System Software & Operating Systems Organization
System Software & Operating Systems Organization
System Software & Operating Systems Organization
Systems Organization
CT213 Computing Systems
Organization
Contents
System Software & OS
OS organization
OS design and implementation
Implementation considerations
Processor modes
Kernel
Requesting services from OS (command shell, system
calls, messages)
Processes
User view
Computers and software
Application software is designed to solve a specific
problem
System software provides a general programming
environment
Operating system is a subset of the system software
Provide functions used by the application software
Provides the mechanisms for application software to
share the hardware in an orderly fashion
Sharing increases the overall performance by allowing different
application software to use different parts of the computer at the
same time, decreasing the time to execute a collection of
programs and increase overall system performance
System Software
Runtime system for a programming language
C libraries runtime
Standard input/output (I/O) library procedures to perform buffered input/output on
a stream of data
The math library functions to perform various mathematical functions
Graphics libraries functions to render images on a bitmapped display
Window system software that provides a virtual terminal to an
application program
Database management system can be used to store information on
computer's permanent storage devices (such as disks); it provides
abstract data types (called schema);
Operating system interacts directly with the hardware to provide an
interface to other system software and with application software
whenever it wants to use systems resources
It is application domain independent
Provides resource abstraction
Provides resources sharing (through strict resource management policies)
Resource abstraction
It is done by providing an abstract model of the operation of the
hardware components
Abstraction generalizes the hardware behavior but restricts the
flexibility
With abstraction, certain operations became easy to perform, other
may become impossible (such as specific hardware control)
Different hardware components that an program may access are
referred to as resources. Any particular resource, such as a HDD has
a generic interface that defines how the programmer can make the
resource perform a desired operation.
An abstraction can be made to be much simpler than the actual
resource interface
Similar resources can be abstracted to a common abstract resource
interface (i.e. system software may abstract floppy disks, hard-disks
and CD-ROMs into a single abstract disk interface)
Resource sharing
Abstract and physical resources may be shared among a set
of concurrently executing programs:
Space multiplexing sharing
resource can be divided in two or more distinct units of the resource that can
be used independently
Different executing programs, or processes can be allocated exclusive
control of different units of a resource at the same time; memory and HDD
are examples of space multiplexed resources
Time multiplexing sharing
The resource is not spatially divisible;
A process is allocated exclusive control of the entire resource for a short
period of time
After a time has elapsed, the resource is de-allocated from the process and
allocated to another
It is used with the processor resource, being switched among processes
holding other resources such as memory space and network access
System software and the OS
Application Software
Application Programming Interface
Other System Software
Operating System Interface
Operating System
Software - Hardware Interface
Hardware
R
e
s
o
u
r
c
e
A
b
s
t
r
a
c
t
i
o
n
R
e
s
o
u
r
c
e
S
h
a
r
i
n
g
Operating systems evolution
Computers with no operating system
Programming in machine language
Lack of I/O devices
OS rudiments
Programming done in assembly
Some basic I/O devices
Some I/O control modules, assembler, debugger, loader, linker
Batch processing systems service a collection of jobs,
called a batch, from a queue
Job predefined sequence of commands, programs and data
combined into a single unit
Job Control Language and monitor batch (interpreter for JCL)
The user doesnt interact with programs while they operate
Operating systems evolution
Operating systems using multiprogramming the technique
of loading multiple programs into space multiplexed
memory while time-multiplexing the processor
Timesharing systems
Real time operating systems
Distributed operating systems
Multiprogramming systems common features
Multitasking multiple processes sharing machine resources
Hardware support for memory protection and I/O devices
Multi-user and multi-access support (through time sharing
mechanisms)
Optional support for real time operations (based on efficient usage
of multitasking support)
Interactive user interface
Operating systems classification criteria
Processor scheduling
Memory management
I/O management
File management
Batch systems
Processor scheduling : FIFO
Memory management:
Memory is divided in two parts:
system memory and program
memory (for programs)
I/O management no special
problems, since a job has exclusive
access to the I/O devices
File management present
Job Queue /
Batch File
Memory
Allocation
Primary
Memory
Processor
Sheduler
Processor
Submit Job /
Batch File
Job / Batch File
Complete
Time sharing systems
Support for
multiprogramming and
multi-user
Processor scheduling
time slice (round robin)
Memory management:
Protection and inter-process
communication support
I/O management
Support for protection and
sharing between users
Is not critical in time
File management
Protection support and sharing
support between users
Time sharing OS
VM VM VM
Terminal Multiplexer
...
...
Servicing the interrupts
from terminals is critical
in time
Real time operating systems
Used whenever a large number of external events have to be treated in a short or
limited interval of time
Support for multiprogramming/multi-tasking
Main goal
Minimization of the response time to service the external events
Processor scheduling:
Priority based preemptive
Memory management:
Concurrent processes are loaded into the memory
Support for protection and inter-process communication
I/O management:
Critical in time
Processes dealing with I/O are directly connected to the interrupt vectors (or handling the
interrupt requests)
File management:
It may be missing
If exists, it should comply with requirements for timesharing systems + it should satisfy
the requirements for real time systems
Distributed operating systems
Multiprogramming induces a strong centralization
tendency
Distributed OS aims decentralization
Based on computer network technologies, with
afferent communication and synchronization
protocols
Client-server application architecture
Security and protection are the primary concerns
Modern operating systems
Batch Operating
Systems
Timesharing
Operating Systems
Distributed Operating
Systems
Real Time
Operating Systems
Modern Operating
Systems
C
o
n
s
t
a
n
t
l
o
a
d
o
f
t
h
e
p
r
o
c
e
s
s
o
r
,
o
n
l
o
w
p
r
i
o
r
i
t
y
t
a
s
k
s
I
n
t
e
r
a
c
t
i
v
e
p
r
o
c
e
s
s
e
s
a
r
e
t
r
e
a
t
e
d
t
i
m
e
s
h
a
r
i
n
g
C
r
i
t
i
c
a
l
p
r
o
c
e
s
s
e
s
(
i
.
e
.
n
e
t
w
o
r
k
d
r
i
v
e
r
s
)
a
r
e
t
r
e
a
t
e
d
a
c
c
o
r
d
i
n
g
t
o
r
e
a
l
t
i
m
e
c
o
n
s
t
r
a
i
n
t
s
C
l
i
e
n
t
-
S
e
r
v
e
r
m
o
d
e
l
p
r
o
t
o
c
o
l
s
OS organization
Process and
Resource
Manager
File Manager
Memory
Manager
Device Manager
Computer Hardware
Processor(s) Main Memory Devices
Operating
System
Process and resource manager creates the
process definition and execution environment
on top of the hardware processor
It uses the abstractions provided by the other
managers
Handles resource allocation
Memory manager is typically distinct from
the mechanism that manages other resources
It is classically a separate part of the operating
system
Beside other functions, it is in charge with the
implementation of the virtual memory
The file manager is the part of the OS that
abstracts device I/O operations into a
relatively simple operation
The device manger handles the details of
reading and writing the physical devices (e.g.
storage devices) and it is implemented within
device driver
OS design functional requirements
Processes:
Creation, termination, control, exception handling
Protection
Synchronization and communication
Resources allocation/de-allocation
Memory management:
Allocation/de-allocation
Protection and sharing
I/O devices
Allocation/de-allocation
Protection and sharing
Physical resource abstraction
File System management:
Space allocation/de-allocation
Protection, sharing, security
Physical resource abstraction
OS implementations
Monolithic operating system
try to achieve the functional requirements by executing
all the code in the same address space to increase the
performance of the system
Too complex to manage
Hierarchical operating system
run most of their services in user space, aiming to
improve maintainability and modularity of the codebase
Suitable for OOP, the levels are very well defined
Implementation considerations
Multi-programming
Protection
Processor modes
Kernels
Method of requesting a system service
Multiprogramming (1)
Technique that allows the system to present the illusion that
multiple programs are running on the computer
simultaneously
Protection between programs is very important
Many multiprogrammed computers are multiuser
Allow multiple persons to be logged on at a time
Beside protection, data privacy is also important
Multiprogramming is achieved by switching rapidly
between programs.
Each program is allowed to execute for a fixed amount of time
timeslice
Multiprogramming (2)
When a program timeslice ends, the OS stops it, removes it
and gives another program control over processor this is a
context switch
To do a context switch the OS copies the content of current
program register file into memory, restores the contents of the next
programs register file into the processor and starts executing the
next program.
From the program point of view, they cant tell that a context
switch has been performed
Program 1 Program 1 Program 2 Program 3 Program 2 Program 3
Program
executing on
processor
Time
Slice
Time
...
Protection (1)
The result of any program running on a
muliprogrammed computer must be the same as if
the program was the only program running on the
computer
Programs must not be able to aces other programs
data and must be confident that their data will not be
modified by other programs.
Programs must not interfere with other programs
use of I/O devices
Protection (2)
Protection is achieved by having the operating system to
have full control over the resources of the system
(processor, memory and I/O devices)
Virtual memory is one of the techniques used to achieve
protection between programs
Each program operates as if it were the only program on the
computer, occupying a full set of the address space in its virtual
space. The OS is translating memory addresses that the program
references into physical addresses used by the memory system.
As long as two programs addresses are not translated to same
address space, programs can be written as they were the only ones
running on the machine
Privileged Mode
To ensure that the operating system is the only one that can
control the physical resources it executes in privileged mode
User programs execute in user mode
When user mode programs want to execute something that
requires privileged rights, it sends a request to the OS,
known as system call, that asks the OS to do the operation
for them
OS is also responsible for low level UI
Keys are pressed, the OS is responsible to determine which
program should receive the input
When a program wants to display some output, the user program
executes some system call that displays the data
Processor Modes
Are operating modes for the CPU that place restrictions on
the operations that can be performed by the currently
running process
Hardware supported CPU modes help the operating system
to enforce rules that would prevent viruses, spyware, and/or
similar malware to run
Only very specific and limited "kernel" code would run
unrestricted.
Any other software (including portions of the operating system)
would run restricted and would have to ask the "kernel" for
permission to modify anything that could compromise the system.
Multiple mode levels could be designed.
Processor modes
Mode bit to define execution capability of program on a
processor
Supervisor mode
The processor can execute any instruction
Instructions that can be executed only in supervisor mode are called
supervisor, privileged or protected instructions (e.g. I/O instructions)
User mode
The processor can execute a subset of the instruction set
Some microprocessors do not make a difference between
protected and user mode (i.e. 8086)
The mode bit may be logically extended to define areas of
memory to be used when the processor is in supervisor
mode versus when it is in user mode
Supervisor and user memory
In general, the mode bit extends the operating systems protection
rights; usually the mode bit is set by the interrupts, making the
processor to jump to a location in the system space, to execute a
system routine; it is similar to a hardware interrupt; once the processor
finishes the execution of the system call, it resets the mode bit and
returns.
User
Space
Supervisor
Space
User
Process
Supervisor
Process
Memory
If mode bit is set to supervisor
mode, then the execution process
has access on both memory spaces
If user mode is set, then the
executing process has access only
to the user space
Kernels
The part of the operating system that executes in supervisor
mode is called kernel or nucleus
Operates as trusted software
Implements protection mechanisms that could not be changed
through the actions of un-trusted software executing in user mode
Extensions of the OS can operate in user mode
Provides the lowest level abstraction layer for resources (memory,
processor(s) and IO devices)
Fundamental design decision if a given function of the
operating system is to be incorporated in the kernel or not
Protection issues
Performances issues
Method of requesting a system service
Through command interface
By calling a specific command using a command
interpreter known as shell
From user processes requesting services from OS:
By calling a system function
By sending a message to a system process
Command execution mechanism
A key pressed by the user generates a hardware interrupt
Specialized module of the OS reads the keyed character and
the stores it in a special command line buffer
There are special characters (i.e. to edit the command line, that are
not stored in the command line buffer)
End of line detected - control taken by the command
interpreter (shell):
Analysis of the command (with error or success)
If success, then the command interpreter decides if it is about an
internal or external command (for another module)
If internal command tries the execution, that can end successfully or with
error
If external
Looking for the corresponding executable file
Launching in execution with the detected parameters from
previous phase
Command execution example
Semantics of grep establish that first string
parameter (first) represents the search pattern, while
the second parameter represents a file name (where
to search)
Shell process
Process executing grep
command
first
File f3
The command line looks like:
%> grep first f3
System call
The parameters of the call are passed
according to some OS specific
convention and hardware architecture
Switch in protected (supervisor) mode
using a specific mechanism (software
interrupt, trap, special instruction of
type call supervisor), mechanism that
is different from a normal call
A special module takes over, that will
analyze the parameters and the access
rights; this module can reject the system
call
If accepted, then the corresponding
routine from the operating system is
executed and the result is returned to the
user; upon return, the user mode is
restored
call()
Software interrupt, trap,
call supervisor
User mode
Kernel mode
Target
procedure
return
Kernel mode
procedure
Messages
User process constructs a message
that describes a desired service (A)
Uses send function to pass the
message to a trusted operating
system process
The send function checks the
message, switches the processor in
protected mode and then delivers the
message to the process that
implements the target function
Meanwhile, the user waits for result
with a message receive operation.
When the kernel finishes to process
the request, it sends a message (B)
back to the user process
send (, A, )
receive (.., B, )
send / receive
receive (,A, );
send (, B, );
User mode
Kernel mode
References
Operating Systems A modern perspective, Garry
Nutt, ISBN 0-8053-1295-1