Home » Operating Systems

System Calls in Operating System

In this article, we will learn about the introduction of system calls and also discuss about the various types of system call in operating system.
Submitted by Prerana Jain, on December 11, 2018

Introduction to System calls

The interface between the operating system and the user program is defined by the set of extended instruction that the operating system provides. These extended instructions are known as system calls. User program communicates with the operating system and request services from if by making system calls. There exist a library procedure corresponding to each system call that the user program can call. System call allows user-level processes to required services of the operating system. This procedure put the parameter of the system call in a specified place, such as the machine registers, and then issue TRAP instructions to start the operating system. When the operating system gets control after TRAP it examines the parameters to see if they are valid and if so perform the work requested. When it is finished the operating system puts a status code in a register telling whether it succeed or failed and execute a RETURN FROM TRAP instructions to return control back to the library procedure. The library procedure then returns to the caller in the usual way, returning the status code as a function value.

Any operation perform in the system require the system and if any error occurs in the system it needs additional system calls for solving the errors. Suppose if any program wants to open a file and the file of that name may not exist in the system, in this case, the program print a message on the console window that the file does not exists all these things done by the system calls. System calls are callable from the assembly language. We have often encountered phrase such as “ assembly language under DOS”. We should now be clear about its meaning. The assembly language programmer needs to know the assembly language instructions set for that machine. In addition, he normally needs to aware of the system calls of the operating system running on that machine. Many high-level languages such as C and also enables the system calls to be embedded explicitly in the midst of other statements. Some high-level language such as JAVA or C++ does not need the explicit use of system calls embedded in other statements. In these scenarios the compiler substitutes system calls at specific locations.

The two-parameter will be substituting various sets of operations system calls for the same source's statements such a fread, fwrite or execute. Generally, the mapping between the system calls of two operating system is never straightforward. Normally before the real system calls, the compiler produces machine instructions which are preparatory instructions for that system call.


Types of system calls

System calls can be grouped into five categories- process control, file management, device management, information management, and communication.

1. Process control

A process or the job which is currently run in the system always want to load and execute another program. The command interpreter executes a program for example when the user clicks on the mouse button. Now the question arises that when the loaded program terminates when the control return. When any new program terminates in the system the memory the currently running program must be saved. So in this way we can efficiently create a program which calls another program and both are running concurrently. For the multiprogramming, we have created jobs or process. So the system calls for this purpose is called create a process or submit the job. When a new job, process or the group of the process is created then we have to manage the execution of these process.

2. File management

In the file management system, we should be able to create or delete the files. For creating a file the system call requires the names of the file and some attribute of the files. When the file is created we should be able to open and use these files. We can also read-write or reposition the files. After all the work is done we need to close the file which indicates that the file is no longer need. We can also use these operations for directories also. In the file management system, we should be able to determine the values of various attributes for the file and directories. There are various file attributes like name, types, size, location, accounting information and so on. The two important system calls get attribute and file set attribute is required for this function.

3. Device management

When the program is running in the system it needs some resources such as memory, input, output, and so on. The resources are only granted when they are available and not held by another process. If the resources are not free the program has to wait for the resources. Files are the abstract or virtual devices. So there are many system calls which are needed for the files and also for the devices. If there are multiple users then first it requests for the devices and after finishing the work with these devices we should release it. When the devices are allocated to the user then we can perform different operations like reading, write and execute.

4. Information management

In information management, various system calls are used to communicate the information between the operating system and user program. For example, some system has a system call forget the current time or date. There are many another system call like for the number of the user, different versions of operating system., free space in memory etc.

5. Communication

There are mainly two models for communication. First is the message passing model in this the information is exchanged between the process and this communication facility is provided by the operating system. When the process wants to communicate first the other communicator should be know so that the communication is established and they can communicate. Second is the shared memory model in this model different process shared memory and communicate with each other.





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.