0% found this document useful (0 votes)
57 views48 pages

CH 2

The document discusses the various services and interfaces provided by operating systems to users and programs. It describes user interfaces like command-line, graphical user interfaces, and touchscreen interfaces. It also covers various operating system services like process execution, I/O operations, file manipulation, resource allocation, protection and more. The document contains details about different components of operating systems.

Uploaded by

Noo Opp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views48 pages

CH 2

The document discusses the various services and interfaces provided by operating systems to users and programs. It describes user interfaces like command-line, graphical user interfaces, and touchscreen interfaces. It also covers various operating system services like process execution, I/O operations, file manipulation, resource allocation, protection and more. The document contains details about different components of operating systems.

Uploaded by

Noo Opp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 48

Chapter 2: Operating-System

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.):

2. 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)

3. I/O operations - A running program may require I/O, which


may involve a file or an I/O device (such as recording to a CD or
DVD drive or blanking a display screen).

4. 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 – 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

7. Resource allocation - When multiple users or multiple jobs running


concurrently, resources must be allocated to each of them
 operating system manages Many different types of resources -
CPU cycles, main memory, file storage, I/O devices.
8. Accounting - To keep track of which users use how much and what
kinds of computer resources
 Usage statistics may be a valuable tool for researchers who
wish to reconfigure the system to improve computing

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

2.2.1 command-line interface CLI or command interpreter

CLI or command interpreter allows direct command entry


Some operating systems include the command interpreter in
the kernel. Others, such as Windows and UNIX, treat the
command interpreter as a special program
The main function of the command interpreter is to get and
execute command.
 Many of the commands given at this level manipulate
files: create, delete, list, print, copy, execute, and so on.
These commands can be implemented in two general ways:
 commands built-in.
 just names of programs : merely uses the command to
identify a file to be loaded into memory and executed.

Operating System Concepts – 9th Edition 2.8 Silberschatz, Galvin and Gagne ©2013
User and Operating-System Interface

2.2.2 Graphical User Interfaces CUI


users employ a mouse-based window and menu system
characterized by a desktop metaphor.
The user moves the mouse to position its pointer on images, or
icons, on the screen (the desktop) that represent programs,
files, directories, and system functions. Depending on the
mouse pointer’s location, clicking a button on the mouse can
invoke a program, select a file or directory—known as a
folder—or pull down a menu that contains commands.
Many systems now include both CLI and GUI interfaces
Microsoft Windows is GUI with CLI “command” shell
Apple Mac OS X is “Aqua” GUI interface with UNIX kernel
underneath and shells available
Unix and Linux have CLI with optional GUI interfaces (CDE,
KDE, GNOME)

Operating System Concepts – 9th Edition 2.9 Silberschatz, Galvin and Gagne ©2013
Touchscreen Interfaces

changes in the appearance of the


GUI along with several
enhancements in its functionality

Touchscreen devices require new


interfaces
Mouse not possible or not desired
Actions and selection based on
gestures
Virtual keyboard for text entry
Voice commands.

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

The API specifies a set of functions that are available to an


application programmer, including the parameters that are
passed to each function and the return values the
programmer can expect.

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

For most programming languages, the run-time support system (a


set of functions built into libraries included with a compiler)
provides a system call interface that serves as the link to system
calls made available by the operating system.
The system-call interface intercepts function calls in the API
and invokes the necessary system calls within the operating
system.

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

Why would an application programmer prefer programming


according to an API rather than invoking actual system calls?
An application programmer designing a program using an API
can expect her program to compile and run on any system
that supports the same API
system calls can often be more detailed and difficult to work
with than the API available to an application programmer.
strong correlation between a function in the API and its
associated system call within the kernel.

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

2.4.2 File management


create file, delete file
open, close file
read, write, reposition
get and set file attributes
2.4.3 Device management
request device, release device
read, write, reposition
get device attributes, set device attributes
logically attach or detach devices

Operating System Concepts – 9th Edition 2.20 Silberschatz, Galvin and Gagne ©2013
Types of System Calls (Cont.)

2.4.4 Information maintenance


get time or date, set time or date
get system data, set system data
get and set process, file, or device attributes
2.4.5 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 – 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

File management - Create, delete, copy, rename, print, dump, list,


and generally manipulate files and directories

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

Along with system programs, most operating systems are supplied


with programs that are useful in solving common problems or
performing common operations. Such application programs include
Web browsers, word processors and text formatters, spreadsheets,
database systems, compilers, plotting and statistical-analysis
packages, and games.

Operating System Concepts – 9th Edition 2.29 Silberschatz, Galvin and Gagne ©2013
2.6 Operating System Design and Implementation

2.6.1 Design Goals


The first problem in designing a system is to define goals and
specifications.
Start the design by defining goals and specifications
Design and Implementation of OS not “solvable”, but some
approaches have proven successful

Affected by choice of hardware, type of system

User goals and System goals


User goals – operating system should be convenient to use,
easy to learn, reliable, safe, and fast
System goals – operating system should be easy to design,
implement, and maintain, as well as flexible, reliable, error-free,
and efficient .

Operating System Concepts – 9th Edition 2.30 Silberschatz, Galvin and Gagne ©2013
Operating System Design and Implementation (Cont.)

2.6.2 Mechanisms and Policies


Important principle to separate
Policy: What will be done?
Mechanism: How to do it?
Mechanisms determine how to do something, policies decide
what will be done
For example, the timer construct (see Section 1.5.2) is a
mechanism for ensuring CPU protection, but deciding how long
the timer is to be set for a particular user is a policy decision.
The separation of policy from mechanism is a very important
principle, it allows maximum flexibility if policy decisions are to
be changed later (example – timer)
Specifying and designing an OS is highly creative task of
software engineering

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?

Various ways to structure ones


Simple structure – MS-DOS
Layered – an abstrcation
Microkernel –Mach
modules

Operating System Concepts – 9th Edition 2.33 Silberschatz, Galvin and Gagne ©2013
2.7.1 Simple Structure -- MS-DOS

Many operating systems do not


have well-defined structures.
Frequently, such systems started
as small, simple, and limited
systems and then grew beyond
their original scope.
MS-DOS is an example of
such a system.
MS-DOS – written to provide the
most functionality in the least
space
Not divided into modules
Although MS-DOS has some
structure, its interfaces and
levels of functionality are not
well separated

Operating System Concepts – 9th Edition 2.34 Silberschatz, Galvin and Gagne ©2013
2.7.2 Layered Approach

With proper hardware support,


operating systems can be
broken into pieces that are
smaller and more appropriate
than those allowed by the
original MS-DOS
The operating system can then
retain much greater control
over the computer and over the
applications that make use of
that computer.
The operating system is divided
into a number of layers (levels),
each built on top of lower
layers. The bottom layer (layer
0), is the hardware; the highest
(layer N) is the user interface.

Operating System Concepts – 9th Edition 2.35 Silberschatz, Galvin and Gagne ©2013
2.7.2 Layered Approach

A typical operating-system layer—say,


layer M—consists of data structures and a set of routines that
can be invoked by higher-level layers.
Layer M, in turn, can invoke operations on lower-level layers

The main advantage of the layered approach is simplicity of


construction and debugging.
The layers are selected so that each uses functions (operations) and
services of only lower-level layers.
This approach simplifies debugging and system verification.

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

Application File Device user


Program System Driver mode

messages messages

Interprocess memory CPU kernel


Communication managment scheduling mode

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

debugging is the activity of finding and fixing errors in a system, both


in hardware and in software.
Debugging is finding and fixing errors, or bugs
2.8.1 Failure Analysis
If a process fails, most operating systems write the error information to
a log file to alert system operators or users that the problem occurred.
The operating system can also take a core dump—a capture of the
memory of the process — and store it in a file for later analysis.
Failure of an application can generate core dump file capturing
memory of the process
A failure in the kernel is called a crash.
When a crash occurs, error information is saved to a log file, and
the memory state is saved to a crash dump.
Operating system failure can generate crash dump file containing
kernel memory

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.)

DTrace code to record


amount of time each
process with UserID 101 is
in running mode (on CPU)
in nanoseconds

Operating System Concepts – 9th Edition 2.45 Silberschatz, Galvin and Gagne ©2013
9.Operating System Generation

n Operating systems are designed to run on any of a class of


machines; the system must be configured for each specific
computer site
n SYSGEN program obtains information concerning the specific
configuration of the hardware system
l Used to build system-specific compiled kernel or system-
tuned
l Can general more efficient code than one general kernel

Operating System Concepts – 9th Edition 2.46 Silberschatz, Galvin and Gagne ©2013
10.System Boot

When power initialized on system, execution starts at a fixed


memory location
Firmware ROM used to hold initial boot code
Operating system must be made available to hardware so hardware
can start it
Small piece of code – bootstrap loader, stored in ROM or
EEPROM locates the kernel, loads it into memory, and starts it
Sometimes two-step process where boot block at fixed
location loaded by ROM code, which loads bootstrap loader
from disk
Kernel loads and system is then running

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

You might also like