0% found this document useful (0 votes)
41 views

Chapter 2: Operating-System Services Week 3: Silberschatz, Galvin and Gagne ©2018 Operating System Concepts - 10 Edition

Uploaded by

malaika ghufran
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views

Chapter 2: Operating-System Services Week 3: Silberschatz, Galvin and Gagne ©2018 Operating System Concepts - 10 Edition

Uploaded by

malaika ghufran
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 20

Week 3

Chapter 2: Operating-System
Services

Operating System Concepts – 10th Edition Silberschatz, Galvin and Gagne ©2018
System Calls

 A system call is a way for programs to interact with the operating


system
 A system call is a programmatic way a program requests a service
from the kernel

 An operating system can roughly be divided into two modes:


• Kernel mode: A privileged and powerful mode used by the
operating system kernel
• User mode: Where most user applications run

 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??

 System Calls, System Call Interface and API

 a system call is a request to the kernel for a service


 The system call interface is the basic interface between a program
and the kernel.

 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

 Typically, a number is 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)

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

• 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

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

 System calls can be grouped roughly into six major categories:


1. Process control
2. File management
3. Device management
4. Information maintenance
5. Communications
6. Protection

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

At system startup running a program

Operating System Concepts – 10th Edition 2.18 Silberschatz, Galvin and Gagne ©2018
Why Applications are Operating System Specific

 Apps compiled on one system usually not executable on other


operating systems
 Each operating system provides its own unique system calls
• Own file formats, etc.
 Apps can be multi-operating system
• Written in interpreted language like Python, Ruby, and interpreter
available on multiple operating systems
• App written in language that includes a VM containing the running
app (like Java)
• Use standard language (like C), compile separately on each
operating system to run on each
 Application Binary Interface (ABI) is architecture equivalent of API,
defines how different components of binary code can interface for a
given operating system on a given architecture, CPU, etc.
• Thus ABI is the architecture-level equivalent of an API

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

You might also like