Lecture 1 - OS (Introduction Process Management)
Lecture 1 - OS (Introduction Process Management)
Course Description
This course is about the concepts, structure and mechanisms of
operating systems, which is an essential part of any computer
system. The course intend to provides the design principles and
implementation issues of modern operating systems.
Course Contents
1. Introduction (OS Overview)
2. Process management
1. Threads
2. Concurrency (Mutuatl Exclusion & Synchronization)
3. Concurrency (Deadlocks & Starvation)
3. Scheduling
4. Memory management
5. File Systems & I/O management
6. Information security/Access control
7. OS in real time and embedded systems
Mode of Delivery
2 hrs lectures & 1 hrs practical per week.
Assessment
Introduction 5
Outline
Operating System
Objectives/Functions
The Evolution of Operating Systems
Major Achievements
Developments Leading to Modern Operating
Systems
6
Introduction
2. Systems Programs
- Manages the operation of a computer itself and
application programs which can create end user
programs.
- Operating system
Controls all computer resources and provides the base
upon which the application programs can be written.
Introduction 8
Introduction
A computer is a set of
resources for the movement,
storage, and processing of
data.
Introduction 9
What is an Operating System?
A program that acts as an intermediary between
a user of a computer and the computer
hardware.
It is an extended machine
Hides the messy details which must be performed
Presents user with a virtual machine, easier to use
It is a resource manager
Each program gets time with the resource
Each program gets space on the resource
Use the computer hardware in an efficient manner.
Introduction 10
Services/Functions Provided by
the Operating System
Program development
Editors and debuggers.
Program execution
OS handles scheduling of numerous tasks
required to execute a program
Introduction 11
Services/Functions Provided by
the Operating System
Control access to files
Accessing different media but presenting a
common interface to users
Provides protection in multi-access systems
System access
Controls access to the system and its
resources
Introduction 12
Services/Functions Provided by the
Operating System
Error detection and response
Internal and external hardware errors
Software errors
Operating system cannot grant request of
application
Accounting
Collect usage statistics
Monitor performance
Introduction 13
OUTLINE
14
Evolution of Operating Systems
Introduction 15
Evolution of Operating Systems
The OS has evolved from serial to
multiprogramming systems.
Stages include
Serial Processing
Simple Batch Systems
Multiprogrammed batch systems
Time Sharing Systems
16
Evolution: Serial Processing
No operating system
Programmer interacted directly with the computer
hardware
Machines run from a console with display lights,
toggle switches, input device, and printer
Problems include:
Scheduling (used a hardcopy sign-up sheet to reserve
computer time)
Setup time (Each steps involved mounting or
dismounting tapes or setting up card decks)
17
Simple batch system
Early computers were extremely
expensive
Important to maximize processor utilization
Monitor
Software that controls the sequence of
events
Batch jobs together
Program returns control to monitor when
finished
18
Evolution of Operating Systems
20
Job Control Language
The monitor performs a scheduling function:
• A batch of jobs is queued up, and jobs are executed as
rapidly as possible, with no intervening idle time.
• The monitor improves job setup time as well.
User Mode
User program executes in user mode
Certain areas of memory protected from user access
Certain instructions may not be executed
Kernel Mode
Monitor executes in kernel mode
Privileged instructions may be executed, all memory
accessible.
22
Multiprogrammed Batch Systems
In simple batch systems, CPU is often
idle
Even with the automatic job sequencing
provided by a simple batch operating
system,
I/O devices are slow compared to processor
23
Uniprogramming
24
Multiprogramming
25
Multiprogramming
26
Example
27
Example
28
Time Sharing Systems
However, for many jobs, it is desirable to provide a
mode in which the user interacts directly with the
computer.
30
Major Areas of advancements
31
Different Architectural Approaches
(Developments Leading to Modern Operating Systems)
32
Microkernel Architecture
Most early OS are a monolithic kernel
Typically, a monolithic kernel is implemented as a single
process, with all elements sharing the same address
space.
34
Multithreading
35
Symmetric multiprocessing (SMP)
36
SMP Advantages
Performance
Allowing parallel processing
Availability
Failure of a single process does not halt the system
Incremental Growth
Additional processors can be added.
Scaling
Vendors can offer a range of products with different price
and performance characteristics based on the number of
processors configured in the system.
37
Multiprogramming and Multiprocessing
38
Distributed Systems (Networking)
Introduction 39
Object-oriented design
40
Operating System Design Goals
Introduction 41
Operating System Implementation
Introduction 42
Process Management
Roadmap
44
What is a “process”?
A program in execution
An instance of a program running on a
computer
The entity that can be assigned to and
executed on a processor
A unit of activity characterized by the
execution of a sequence of instructions,
a current state, and an associated set of
system instructions
45
Requirements of an Operating
System
Fundamental Task: Process
Management
The Operating System must
Interleave the execution of multiple
processes
Allocate resources to processes, and protect
the resources of each process from other
processes,
Enable processes to share and exchange
information,
Enable synchronization among processes.
46
Process Elements
47
Process Elements
48
Process Control Block
Contains the process
elements
Created and manage by the
operating system
Allows support for multiple
processes
49
Process Execution
Consider three
processes being
executed
All are in memory (plus
the dispatcher)
Lets ignore virtual
memory for this.
51
Two-State Process Model
52
Queuing Diagram
Etc … processes moved by the dispatcher of the OS to the CPU then back
to the queue until the task is competed
53
Five-State Process Model
In a two state model, the dispatcher would have to scan the list looking for
the process that is not blocked and that has been in the queue the longest.
To simplify that, the Not Running state can be split into two states:
• Ready (processes in the Not Running state which are ready to
execute)
• Blocked (processes in the Not Running state waiting for an I/O
operation to complete).
54
Using Two Queues
•Five state model would require an additional queue for the blocked
processes.
•But when an event occurs the dispatcher would have to cycle through the
entire queue to see which process is waiting for that event. This can cause
a huge overhead when there many
55
( 100’s or 1000’s) processes
Multiple Blocked Queues
57
One Suspend State
The simple solution is to add a single state – but this only allows processes
which are blocked to be swapped out.
58
Two Suspend States
59
Reason for Process
Suspension
Reason Comment
Swapping The OS needs to release sufficient main memory to
bring in a process that is ready to execute.
Other OS Reason OS suspects process of causing a problem.
Interactive User e.g. debugging or in connection with the use of a
Request resource.
Timing A process may be executed periodically (e.g., an
accounting or system monitoring process) and may
be suspended while waiting for the next time.
Parent Process A parent process may wish to suspend execution of
Request a descendent to examine or modify the suspended
process, or to coordinate the activity of various
descendants.
Table 3.3 Reasons for Process Suspension
60
Roadmap
61
Processes and Resources
62
Operating System Control
Structures (Control Tables)
64
Process Attributes
65
Process Identification
66
Processor State Information
67
Process Control Information
This is the information needed by the OS to control and
coordinate the various active processes.
68
Threads
Processes and Threads
70
Single Thread Approaches
MS-DOS supports a
single user process and
a single thread.
Some UNIX, support
multiple user processes
but only support one
thread per process
71
Multithreading
Java run-time
environment is a single
process with multiple
threads
Multiple processes and
threads are found in
Windows, Solaris, and
many modern versions of
UNIX
72
Relationship Between
Thread and Processes
73
Threads Analogy: The Hamburger
Restaurant
74
74
Single-Threaded Restaurant
75
75
Multithreaded Restaurant
76
76
Benefits of Threads
If there is an application or function that should be
implemented as a set of related units of execution,
it is far more efficient to do so as a collection of threads -
rather than a collection of separate processes
77
Threads
78