OS

System Calls

System calls provide the interface between a process & the OS. These are usually available in the form of assembly language instruction. Some systems allow system calls to be made directly from a high level language program like C, BCPL and PERL etc. systems calls occur in different ways depending on the computer in use. System calls can be roughly grouped into 5 major categories.

1. Process Control:

  • End, abort: A running program needs to be able to has its execution either normally (end) or
    abnormally (abort).
  • Load, execute: A process or job executing one program may want to load and executes another program.
  • Create Process, terminate process: There is a system call specifying for the purpose of creating a new process or job (create process or submit job). We may want to terminate a job or process that we created (terminates process, if we find that it is incorrect or no longer needed).
  • Get process attributes, set process attributes: If we create a new job or process we should able to control its execution. This control requires the ability to determine & reset the attributes of a job or processes (get process attributes, set process attributes).
  • Wait time: After creating new jobs or processes, we may need to wait for them to finish their execution (wait time).
  • Wait event, signal event: We may wait for a specific event to occur (wait event). The jobs or processes then signal when that event has occurred (signal event).

2. File Manipulation:

  • Create file, delete file: We first need to be able to create & delete files. Both the system calls
    require the name of the file & some of its attributes.
  • Open file, close file: Once the file is created, we need to open it & use it. We close the file
    when we are no longer using it.
  • Read, write, reposition file: After opening, we may also read, write or reposition the file
    (rewind or skip to the end of the file).
  • Get file attributes, set file attributes: For either files or directories, we need to be able to
    determine the values of various attributes & reset them if necessary. Two system calls get file
    attribute & set file attributes are required for their purpose.

3. Device Management:

  • Request device, release device: If there are multiple users of the system, we first request the device. After we finished with the device, we must release it.
  • Read, write, reposition: Once the device has been requested & allocated to us, we can read,
    write & reposition the device.

4. Information maintenance:

  • Get time or date, set time or date: Most systems have a system call to return the current
    date & time or set the current date & time.
  • Get system data, set system data: Other system calls may return information about the
    system like the number of current users, the version number of OS, amount of free memory etc.
  • Get process attributes, set process attributes: The OS keeps the information about all its
    processes & there are system calls to access this information.

5. Communication:

There are two modes of communication such as:

  • Message passing model: Information is exchanged through an inter process communication facility provided by operating system. Each computer in a network has a name by which it is known. Similarly, each process has a process name which is translated to an equivalent identifier by which the OS can refer to it. The get hostid and get processed systems calls to do this translation. These identifiers are then passed to the general purpose open & close calls provided by the file system or to specific open connection system call. The recipient process must give its permission for communication to take place with an accept connection call. The source of the communication known as client & receiver known as server exchange messages by read message & write message system calls. The close connection call terminates the connection.
  • Shared memory model: processes use map memory system calls to access regions of memory owned by other processes. They exchange information by reading & writing data in the shared areas. The processes ensure that they are not writing to the same location simultaneously.