Definition of a system call in Operating System.
System calls provide an interface to such services that are made available by an Operating System. This calls are generally available as routine written in C and C+ + languages. Although, the some low level task or system calls must have to be written using assembly language instruction for direct communication and accessed by the hardware.
Let's take a simple example to illustrate how system calls are called and used:
First " writing a simple program to read data from one file to another file and copy them to another file. The first input that the program will need is the name of two files - the input file and output file. These name 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. 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 characters that define the two files.
It could be possible to occur error condition during this whlole processing, so it will must require the another sequence of system calls for managing this process execution. For Example : when the program tries to open the input file it may find that there is no file of that name or that the file is protected against access. In this case, the program should print a message on the console ( another sequence of system calls) and then terminate abnormally ( another system call).
If the input file exists, then we must create a new output file. We may find that there is already an output file with the same name. This situation may cause the program to abort ( a system call) or we may delete the existing file ( another system call) and create a new one (yet another system call). So this process is going continuously until the process will successfully finish or terminated if any errors will countered while processing.
System call Interface Indexing Table :
When both files are set up with integral of that reads from the input file and write to the output file. The read and write must return status information regarding various possible errors conditions. In read operation, the program May find that the end of the file has been reached or that there was a hardware failure in the read (such as a priority error). The write operation may encounter various error depending on the output device, for example : "no more disks space".The relationship between an API, system-call Interface, and the operating system is shown below:
The Caller need know nothing about how the system call is implemented or what it does during the execution. Rather, the caller need only obey the API and understand what the operating system will do as a result of the execution of that system call. Thus, most of the details of the operating system interface are hidden from the programmer by the API ( Application programming interface ) and are managed by the run-time support library. In the above diagram are showing how the operating system handles a user's application invoking the open( ) system call.
Three types of methods are used to pass the parameters in operating systems :
● The easiest and simple way to pass the parameters in operating system through the Registers.
● And the another approach is set of block, in some cases the parameters are stored in a blocks or table, in memory, and then the address of the block is passed as a parameter in a Registers. This type of approache taken by Linux and Solaris systems.
● The last approach is, parameters may also be placed or pushed onto the stack by the program and popped off the stack by the operating system.
Note: There are some systems that prefer the block or stack method because those approaches do not limit the number or length of parameters will pass.
Figures B: click on the image for better visibility.