Chapter 2: Operating-System Services Week 3: Silberschatz, Galvin and Gagne ©2018 Operating System Concepts - 10 Edition
Chapter 2: Operating-System Services Week 3: Silberschatz, Galvin and Gagne ©2018 Operating System Concepts - 10 Edition
Chapter 2: Operating-System
Services
Operating System Concepts – 10th Edition Silberschatz, Galvin and Gagne ©2018
System Calls
System calls provide the interface between a user’s process and the
OS. System calls work silently in the background, interfacing with the
kernel to get work done.
Operating System Concepts – 10th Edition 2.2 Silberschatz, Galvin and Gagne ©2018
System Calls (Cont.)
The system call interface layer contains entry point in the kernel code;
because all system resources are managed by the kernel any user or
application request that involves access to any system resource must
be handled by the kernel code, but user process must not be given
open access to the kernel code for security reasons.
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)
Operating System Concepts – 10th Edition 2.3 Silberschatz, Galvin and Gagne ©2018
What is the difference??
API is just a programming library, e.g. libc, on top of the basic system
calls, provided by the kernel, which further ease the job of the
developer.
Operating System Concepts – 10th Edition 2.4 Silberschatz, Galvin and Gagne ©2018
Example of System Calls
System call sequence to copy the contents of one file to another file
Operating System Concepts – 10th Edition 2.5 Silberschatz, Galvin and Gagne ©2018
Example of Standard API
Operating System Concepts – 10th Edition 2.6 Silberschatz, Galvin and Gagne ©2018
System Call Implementation
Operating System Concepts – 10th Edition 2.7 Silberschatz, Galvin and Gagne ©2018
API – System Call – OS Relationship
Operating System Concepts – 10th Edition 2.8 Silberschatz, Galvin and Gagne ©2018
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
Operating System Concepts – 10th Edition 2.9 Silberschatz, Galvin and Gagne ©2018
Parameter Passing via Table
Operating System Concepts – 10th Edition 2.10 Silberschatz, Galvin and Gagne ©2018
Types of System Calls
Operating System Concepts – 10th Edition 2.11 Silberschatz, Galvin and Gagne ©2018
Types of System Calls (Cont.)
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
Operating System Concepts – 10th Edition 2.12 Silberschatz, Galvin and Gagne ©2018
Types of System Calls (Cont.)
File management
• create file, delete file
• open, close file
• read, write, reposition
• get and set file attributes
Device management
• request device, release device
• read, write, reposition
• get device attributes, set device attributes
• logically attach or detach devices
Operating System Concepts – 10th Edition 2.13 Silberschatz, Galvin and Gagne ©2018
Types of System Calls (Cont.)
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 if message passing model to host
name or process name
From client to server
• Shared-memory model create and gain access to memory
regions
• transfer status information
• attach and detach remote devices
Operating System Concepts – 10th Edition 2.14 Silberschatz, Galvin and Gagne ©2018
Types of System Calls (Cont.)
Protection
• Control access to resources
• Get and set permissions
• Allow and deny user access
Operating System Concepts – 10th Edition 2.15 Silberschatz, Galvin and Gagne ©2018
Examples of Windows and Unix System Calls
Operating System Concepts – 10th Edition 2.16 Silberschatz, Galvin and Gagne ©2018
Standard C Library Example
C program invoking printf() library call, which calls write() system call
Operating System Concepts – 10th Edition 2.17 Silberschatz, Galvin and Gagne ©2018
Example: Arduino
Single-tasking
No operating system
Programs (sketch) loaded via
USB into flash memory
Single memory space
Boot loader loads program
Program exit -> shell
reloaded
Operating System Concepts – 10th Edition 2.18 Silberschatz, Galvin and Gagne ©2018
Why Applications are Operating System Specific
Operating System Concepts – 10th Edition 2.19 Silberschatz, Galvin and Gagne ©2018
Book study
Chapter 2: System Calls
Operating System Concepts – 10th Edition 2.20 Silberschatz, Galvin and Gagne ©2018