CH 2
CH 2
Structures
Operating System Concepts – 9th Edition Silberschatz, Galvin and Gagne ©2013
2.1 Operating System Services
Operating systems provide an environment for execution of programs
and services to programs and to the users of those programs users
One set of operating-system services provides functions that are
helpful to the user:
1. User interface - Almost all operating systems have a user
interface (UI).
Command-Line (CLI) which uses text commands and a
method for entering them (say, a keyboard for typing in
commands in a specific format with specific options)
Batch in which commands and directives to control
those commands are entered into files, and those files
are executed)
Graphics User Interface (GUI) interface is a window
system with a pointing device to direct I/O, choose from
menus, and make selections and a keyboard to enter text.
Operating System Concepts – 9th Edition 2.2 Silberschatz, Galvin and Gagne ©2013
Operating System Services
One set of operating-system services provides functions that are
helpful to the user (Cont.):
Operating System Concepts – 9th Edition 2.3 Silberschatz, Galvin and Gagne ©2013
Operating System Services (Cont.)
One set of operating-system services provides functions that are helpful to the user
(Cont.):
5. 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)
6. Error detection – OS needs to be constantly aware of possible errors
May occur in
– - CPU and memory hardware (such as a memory error or a power
failure),
– - I/O devices (such as a parity error on disk, a connection failure on a
network, or lack of paper in the printer),
– - user program (such as an arithmetic overflow)
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 efficiently use the system
Operating System Concepts – 9th Edition 2.4 Silberschatz, Galvin and Gagne ©2013
Operating System Services (Cont.)
Another set of OS functions exists for ensuring the efficient operation of the
system itself via resource sharing
Systems with multiple users can gain efficiency by sharing the computer
resources among the users
services.
Operating System Concepts – 9th Edition 2.5 Silberschatz, Galvin and Gagne ©2013
Operating System Services (Cont.)
Another set of OS functions exists for ensuring the efficient operation of the
system itself via resource sharing
8. Protection and security - The owners of information stored in a
multiuser or networked computer system may want to control use of
that information, concurrent processes should not interfere with each
other
Protection involves ensuring that all access to system resources is
controlled
Security of the system from outsiders requires user authentication,
extends to defending external I/O devices including network
adapters from invalid access attempts
If a system is to be protected and secure, precautions must be
instituted throughout it.
Operating System Concepts – 9th Edition 2.6 Silberschatz, Galvin and Gagne ©2013
A View of Operating System Services
Operating System Concepts – 9th Edition 2.7 Silberschatz, Galvin and Gagne ©2013
2.2 User and Operating-System Interface
Operating System Concepts – 9th Edition 2.8 Silberschatz, Galvin and Gagne ©2013
User and Operating-System Interface
Operating System Concepts – 9th Edition 2.9 Silberschatz, Galvin and Gagne ©2013
Touchscreen Interfaces
Operating System Concepts – 9th Edition 2.10 Silberschatz, Galvin and Gagne ©2013
The Mac OS X GUI
Operating System Concepts – 9th Edition 2.11 Silberschatz, Galvin and Gagne ©2013
2.3 System Calls
System calls provide an interface to the services made available
by an operating system.
Typically written in a high-level language (C or C++)
Example: writing a simple program to read data from one file and
copy them to another file
first input that the program will need is the names of the two
files (input and output file)
names can be specified in many ways
ask the user
– require a sequence of system calls, first to write a
prompting message on the screen and then to read from
the keyboard.
the program must open the input file and create the output file
Etc…
we enter a loop that reads from the input file (a system call)
and writes to the output file
Etc …
Operating System Concepts – 9th Edition 2.12 Silberschatz, Galvin and Gagne ©2013
System Calls
As you can see, even simple programs
may make heavy use of the operating system.
systems execute thousands of system calls per second.
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 – 9th Edition 2.13 Silberschatz, Galvin and Gagne ©2013
Example of System Calls
System call sequence to copy the contents of one file to another file
Operating System Concepts – 9th Edition 2.14 Silberschatz, Galvin and Gagne ©2013
Example of Standard API
Operating System Concepts – 9th Edition 2.15 Silberschatz, Galvin and Gagne ©2013
System Call Implementation
Operating System Concepts – 9th Edition 2.16 Silberschatz, Galvin and Gagne ©2013
API – System Call – OS Relationship
Operating System Concepts – 9th Edition 2.17 Silberschatz, Galvin and Gagne ©2013
System Call Implementation
Operating System Concepts – 9th Edition 2.18 Silberschatz, Galvin and Gagne ©2013
2.4 Types of System Calls
System calls can be grouped roughly into six major categories: process
control, file manipulation, device manipulation, information
maintenance,communications, and protection.
2.4.1 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 – 9th Edition 2.19 Silberschatz, Galvin and Gagne ©2013
Types of System Calls
Operating System Concepts – 9th Edition 2.20 Silberschatz, Galvin and Gagne ©2013
Types of System Calls (Cont.)
Operating System Concepts – 9th Edition 2.21 Silberschatz, Galvin and Gagne ©2013
Types of System Calls (Cont.)
2.4.6 Protection
Control access to resources
Get and set permissions
Allow and deny user access
Operating System Concepts – 9th Edition 2.22 Silberschatz, Galvin and Gagne ©2013
Examples of Windows and Unix System Calls
Operating System Concepts – 9th Edition 2.23 Silberschatz, Galvin and Gagne ©2013
Standard C Library Example
C program invoking printf() library call, which calls write() system call
Operating System Concepts – 9th Edition 2.24 Silberschatz, Galvin and Gagne ©2013
2.5 System Programs
System programs or system utilities provide a convenient
environment for program development and execution. They can
be divided into:
File manipulation
Status information sometimes stored in a File modification
Programming language support
Program loading and execution
Communications
Background services
Application programs
Most users’ view of the operation system is defined by system
programs, not the actual system calls
Operating System Concepts – 9th Edition 2.25 Silberschatz, Galvin and Gagne ©2013
System Programs
Provide a convenient environment for program development and
execution
Some of them are simply user interfaces to system calls; others
are considerably more complex
Status information
Some ask the system for info - date, time, amount of available
memory, disk space, number of users
Others provide detailed performance, logging, and debugging
information
Typically, these programs format and print the output to the
terminal or other output devices
Some systems implement a registry - used to store and
retrieve configuration information
Operating System Concepts – 9th Edition 2.26 Silberschatz, Galvin and Gagne ©2013
System Programs (Cont.)
File modification
Text editors to create and modify files
Special commands to search contents of files or perform
transformations of the text
Programming-language support - Compilers, assemblers,
debuggers and interpreters sometimes provided
Program loading and execution- Once a program is assembled
or compiled, it must be loaded into memory to be executed. The
system may provide Absolute loaders, relocatable loaders,
linkage editors, and overlay-loaders, debugging systems for
higher-level and machine language
Communications - Provide the mechanism for creating virtual
connections among processes, users, and computer systems
Allow users to send messages to one another’s screens,
browse web pages, send electronic-mail messages, log in
remotely, transfer files from one machine to another
Operating System Concepts – 9th Edition 2.27 Silberschatz, Galvin and Gagne ©2013
System Programs (Cont.)
Background Services
Launch at boot time
Some for system startup, then terminate
Some from system boot to shutdown
Provide facilities like disk checking, process scheduling, error
logging, printing
Run in user context not kernel context
Known as services, subsystems, daemons
Operating System Concepts – 9th Edition 2.28 Silberschatz, Galvin and Gagne ©2013
System Programs (Cont.)
Application programs
Don’t pertain to system
Run by users
Not typically considered part of OS
Launched by command line, mouse click, finger poke
Operating System Concepts – 9th Edition 2.29 Silberschatz, Galvin and Gagne ©2013
2.6 Operating System Design and Implementation
Operating System Concepts – 9th Edition 2.30 Silberschatz, Galvin and Gagne ©2013
Operating System Design and Implementation (Cont.)
Operating System Concepts – 9th Edition 2.31 Silberschatz, Galvin and Gagne ©2013
Operating System Design and Implementation (Cont.)
2.6.3.Implementation
Once an operating system is designed, it must be implemented.
Because operating systems are collections of many programs, written
by many people over a long period of time
operating systems written :
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
The disadvantages of implementing an operating system in a higher-
level language are reduced speed.
Operating System Concepts – 9th Edition 2.32 Silberschatz, Galvin and Gagne ©2013
2.7 Operating System Structure
A system as large and complex as a modern operating system
must be engineered carefully if it is to function properly and be
modified easily.
A common approach is to partition the task into small
components, or modules, rather than have one monolithic
system.
How these components are interconnected and melded
into a kernel?
Operating System Concepts – 9th Edition 2.33 Silberschatz, Galvin and Gagne ©2013
2.7.1 Simple Structure -- MS-DOS
Operating System Concepts – 9th Edition 2.34 Silberschatz, Galvin and Gagne ©2013
2.7.2 Layered Approach
Operating System Concepts – 9th Edition 2.35 Silberschatz, Galvin and Gagne ©2013
2.7.2 Layered Approach
Operating System Concepts – 9th Edition 2.36 Silberschatz, Galvin and Gagne ©2013
2.7.3 Microkernel System Structure
This method structures the operating system by removing all
nonessential components from the kernel and implementing
them as system and user-level programs.
The result is a smaller kernel. There is little consensus
regarding which services should remain in the kernel and
which should be implemented in user space.
The main function of the microkernel is to provide
communication between the client program and the various
services that are also running in user space.
Communication is provided through message passing
Mach example of microkernel
Operating System Concepts – 9th Edition 2.37 Silberschatz, Galvin and Gagne ©2013
Microkernel System Structure
messages messages
microkernel
hardware
Operating System Concepts – 9th Edition 2.38 Silberschatz, Galvin and Gagne ©2013
2.7.4 Modules
Perhaps the best current methodology for operating-system
design involves using loadable kernel modules.
Many modern operating systems implement loadable kernel
modules
Overall, similar to layers but with more flexible
kernel has a set of core components and links in additional
services via modules, either at boot time or during run time.
The idea of the design is for the kernel to provide core services
while other services are implemented dynamically, as the kernel
is running.
Operating System Concepts – 9th Edition 2.39 Silberschatz, Galvin and Gagne ©2013
Solaris Modular Approach
Operating System Concepts – 9th Edition 2.40 Silberschatz, Galvin and Gagne ©2013
2.7.5 Hybrid Systems
Most modern operating systems are actually not one pure model
In practice, very few operating systems adopt a single, strictly
defined structure. Instead, they combine different structures,
resulting in hybrid systems that address performance, security,
and usability issues.
Operating System Concepts – 9th Edition 2.41 Silberschatz, Galvin and Gagne ©2013
2.8 Operating-System Debugging
Operating System Concepts – 9th Edition 2.42 Silberschatz, Galvin and Gagne ©2013
Performance Tuning
2. performance tuning
performance tuning seeks to
improve performance by
removing processing
bottlenecks.
To identify bottlenecks, we
must be able to monitor
system performance
OS must provide means of
computing and displaying
measures of system behavior
For example, “top” program or
Windows Task Manager
Operating System Concepts – 9th Edition 2.43 Silberschatz, Galvin and Gagne ©2013
DTrace
3.DTrace
DTrace tool allows live
instrumentation on
production systems
DTrace is a facility that
dynamically adds probes to
a running system, both in
user processes and in the
kernel. These probes can
be queried via the
programming language to
determine an astonishing
amount about the kernel,
the system state, and
process activities.
Operating System Concepts – 9th Edition 2.44 Silberschatz, Galvin and Gagne ©2013
Dtrace (Cont.)
Operating System Concepts – 9th Edition 2.45 Silberschatz, Galvin and Gagne ©2013
9.Operating System Generation
Operating System Concepts – 9th Edition 2.46 Silberschatz, Galvin and Gagne ©2013
10.System Boot
Operating System Concepts – 9th Edition 2.47 Silberschatz, Galvin and Gagne ©2013
End of Chapter 2
Operating System Concepts – 9th Edition Silberschatz, Galvin and Gagne ©2013