The document discusses operating system structure and system calls. It defines system calls as the programming interface to OS services, accessed via APIs. It provides examples of common system call types like process control, file management, and inter-process communication using pipes. It also contrasts examples of running programs on single-tasking MS-DOS versus multi-tasking Unix variants like FreeBSD which uses processes and forking.
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
1.7 system calls
1. DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING
CSS308 – OPERATING SYSTEMS
IIIYEAR / V SEMESTER
Prepared by
Dr.Thanuja R
Assistant Professor/ CSE
2. UNIT-I
OPERATING SYSTEMS OVERVIEW
CSS308-OPERATING SYSTEMS / Dr.Thanuja R/ AP/ CSE
Introduction: What Operating systems do - Structure -
Operations - Process management -Operating system Structure:
Services - User Interfaces - Systems calls and types – Systems
programs - Design and implementation - Operating System
Structure - System boot
3. SystemCalls
Programminginterface to the servicesprovided by the O
S
Typicallywritten in ahigh-levellanguage(Cor C++)
Mostly accessed by programs via a high-level Application Programming
Interface(API)rather than direct systemcalluse
Three most common APIs are Win32 API for Windows, POSIXAPI for
POSIX-basedsystems (including virtually all versions of UNIX, Linux, and
MacO
SX),andJavaAPIfor the Javavirtual machine (JVM)
CSS308-OPERATING SYSTEMS / Dr.Thanuja R/ AP/ CSE
5. SystemCallImplementation
Typically,anumber associatedwith eachsystemcall
System-callinterfacemaintains atable indexedaccordingto these
numbers
The system call interface invokes the intended system call in OS
kernel and returns status of the systemcall and any return values
The caller need know nothing about how the system call is
implemented
Justneedsto obeyAPIandunderstand what OSwill do asaresult call
Most details of OSinterface hidden from programmer byAPI
Managedbyrun-time supportlibrary (set of functionsbuilt into libraries
included with compiler)
Why we use APIs rather than system call?
CSS308-OPERATING SYSTEMS / Dr.Thanuja R/ AP/ CSE
7. SystemCallParameter Passing
Often, more information isrequired than simplyidentity of
desired systemcall
Exacttype andamount of information vary accordingtoOSand call
Threegeneral methods usedto passparameters to theOS
Simplest: passthe parameters inregisters
In somecases,maybe more parameters thanregisters
Parametersstored in ablock, or table, inmemory, and addressof block
passedasaparameter in aregister
Thisapproach taken by LinuxandSolaris
Parametersplaced, or pushed,onto the stackby theprogram and
poppedoff the stackby the operatingsystem
Blockandstackmethods do not limit the number or length of
parameters beingpassed
CSS308-OPERATING SYSTEMS / Dr.Thanuja R/ AP/ CSE
11. Typesof SystemCalls
Filemanagement
create file, deletefile
open, closefile
read, write, reposition
get and set fileattributes
Devicemanagement
request device, releasedevice
read, write, reposition
Get& set deviceattributes
logically attach or detachdevices
Protection
Control accessto resources
Getand setpermissions
Allow and denyuseraccess
Information maintenance
gettime or date,set time or date
get systemdata, set systemdata
get and set process,file, ordevice
attributes
Communications
create, delete communication
connection
send,receive messagesif message
passingmodelto hostnameor
processname
Fromclientto server
Shared-memorymodelcreate and
gainaccessto memoryregions
transfer statusinformation
attach and detach remotedevices
13. PIPE() …
•int pipe(int fds[2]);
Parameters :
• fd[0] will be the fd(file descriptor) for the read
end of pipe.
•fd[1] will be the fd for the write end of pipe.
Returns : 0 on Success. -1 on error.
14. Ex:Windows and Unix SystemCalls
StandardCLibraryExample
C program invoking
printf() library call,
which calls write()
system call
CSS308-OPERATING SYSTEMS / Dr.Thanuja R/ AP/ CSE
15. Example:MS-DOS
Single-tasking
Shellinvoked whensystem
booted
Simplemethod torun
program
Noprocesscreated
Singlememory space
Loadsprogram into memory,
overwriting all but thekernel
Programexit ->shellreloaded
At system startup running a program
CSS308-OPERATING SYSTEMS / Dr.Thanuja R/ AP/ CSE
16. Example:FreeBSD
Unix variant
Multitasking
Userlogin ->invokeuser’schoiceofshell
Shellexecutesfork() systemcall tocreate
process
Executesexec()to load programinto
process
Shellwaits for processto terminateor
continues with usercommands
Processexits with:
code=0 –no error
code>0 –error code
CSS308-OPERATING SYSTEMS / Dr.Thanuja R/ AP/ CSE