0% found this document useful (0 votes)
17 views13 pages

1.7 System Calls

Uploaded by

revicse
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)
17 views13 pages

1.7 System Calls

Uploaded by

revicse
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/ 13

ARASU ENGINEERING

COLLEGE
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

CS3451 – INTRODUCTION TO
OPERATING SYSTEMS
II YEAR / IV SEMESTER
Anna University Syllabus, 2021
Regulation
Prepared by
Mrs. V. Revathy
Assistant
Professor/ CSE
System Calls
 Programming interface to the services provided by the OS

 Typically written in a high-level language (C or 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), and Java API for the Java virtual machine (JVM)

CS3451-IOS/ V. REVATHY / AP/ CSE - AEC


Example of System Calls
 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 need know nothing about how the system call is
implemented
 Just needs to obey API and understand what OS will do as a result 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)

CS3451-IOS/ V. REVATHY / AP/ CSE - AEC


API – System Call – OS Relationship

CS3451-IOS/ V. REVATHY / AP/ CSE - AEC


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

CS3451-IOS/ V. REVATHY / AP/ CSE - AEC


Parameter Passing via Table

CS3451-IOS/ V. REVATHY / AP/ CSE - AEC


Types of System Calls
 Process control
 create process, terminate process
 end, abort
 load, execute
 get process attributes, set process attributes
 wait for time
 wait event, signal event
 allocate and free memory
 Dump memory if error
 Debugger for determining bugs, single step execution
 Locks for managing access to shared data between processes

CS3451-IOS/ V. REVATHY / AP/ CSE - AEC


Types of System Calls
 File management  Information maintenance
 create file, delete file  get time or date, set time or date
 open, close file  get system data, set system data
 read, write, reposition  get and set process, file, or device
 get and set file attributes attributes
 Device management  Communications
 request device, release device  create, delete communication
connection
 read, write, reposition
 send, receive messages if message
 Get & set device attributes
passing model to host name or
 logically attach or detach devices process name
 Protection  From client to server

 Control access to resources  Shared-memory model create and


gain access to memory regions
 Get and set permissions
 transfer status information
 Allow and deny user access
 attach and detach remote devices
Ex: Windows and Unix System Calls
 C program invoking
printf() library call,
which calls write()
system call

Standard C Library Example


CS3451-IOS/ V. REVATHY / AP/ CSE - AEC
Example: MS-DOS
 Single-tasking
 Shell invoked when system
booted
 Simple method to run
program
 No process created
 Single memory space
 Loads program into memory,
overwriting all but the kernel
At system startup running a program
 Program exit -> shell reloaded

CS3451-IOS/ V. REVATHY / AP/ CSE - AEC


Example: FreeBSD
 Unix variant
 Multitasking
 User login -> invoke user’s choice of shell
 Shell executes fork() system call to create
process
 Executes exec() to load program into
process
 Shell waits for process to terminate or
continues with user commands
 Process exits with:
 code = 0 – no error
 code > 0 – error code
CS3451-IOS/ V. REVATHY / AP/ CSE - AEC
Thank You
CS3451-IOS/ V. REVATHY / AP/ CSE - AEC

You might also like