System Calls
Unit-1 Umesh P Rout
System Call
● System calls provide a programming interface to the services provided by
the OS
● System calls are the only entry points into the kernel system
● These calls generally available as routines written in C and C++
● Mostly accessed by programs via a high-level Application Programming
Interface (API) rather than direct system call use
● Three most common APIs are
○ Win32 API for Windows,
○ POSIX API for POSIX-based systems (including virtually all versions of
UNIX, Linux, and Mac OS X)
○ Java API for the Java virtual machine (JVM)
2
Example of System Call
System call sequence to copy the contents of one file to another file
3
System Call Implementation
● Typically, a number associated with each system call. System-call
interface maintains a table indexed according to these numbers
● The system call interface invokes the intended system call in OS
kernel and returns status of the system call and any return values
● The caller needs to know nothing about how the system call is
implemented. Just needs to obey API and understand what OS will do
as a result of system call
○ Most details of OS interface hidden from programmer by API
○ Managed by run-time support library (set of functions built into
libraries included with compiler)
4
API – System Call – OS Relationship
5
Standard C Library Example
C program invoking printf() library call, which calls write() system call
6
Types of System Calls
System calls can be grouped roughly into six major
categories:
1. Process Control
2. File Management
3. Device Management
4. Information Maintenance
5. Communication
6. Protection
7
Types of System Calls (Cont.)
1. Process Control System Call
● create process, terminate process
● end, abort
● load, execute
● get process attributes, set process attributes
● wait for time
● allocate and free memory
● wait event, signal event
2. File Management System Call
● create file, delete file
● open, close file
● read, write, reposition
● get and set file attributes 8
Types of System Calls (Cont.)
3. Device Management System Call
● request device, release device
● read, write, reposition
● get device attributes, set device attributes
● logically attach or detach devices
4. Information Maintenance System Call
● get time or date, set time or date
● get system data, set system data
● get and set process, file, or device attributes
9
Types of System Calls (Cont.)
5. Protection System Call
● Control access to resources
● Get and set permissions
● Allow and deny user access
6. Communication System Call
● create, delete communication connection
● send, receive messages
● transfer status information
● attach and detach remote devices
10
Examples of Windows and Unix System Calls
11