0% found this document useful (0 votes)
18 views14 pages

2 System Calls

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views14 pages

2 System Calls

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 14

System Calls, Types

The mechanism used by an application program to request


service from the operating system.

 System calls causes the processor to change mode (e.g. to


"supervisor mode" or "protected mode").

This allows the OS to perform restricted actions such as


accessing hardware devices or the memory management unit.
System Calls
Systems calls are the programming interface to the services
provided by the OS

Typically written in a high-level language (C or C++)


System Calls
Application
(a process, a Application
running program)
System Call Interface
…. System Calls
(OS functions)
Each has a name/number, set of parameters

Other kernel functions

Kernel/OS other kernel functions can be called by system calls


Example of System Calls

System call sequence to copy the contents of one file to


another file
System Call Implementation and Calling
 Typically,
 a number associated with each
system call
 Number used as an index to a
table: System Call table
 Table keeps addresses of system
calls (routines)
 System call runs and returns
 Caller does not know system call
implementation
 Just knows interface
Standard C Library Example
C program invoking printf() library call,
which calls the write() system call
System Call Parameter Passing
Often, more information is required than simply identity of
desired system call
Exact type and amount of information vary according to OS
and call
Three general methods used to pass parameters to the OS
Simplest: pass the parameters in registers
 In some cases, may be more parameters than registers
Parameters stored in a block, or table, in memory, and
address of block passed as a parameter in a register
 This approach taken by Linux and Solaris
Parameters placed, or pushed, onto the stack by the
program and popped off the stack by the operating system
Block and stack methods do not limit the number or length
of parameters being passed
Parameter Passing via Table
Accessing and executing System Calls
System calls typically not accessed directly
by programs Program
Mostly accessed by programs via a high-
API (std lib)
level Application Program Interface (API)
(i.e. a library) rather than direct system call
use OS Sys Calls
Rest of Kernel
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
Example of Standard API
 Consider the ReadFile() function in the Win32 API — a function for
reading from a file

 A description of the parameters passed to ReadFile()


 HANDLE file—the file to be read
 LPVOID buffer—a buffer where the data will be read into and written
from
 DWORD bytesToRead—the number of bytes to be read into the buffer
 LPDWORD bytesRead—the number of bytes read during the last read
 LPOVERLAPPED ovl—indicates if overlapped I/O is being used
Types of System Calls
 System calls can be grouped into six major categories:
 Process control
 Load, execute, end, abort, create process, get/set process
attributes, wait for time/signal, allocate/free memory
 File management (manipulation)
 Create/delete/open/close/read/write a file, get/set file attributes

 Device management
 Request/release device, read/write data, get/set attributes

 Information maintenance
 Get/set time or date, get/set system data, get/set attributes for

process/file/device
 Communications
 Create/delete connection, send/receive messages, attach/detach

devices
Protection:Protection provides a mechanism for controlling access

to the resources provided by a computer system


Types of System Calls
 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
 File management
 create file, delete file
 open, close file
 read, write, reposition
 get and set file attributes
Types of System Calls
 Device management
 request device, release device
 read, write, reposition
 get device attributes, set device attributes
 logically attach or detach devices
 Information maintenance
 get time or date, set time or date
 get system data, set system data
 get and set process, file, or device attributes
 Communications
 create, delete communication connection
 send, receive messages
 transfer status information
 attach and detach remote devices
Examples of Windows and
Unix System Calls

You might also like