Operating
Systems:
Internals Week-2
and Design
Principles Operating System
Overview
Operating System
A program that controls the execution of application
programs
An interface between applications and hardware
Main objectives of an OS:
• convenience
• efficiency
• ability to evolve
Operating System Services
Program development
Program execution
Access I/O devices
Controlled access to files
System access
Error detection and response
Accounting
Key Interfaces
Instruction set architecture (ISA)
Application binary interface (ABI)
Application programming interface (API)
The Role of an OS
A computeris a set of resources for the
movement, storage, and processing of
data
TheOS is responsible for managing these
resources
Operating System
as Software
Functions
in the same way as ordinary
computer software
Program, or suite of programs, executed by
the processor
Frequentlyrelinquishes control and must
depend on the processor to allow it to regain
control
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
Computers ran from a console run short or long,
with display lights, toggle resulting in wasted
switches, some form of input computer time
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 Point of View
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 Point of View
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
Desirable Hardware
Features
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 user • monitor executes in kernel
mode mode
• certain areas of memory are • privileged instructions may be
protected from user access executed
• certain instructions may not be • protected areas of memory
executed may be accessed
Uniprogramming
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
Multiprogramming
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
Multiprogramming
also known as multitasking
memory is expanded to hold three, four, or more programs and
switch among all of them
Time-Sharing Systems
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
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
Causes of Errors
Improper Nondeterminate program
synchronization operation
a program must wait until the program execution is interleaved by
data are available in a buffer the processor when memory is
shared
improper design of the
the order in which programs are
signaling mechanism can result
scheduled may affect their outcome
in loss or duplication
Deadlocks
Failed mutual exclusion
it is possible for two or more
more than one user or program
programs to be hung up
attempts to make use of a shared
waiting for each other
resource at the same time
only one routine at a time
may depend on the chance
allowed to perform an update timing of resource allocation
against the file and release
Components of
a Process
A process contains Theexecution context is
three components: essential:
an executable program it is the internal data by which
the OS is able to supervise and
the associated data
control the process
needed by the program
(variables, work space,
includes the contents of the
buffers, etc.) various process registers
the execution context (or
includes information such as
the priority of the process and
“process state”) of the
whether the process is waiting
program
for the completion of a
particular I/O 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
Memory Management
TheOS has five principal storage management
responsibilities:
automatic support of
process protection and long-term
allocation and modular
isolation access control storage
management programming
Virtual Memory
A facilitythat 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
Paging
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
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
• distributed operating systems
• object-oriented design
Multithreading
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
End