System call provide the interface between a process and the operating system. these calls are generally available as assembly language instructions, and they are usually listed in the various manuals by the assembly language programmers. certain operations can be performed only by the operating system. The user can performs this action only through the request.

How system calls are used?

Writing a simple program to read data from one file and to copy them to another file. the first input that the program will need is the names of the two files: the input and output file. these names can be specified in many ways, depending on the operating system design. one approach is for the program to ask the user for the names of the two files. in an interactive system, this approach will require a sequence of system calls, first to write a prompting message on the screen, and then to read from the keyboard the character that define the two files. once the two files are obtained, the program must open the input file and create the output file. 

In some cases, they are written in high level language. eg. using system call to read data from one file and copy the same to the another file.

Step 1: System acquires the name of two files. the name are specified either by using keyboard and mouse icon

Step 2: The names are received and the system checks whether source file name already exists, according to the situation system should handle the system

Step 3: If the source file does not exist or protected from access, the system should message, the console.

step 4: The system enters a loop that reads from the source file and write the information into the destination file

Types of system call

Process control

A running program needs to be able to halt its execution either normally (end) and abnormally (abort). a process or job executing one program may want to load and execute another program. 

This feature allows the command interpreter to execute  a program as directed by, for example, a user command, the click of a mouse, or a batch command.

File management

we first need to be able to create and delete files. either system call requires the name of the file and perhaps some of the files attributes. once the file is created, we need to open  it and to use it. we may also read, write, or reposition. finally, we need to close the file, indicating that we are no longer using it.

Device management

a program, as it running, may need additional resources to proceed. additional resources may be more memory, tape drives, access to files and so on. if the resources are available, they can be granted, and control can be returned to the user program; otherwise, the program will have to wait until sufficient resources are available.

Information maintenance

Many system calls exist simply for the purpose of transferring information between the user program and the operating system. for example, most systems have a system call to return the current time and date. other system calls may return information about the system, such as the number of current users, the version number of the operating system, the amount of free memory or disk space, and so on

In addition, the operating system keeps information about all its processes, and there are system calls to access this information

Communication

There are two common models of communication. in the message- passing model, information is exchanged through an interprocess-communication facility provided by the operating system.

In the shared memory model, processes use map memory system calls to gain access to regions of memory owned by other processes. shared memory requires that several processes agree to remove this restriction.

Reference video