Chapter2-OS Services
Chapter2-OS Services
Services
Operating System Concepts – 10th Edition Silberschatz, Galvin and Gagne ©2018
Objectives
Operating System Concepts – 10th Edition 2.2 Silberschatz, Galvin and Gagne ©2018
Chapter 2: Outline
Operating System Concepts – 10th Edition 2.3 Silberschatz, Galvin and Gagne ©2018
Operating System Services
Operating System Concepts – 10th Edition 2.4 Silberschatz, Galvin and Gagne ©2018
Operating System Services
Operating System Concepts – 10th Edition 2.5 Silberschatz, Galvin and Gagne ©2018
Operating System Services
Operating systems provide an environment for the execution of
programs and services to programs and users
One set of operating-system services provides functions that are
helpful to the user:
• User interface - Almost all operating systems have a user
interface (UI).
Varies between Command-Line (CLI), Graphics User
Interface (GUI), touch-screen
• Program execution - The system must be able to load a program
into memory and to run that program, end execution, either
normally or abnormally (indicating error)
• I/O operations - A running program may require I/O, which may
involve a file or an I/O device
• File-system manipulation - The file system is of particular
interest. Programs need to read and write files and directories,
create and delete them, search them, list file Information,
permission management.
Operating System Concepts – 10th Edition 2.6 Silberschatz, Galvin and Gagne ©2018
Operating System Services (Cont.)
Operating System Concepts – 10th Edition 2.7 Silberschatz, Galvin and Gagne ©2018
Operating System Services (Cont.)
Error detection – OS needs to be constantly aware of possible errors
• May occur in the CPU and memory hardware, in I/O devices, in
user program
• For each type of error, OS should take the appropriate action to
ensure correct and consistent computing
• Debugging facilities can greatly enhance the user’s and
programmer’s abilities to use the system efficiently
Protection and security
– Protect access to system resources is controlled
– Security from the outsiders, e.g., user authentication
Operating System Concepts – 10th Edition 2.8 Silberschatz, Galvin and Gagne ©2018
System Services (Cont.)
Background Services
• Launch at boot time
Some for system startup, then terminate
Some from system boot to shutdown
Operating System Concepts – 10th Edition 2.9 Silberschatz, Galvin and Gagne ©2018
Overview of Services in typical
Windows O.S.
Operating System Concepts – 10th Edition 2.10 Silberschatz, Galvin and Gagne ©2018
System Calls
Operating System Concepts – 10th Edition 2.11 Silberschatz, Galvin and Gagne ©2018
System Calls
Operating System Concepts – 10th Edition 2.12 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.13 Silberschatz, Galvin and Gagne ©2018
Example of Standard API
Operating System Concepts – 10th Edition 2.14 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.15 Silberschatz, Galvin and Gagne ©2018
API – System Call – OS Relationship
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
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
• Debugger for determining bugs, single-step execution
• Locks for managing access to shared data between processes
Operating System Concepts – 10th Edition 2.18 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.19 Silberschatz, Galvin and Gagne ©2018
Types of System Calls (Cont.)
Information maintenance ( Metadata )
• get time or date, set time or date
• get system data, set system data
• get and set process, file, or device attributes
Communications (IPC)
• 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.20 Silberschatz, Galvin and Gagne ©2018
Types of System Calls (Cont.)
Protection & Security
• Control access to resources
• Get and set permissions
• Allow and deny user access
Operating System Concepts – 10th Edition 2.21 Silberschatz, Galvin and Gagne ©2018
Examples of Windows and Unix System Calls
Operating System Concepts – 10th Edition 2.22 Silberschatz, Galvin and Gagne ©2018
Why Applications are Operating System Specific
Operating System Concepts – 10th Edition 2.23 Silberschatz, Galvin and Gagne ©2018
Operating System Design &
Implementation
Operating System Concepts – 10th Edition 2.24 Silberschatz, Galvin and Gagne ©2018
Design and Implementation
Operating System Concepts – 10th Edition 2.25 Silberschatz, Galvin and Gagne ©2018
Policy and Mechanism
Policy: What needs to be done?
• Example: Interrupt after every 100 seconds
Mechanism: How to do something?
• Example: timer
Important principle: separate policy from mechanism
The separation of policy from mechanism is a very
important principle, it allows maximum flexibility if policy
decisions are to be changed later.
• Example: change 100 to 200
Operating System Concepts – 10th Edition 2.26 Silberschatz, Galvin and Gagne ©2018
Implementation
Much variation
• Early OSes in assembly language
• Then system programming languages like Algol, PL/1
• Now C, C++
Actually usually a mix of languages
• Lowest levels in assembly
• Main body in C
• Systems programs in C, C++, scripting languages like PERL,
Python, shell scripts
More high-level language easier to port to other hardware
• But slower
Operating System Concepts – 10th Edition 2.27 Silberschatz, Galvin and Gagne ©2018
Building and Booting an Operating System
Operating System Concepts – 10th Edition 2.28 Silberschatz, Galvin and Gagne ©2018
System Boot-Recap
When power initialized on system, execution starts at a fixed memory
location
Operating system must be made available to hardware so hardware
can start it
• Small piece of code – bootstrap loader, BIOS, stored in ROM or
EEPROM locates the kernel, loads it into memory, and starts it
Common bootstrap loader, GRUB, allows selection of kernel from
multiple disks, versions, kernel options ( Linux Distros)
Kernel loads and system is then running
Boot loaders frequently allow various boot states, such as single user
mode
Operating System Concepts – 10th Edition 2.29 Silberschatz, Galvin and Gagne ©2018
Operating System Debugging
Operating System Concepts – 10th Edition 2.30 Silberschatz, Galvin and Gagne ©2018
Operating-System Debugging
Operating System Concepts – 10th Edition 2.31 Silberschatz, Galvin and Gagne ©2018
Performance Tuning
Beyond crashes, performance tuning can optimize system
performance
• Profiling is periodic sampling of instruction pointer to look for
statistical trends
Improve performance by removing bottlenecks
OS must provide means of computing and displaying measures of
system behavior
For example, Windows Task Manager
Operating System Concepts – 10th Edition 2.32 Silberschatz, Galvin and Gagne ©2018
Tracing
Operating System Concepts – 10th Edition 2.33 Silberschatz, Galvin and Gagne ©2018
End of Chapter 2
Operating System Concepts – 10th Edition Silberschatz, Galvin and Gagne ©2018