Operating
Systems:
Internals Chapter 2
and Design
Principles Operating System
Overview
Seventh Edition
By William Stallings
◼ Program development
◼ Program execution
◼ Access I/O devices
◼ Controlled access to files
◼ System access
◼ Error detection and response
◼ Accounting (Usage Statistics for Resources)
Key Interfaces
◼ Instruction Set Architecture (ISA)
◼ Application Binary Interface (ABI)
◼ Application Programming Interface (API)
◼A computer is a set of resources for the
movement, storage, and processing of
data
◼ TheOS is responsible for managing these
resources
◼ Functionsin the same way as ordinary
computer software
◼ Program, or suite of programs, executed by
the processor
◼ Frequently
relinquishes control and must
depend on the processor to allow it to regain
control
Operating
System
as
Resource
Manager
Evolution of Operating
Systems
▪ A major OS will evolve over time for a
number of reasons:
Hardware upgrades
New types of hardware
New services
Fixes
Evolution of
Operating Systems
▪ Stages include:
Time
Sharing
Multiprogrammed Systems
Batch Systems
Simple Batch
Systems
Serial
Processing
Serial Processing
Earliest Computers: Problems:
◼ Scheduling:
◼ No operating system
◼ most installations used a
◼ programmers interacted
hardcopy sign-up sheet to
directly with the computer
reserve computer time
hardware
◼ time allocations could run
◼ Computers ran from a console short or long, resulting in
with display lights, toggle switches, wasted computer time
some form of input device, and a
printer ◼ Setup time
◼ Users have access to the computer ◼ a considerable amount of time
in “series” was spent just on setting up the
program to run
Simple Batch Systems
◼ Early computers were very expensive
◼ important to maximize processor utilization
◼ Monitor
◼ user no longer has direct access to processor
◼ job is submitted to computer operator who batches them
together and places them on an input device
◼ program branches back to the monitor when finished
◼ Monitor controls the sequence of
events
◼ Resident Monitor is software always in
memory
◼ Monitor reads in job and gives
control
◼ Job returns control to monitor
◼ Processor executes instruction from the memory containing
the monitor
◼ Executes the instructions in the user program until it
encounters an ending or error condition
◼ “control is passed to a job” means processor is fetching and
executing instructions in a user program
◼ “control is returned to the monitor” means that the processor is
fetching and executing instructions from the monitor program
Job Control Language
(JCL)
Special type of programming
language used to provide
instructions to the monitor
what compiler to use
what data to use
Memory protection for monitor
• while the user program is executing, it must not alter the memory area
containing the monitor
Timer
• prevents a job from monopolizing the system
Privileged instructions
• can only be executed by the monitor
Interrupts
• gives OS more flexibility in controlling user programs
Modes of Operation
User Mode Kernel Mode
• user program executes in • monitor executes in kernel
user mode mode
• certain areas of memory are • privileged instructions may
protected from user access be executed
• certain instructions may not • protected areas of memory
be executed may be accessed
Simple Batch System
Overhead
◼ Processor time alternates between execution of user programs
and execution of the monitor
◼ Sacrifices:
◼ some main memory is now given over to the monitor
◼ some processor time is consumed by the monitor
◼ Despite overhead, the simple batch system improves
utilization of the computer
Multiprogrammed
Batch Systems
◼ Processor is
often idle
◼ even with
automatic job
sequencing
◼ I/O devices are
slow compared
to processor
◼ The processor spends a certain amount of time executing,
until it reaches an I/O instruction; it must then wait until that
I/O instruction concludes before proceeding
◼ There must be enough memory to hold the OS (resident monitor) and one user
program
◼ When one job needs to wait for I/O, the processor can switch to the other job,
which is likely not waiting for I/O
◼ Multiprogramming
◼ also known as multitasking
◼ memory is expanded to hold three, four, or more programs
and switch among all of them
Multiprogramming Example
◼ Can be used to handle multiple interactive jobs
◼ Processor time is shared among multiple users
◼ Multipleusers simultaneously access the system
through terminals, with the OS interleaving the
execution of each user program in a short burst or
quantum of computation
Table 2.3 Batch Multiprogramming versus Time Sharing
Compatible Time-Sharing
Systems
CTSS Time Slicing
◼ One of the first time-sharing ◼ System clock generates interrupts at a
operating systems rate of approximately one every 0.2
seconds
◼ Developed at MIT by a group ◼ At each interrupt OS regained control
known as Project MAC and could assign processor to another
user
◼ Ran on a computer with 32,000
36-bit words of main memory, with ◼ At regular time intervals the current user
would be preempted and another user
the resident monitor consuming loaded in
5000 of that
◼ Old user programs and data were
◼ To simplify both the monitor and written out to disk
memory management a program
was always loaded to start at the ◼ Old user program code and data were
restored in main memory when that
location of the 5000th word program was next given a turn
◼ Fundamental to the structure of operating systems
A process can be defined as:
a program in execution
an instance of a running program
the entity that can be assigned to, and executed on, a processor
a unit of activity characterized by a single sequential thread of execution, a
current state, and an associated set of system resources
Development of the
Process
▪ Three major lines of computer system development
created problems in timing and synchronization that
contributed to the development:
multiprogramming batch operation
• processor is switched among the various programs residing in main
memory
time sharing
• be responsive to the individual user but be able to support many users
simultaneously
real-time transaction systems
• a number of users are entering queries or updates against a database
◼ A process contains ◼ The execution context is
three components: essential:
◼ it is the internal data by which the
◼ an executable program
OS is able to supervise and control
◼ the associated data the process
needed by the program ◼ includes the contents of the various
(variables, work space, process registers
buffers, etc.) ◼ includes information such as the
priority of the process and whether
◼ the execution context the process is waiting for the
(or “process state”) of completion of a particular I/O
the program event
Process
Management
▪ The entire state of the
process at any instant is
contained in its context
▪ New features can be
designed and incorporated
into the OS by expanding
the context to include any
new information needed to
support the feature
◼ TheOS has five principal storage management
responsibilities:
automatic
support of protection
process allocation long-term
modular and access
isolation and storage
programming control
management
◼A facility that allows programs to address
memory from a logical point of view, without
regard to the amount of main memory physically
available
◼ Conceived to meet the requirement of having
multiple user jobs reside in main memory
concurrently
◼ Allows processes to be comprised of a number of
fixed-size blocks, called pages
◼ Program references a word by means of a virtual
address
◼ consists of a page number and an offset within the page
◼ each page may be located anywhere in main memory
◼ Provides for a dynamic mapping between the virtual
address used in the program and a real (or physical)
address in main memory
Virtual
Memory
◼ The nature of the threat
that concerns an
organization will vary Main
greatly depending on the issues availability
circumstances
◼ The problem involves
authenticity confidentiality
controlling access to
computer systems and the data
information stored in integrity
them
Scheduling and
Resource Management
◼ Keyresponsibility of an OS is managing
resources
◼ Resource allocation policies must consider:
fairness
efficiency
differential
responsiveness
Key Elements of an
Operating System
Different Architectural
Approaches
◼ Demands on operating systems require new
ways of organizing the OS
Different approaches and design elements have been tried:
• Microkernel architecture
• Multithreading
• Symmetric multiprocessing
Microkernel Architecture
◼ Assigns only a few essential functions to the
kernel:
interprocess
address basic
communication
spaces scheduling
(IPC)
◼ The approach:
is well suited to a
simplifies provides
distributed
implementation flexibility
environment
◼ Technique in which a process, executing an application, is
divided into threads that can run concurrently
Thread
• dispatchable unit of work
• includes a processor context and its own data area to enable subroutine
branching
• executes sequentially and is interruptible
Process
• a collection of one or more threads and associated system resources
• programmer has greater control over the modularity of the application and the
timing of application related events
Symmetric
Multiprocessing (SMP)
◼ Term that refers to a computer hardware architecture and also to the
OS behavior that exploits that architecture
◼ Several processes can run in parallel
◼ Multiple processors are transparent to the user
◼ these processors share same main memory and I/O facilities
◼ all processors can perform the same functions
◼ The OS takes care of scheduling of threads or processes on
individual processors and of synchronization among processors
SMP Advantages
more than one process can be
Performance running simultaneously, each on a
different processor
failure of a single process does not
Availability halt the system
Incremental performance of a system can be
enhanced by adding an
Growth additional processor
vendors can offer a range of products
Scaling based on the number of processors
configured in the system