Ch2 Operating System Structures
Ch2 Operating System Structures
Structures
Operating System Concepts Essentials– 8th Edition Silberschatz, Galvin and Gagne ©2011
Operating System Services
Operating systems provide an environment for execution of programs and
services to programs and users
Operating-system services provided to the user:
User interface - Almost all operating systems have a user interface (UI).
Varies between Command-Line (CLI), Graphics User Interface (GUI).
Program execution - It provides programs an environment to execute.
I/O operations - Operating system provides the access to the required I/O
device when required.
Operating System Concepts Essentials – 8th Edition 2.2 Silberschatz, Galvin and Gagne ©2011
Operating System Services (Cont.)
Communications – Processes may exchange information, on the
same computer or between computers over a network
Communications may be via shared memory or through
message passing (packets moved by the OS)
Error detection – OS needs to be constantly aware of possible
errors. An error may occur in the CPU and memory hardware, in I/O
devices, in user program.
The OS constantly checks for possible errors.
For each type of error, the OS takes an appropriate action to
ensure correct and consistent computing.
Operating System Concepts Essentials – 8th Edition 2.3 Silberschatz, Galvin and Gagne ©2011
User Operating System Interface - CLI
Operating System Concepts Essentials – 8th Edition 2.4 Silberschatz, Galvin and Gagne ©2011
User Operating System Interface - GUI
Operating System Concepts Essentials – 8th Edition 2.5 Silberschatz, Galvin and Gagne ©2011
Bourne Shell Command Interpreter
Operating System Concepts Essentials – 8th Edition 2.6 Silberschatz, Galvin and Gagne ©2011
The Mac OS X GUI
Operating System Concepts Essentials – 8th Edition 2.7 Silberschatz, Galvin and Gagne ©2011
System Calls
Programming interface to the services provided by the OS
Examples of APIs are Win32 API for Windows, and Java API for the
Java virtual machine (JVM).
Operating System Concepts Essentials – 8th Edition 2.8 Silberschatz, Galvin and Gagne ©2011
Example of System Calls
System call sequence to copy the contents of one file to another file
Operating System Concepts Essentials – 8th Edition 2.9 Silberschatz, Galvin and Gagne ©2011
API – System Call – OS Relationship
Operating System Concepts Essentials – 8th Edition 2.10 Silberschatz, Galvin and Gagne ©2011
Standard C Library Example
C program invoking printf() library call, which calls write() system call
Operating System Concepts Essentials – 8th Edition 2.11 Silberschatz, Galvin and Gagne ©2011
System Calls
To understand system calls, first one needs to understand the difference
between kernel mode and user mode of a CPU. Every modern operating
system supports these two modes.
Operating System Concepts Essentials – 8th Edition 2.12 Silberschatz, Galvin and Gagne ©2011
System Calls
Kernel Mode
When CPU is in kernel mode, the code being executed can access any
memory address and any hardware resource.
Hence kernel mode is a very privileged and powerful mode.
If a program crashes in kernel mode, the entire system will be halted.
User Mode
When CPU is in user mode, the programs don’t have direct access to
memory and hardware resources.
In user mode, if any program crashes, only that particular program is
halted.
That means the system will be in a safe state even if a program in user
mode crashes.
Hence, most programs in an OS run in user mode.
Operating System Concepts Essentials – 8th Edition 2.13 Silberschatz, Galvin and Gagne ©2011
Types of System Calls
Process control
end, abort
load, execute
create process, terminate process
get process attributes, set process attributes
wait for time
wait event, signal event
allocate and free memory
File management
create file, delete file
open, close file
read, write, reposition
get and set file attributes
Operating System Concepts Essentials – 8th Edition 2.14 Silberschatz, Galvin and Gagne ©2011
Types of System Calls (Cont.)
Device management
request device, release device
read, write, reposition
get device attributes, set device attributes
logically attach or detach devices
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
transfer status information
attach and detach remote devices
Operating System Concepts Essentials – 8th Edition 2.15 Silberschatz, Galvin and Gagne ©2011