System calls

 

System Calls


System call is basically a command given to the OS by a user through a program. System calls provide the interface between a process and the operating system.

The system calls involved while executing a simple program to read data from one file and to copy them to another file is illustrated below.


Fig illustrates how the OS handles a user application invoking the open() system call.

 


Types of system calls

System calls can be grouped roughly into five major categories. The following is a summary of the types of system calls provided by an OS.

1.   Process control – end, abort, load, execute, create process, terminate process get process attributes, set process attributes, wait for time, wait event, signal event, allocate and free memory

2.   File management – create file, delete file, open, close, read, write, reposition, get file attributes, set file attributes,

3.   Device management – request device, release device, read, write, reposition, get device attributes, set device attributes, logically attach or detach devices

4.   Information maintenance – get / set time or date, get / set system data, get / set process, file, or device attributes

5.   Communications – create, delete communication connection, send, receive messages, transfer status information, attach or detach remote devices

6.   Protection – Manipulate permission setting of resources (access control)

 

Process Control

System calls are available to create new processes, control their execution and terminate them. Process control requires the ability to determine and reset the attributes of a process, including its priority, maximum allowable execution time, etc.

A running program needs to be able to halt its execution either normally (end) or abnormally (abort). If a system call is made to terminate the currently running program abnormally, or if the program runs into a problem and causes an error trap, the memory is dumped and later examined by a debugger. Debugger is a system program to find error, determine its cause, correct them and Generate error message.

When two or more process share data – OS ensures integrity of data. System calls (acquire_lock() and release_lock()) used to allow process to lock shared data.

 


 

File Management

System calls dealing with files (create and delete files) requires the name of the file and the file's attributes – file name, a file type, protection codes, accounting information. Once the file is created, it can be opened and used – read, write, or reposition (rewind or skip to the end of the file).

 

Device Management

A running program may need additional resources (more memory, tape drives, access to files, and so on) to proceed. If resources are available, grant resource and return control to the user program. Else the program has to wait until sufficient resources become available. Resources controlled by OS can be thought of as Devices. Devices can be physical (ex – disk drives) or abstract or virtual devices (ex – files). If the system has multiple users – first request the device, to ensure exclusive use of it. On finish – release the device.

 

Information Maintenance

System calls are used to transfer information between the user program and OS. System call may return the current time and date, return information about the system, the number of current users, the version number of the operating system, the amount of free memory or disk space, and so on.

System calls are also used in debugging a program. A program trace lists each instruction as it is executed and provides a time profile of a program, which indicates the amount of time that the program executes and the resources used by the program. OS also keeps information about all its processes. System calls can be used to access this information. System calls can also be used to reset the process information (get process attributes and set process attributes).

 

Communication

There are two common models of communication.

1.   Message-passing model

2.   Shared memory model

 


 

Message Passing Model

Information is exchanged through an IPC facility provided by the OS. Each process has a unique id which is used for establishing connection between various processes. Before communication can take place, a connection must be opened. The sending process sends a request connection system call. The receiving process responds with a n accept connection system call. Open connection system calls is used to create the connection between the two process. read message and write message system calls are used to exchange messages. The close connection system calls is used to terminate the connection.

 

Shared – Memory Model

Processes use map memory system calls to gain access to regions of memory owned by other processes. Processes exchange information by reading and writing data in these shared areas. The form of the data and the location are determined by these processes and are not under the operating system's control. The processes are also responsible for ensuring that they are not writing to the same location simultaneously.

 

Protection

OS provides mechanism for controlling access to resources provided by the system. System calls to manipulate permission setting of resources include

1.   set_permission()

2.   get_permissison()

3.   allow_user()

4.   deny_user()


No comments:

Post a Comment

Don't be a silent reader...
Leave your comments...

Anu