What is System Calls and it's types./Explain in detail about system calls ?
- Get link
- Other Apps
Definition:-
The interface between the operating system and the user programs in defined by the set of "extended instruction" that the operating system provides. These extended instructions are known as system calls.
User programs communicate with the operating system and request services from it by making system calls. There exists a library procedure corresponding to each system call that user program can call. This procedure puts the parameters of the system call in a specific place, such as the machine registers, and then issues a TRAP instruction to start the operating system. When the operating system gets control after the TRAP, it examines the parameters to see if they are valid, and if so, performs the work requested. When it is finished, the operating system puts a status code in a register, telling whether it succeeded of failed, and executes a RETURN FROM TRAP instruction, 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.
System calls allow user-level processes to request services of the operating system. this is the main purpose of system calls.
Types of System Calls:-
System calls can be grouped into five categories:- process control, file management, device management, information management and communications.
i) Process Control:- 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. An interesting question arises that where to return control when the loaded program terminates. if control returns to the existing program when the new program terminates, the memory image of the existing program must be saved. Thus, we have effectively created a mechanism for one program to call another program. if both program continues concurrently, we have created a new job or process to be multi-programmed. The system calls for this purpose are create process or submit job.
After creating new jobs or processes, it is needed to wait for them to finish their execution. We may want to wait for a certain amount of time (wait time). More likely, we may want to wait for a specific event to occur (wait event). The jobs or processes then signal when that event has occurred (signal event).
ii) File Management:- We need to able to create and delete files. Either system call requires the name of the file and perhaps some of the file's 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 it is no longer used.
We may need these same sets of operation for directories if we have a directory structure for organizing files in the file system. For files or directories, we need to be able to determine the values of various attributes and to reset them. File attributes are the file name, a file , protection codes, accounting information and so on. Two system calls, get file attribute and set file attribute, are required for this function.
iii) Device Management:- A running program may need additional resources to proceed such as memory, access to files and so on. if the resources are available, they are granted, and control is returned to the user program. Otherwise the program will have to wait until resources are free.
Files are thought of as abstract or virtual devices. thus, many of the system calls for files are also needed for devices. If the system has multiple users, we must first request the devices to ensure exclusive use of it. After we are finished with the device, we must release it. Once, the device has been requested and allocated to us, we can read, write, and reposition the device.
iv) Information Management:- Many system calls exist for the purpose of transferring information between the user program and the operating system. For example, most system 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 operating system, the amount of free memory or disk space, and so on.
v) Communication:- There are two common models of communication. In the message-passing model, information is exchanged through an inter process-communication facility provided by the operating system. A connection is opened before communication must be known, whether it is another process on the same CPU, or a process on another computer in communications network. Each computer in a network has a host name. Similarly, each process has a process name, which is translated into an equivalent identifier for referring to it by the operating system. The get host-id and get process-id system calls do this translation. these identifiers are then passed to the general purpose open and close calls provided by the file system, or to specific open connection and close connection system calls. The recipient process gives its permission for communication to take place with an accept connection call. Most processes that will be receiving connections are special purpose daemons. they execute a wait for connection call and are awakened when a connection is made. the source of the communication, known as the client, and the receiving daemon, known as a server, then exchange messages by read message and write message system calls. The close connection call terminates the communication.
In the shared-memory model, processes use map memory system calls to gain access to regions of memory owned by other processes.
- Get link
- Other Apps
Comments
Post a Comment