Operating Systems Dr. Barnawi

Download Report

Transcript Operating Systems Dr. Barnawi

Chapter 7
Operating
Systems
Dr. Barnawi
©Brooks/Cole, 2003
Figure 7-1
Computer System
Control access to
hardware by user
Use computer hardware
to resolve problems
©Brooks/Cole, 2003
7.1
O .S. DEFINITION
©Brooks/Cole, 2003
Definition of Operating System
• An operating system is an interface between the
hardware and programs or humans
• An operating system is a program that facilitates the
execution of other programs.
• An operating system is a general manager
supervising the activity of computer’s components.
Operating System design goals
• Efficient use of hardware.
• Easy to use resources
©Brooks/Cole, 2003
7.2
O.S. EVOLUTION
Dr. Barnawi
©Brooks/Cole, 2003
1. Batch Systems
• Each program to be executed is called a job.
• A programmer sends a job request along with
punched cards for the program and the data.
• Programmer had no interaction with the system.
• If the program was successful, the result was sent to
the programmer, if not a printout of error was sent.
• Operating systems only ensured that all of the
resources were transferred from one job to the next
©Brooks/Cole, 2003
2. Time Sharing Systems
• Multiprogramming was introduced to hold several
jobs in memory. Multiprogramming system only
assign resources to a job when it is available.
• Multiprogramming brought the idea of time
sharing where resources are shared between
different jobs.
• Multiprogramming requires a more complex OS.
• The OS has to do scheduling and decide which
program should use the resources and when.
Dr. Barnawi
©Brooks/Cole, 2003
3. Personal System
• Introduced for personal computers.
• Examples Disk Operating System (DOS)
©Brooks/Cole, 2003
4. Parallel System
• The need for more speed and effecincy has led
to the design of parallel systems; multiple CPU
in the same machine.
• Each CPU can be used to serve one program
which means that many task can be
accomplished in parallel.
• These OS are more complex than the ones with
single CPU.
©Brooks/Cole, 2003
5. Distributed System
• Networking has created a new operating
systems.
• In these system, jobs that was previously done
in one computer can be shared between
computers that are physically separated.
• In these OS, resources can be distributed.
Dr. Barnawi
©Brooks/Cole, 2003
7.3
COMPONENTS
©Brooks/Cole, 2003
Figure 7-2
Components of an operating system
©Brooks/Cole, 2003
Memory Manager
• Memory allocation must be managed to prevent
the “running out of memory ” syndrome.
• Operating systems can be divided into two broad
categories of memory management:
1. Monoprogramming
2. Multiprogramming.
©Brooks/Cole, 2003
Figure 7-3
Monoprogramming
• Not used anymore.
• Most of the memory is
dedicated to one single
program with only a small
part used to hold the
operating system.
• When a program finishes
running, it is replaced by
another program
Dr. Barnawi
©Brooks/Cole, 2003
Problems with monoprogramming
• The program cant run if the size of the
program is greater than the size of the
memory.
• When the program runs, no other program
can be executed.
©Brooks/Cole, 2003
Figure 7-4
Multiprogramming
• More than one
program are in the
memory and can be
executed concurrently.
• CPU switches between
the programs
©Brooks/Cole, 2003
Figure 7-5
Categories of multiprogramming
Programs can swap
between memory and disk
during execution
Programs stay in memory
during execution
Dr. Barnawi
©Brooks/Cole, 2003
Figure 7-6
Partitioning
Memory is divided
into sections. Each
holds a program
• CPU switches between programs. It starts with one program
and execute some instructions until either encounters I/O
operation or time for program run out. The CPU will save the
address of last instruction and move to the next program.
• CPU will get back to the first program after all programs are
served
©Brooks/Cole, 2003
Partitioning (Issues)
• Memory manager determines the partition size
 If partition sizes are small, programs cannot be
loaded in the memory.
 If partition sizes are large, there might be some
holes (unused locations) in the memory.
• When there are many holes, memory manager
removes the holes and create new partitions, this
would create extra overhead on the system.
Dr. Barnawi
©Brooks/Cole, 2003
Figure 7-7
Paging
Program is
divided into pages
Memory is divided
into equal sized
sections (frames)
• The size of the page and frame are the same and
equal to the size of the block used to retrieve data
from Disk.
• The page is loaded to the memory.
• The program doesn’t have to be contiguous
©Brooks/Cole, 2003
Paging (issues)
• Advantage of paging that it doesn’t need OS to
partition the memory as the size of programs
changes.
• Paging improves efficiency but the whole
program needs to be in memory before being
executed
©Brooks/Cole, 2003
Demand Paging
• Paging require the entire program to be in
memory. However demand paging, pages can
be loaded one by one, executed and then
replaced by new pages.
• Memory can hold one page from multiple
programs at the same time.
©Brooks/Cole, 2003
Demand Segmentation
• A program is usually made of a main program
and subprograms.
• In Demand Segmentation, the program is
divided into segments (modules) that match
the programmer’s view.
• Modules are loaded into the memory, executed
and replaced by another module from the same
or different program.
©Brooks/Cole, 2003
Demand Paging and segmentation
• A segment (module) may be too large to fit
any space in memory.
• In this case, module is divided into pages and
each page is loaded into memory and executed
one by one.
©Brooks/Cole, 2003
Figure 7-8
Virtual memory (swapping)- Example
Page (1 MB)
Program #1
Frame (1 MB)
#2
#3
24 MB
6 programs
each 4 MB
6 MB
#4
#5
#6
At one time, 1 MB of each
program is in the memory and 3
MB are in the Disk.
Dr. Barnawi
©Brooks/Cole, 2003
Process Manager
Operating system uses three terms;
• Program; A non active set of instruction that
stored in the disk.
• Job; is a program that is picked by the CPU for
execution.
• Process; is a program in execution.
©Brooks/Cole, 2003
Figure 7-9
State diagram with the boundaries
between a program, a job, and a process
©Brooks/Cole, 2003
Figure 7-10
Job scheduler
• Job scheduler is responsible for creating a
process from job and terminating a process.
©Brooks/Cole, 2003
Figure 7-11
Process scheduler
• Process scheduler moves a process from one
state to another.
Dr. Barnawi
©Brooks/Cole, 2003
Queuing
• There are many jobs and processes and process
competing with each other for computer resources.
• To handle multiple processes and jobs, the process
manager uses queues.
• Job control block stores information about jobs.
• Process control block stores information about
processes.
©Brooks/Cole, 2003
Figure 7-12
Queues for process management
• Process manager has different priority polices for
selecting the next job or process; FIFO, short first…
©Brooks/Cole, 2003
Process Synchronization
• The whole idea of process management is to
synchronize different processes with different
resources.
• Whenever resources are shared, two different
situations are created:
– Deadlock
– Starvation
Dr. Barnawi
©Brooks/Cole, 2003
Figure 7-13
Deadlock
©Brooks/Cole, 2003
Figure 7-14
Deadlock
• Deadlock occurs if all of the following conditions
are met:
1. Mutual Exclusion; only one process can hold
resources at a time.
2. Resource holding; process holds the resource until
other resource is released.
3. No pre-emption; the O. S. cant temporarily reallocate
resources.
4. Circular waiting; all processes and resources form a
loop.
©Brooks/Cole, 2003
Figure 7-15.a
Starvation
Starvation happens when OS puts too many restriction on resources
©Brooks/Cole, 2003
Figure 7-15.b
Starvation
Dr. Barnawi
©Brooks/Cole, 2003
Figure 7-15.c
Starvation
Dr. Barnawi
©Brooks/Cole, 2003
Figure 7-16
Dining philosophers-Dijkstra
©Brooks/Cole, 2003
Device Manager
accessing I/O devices
The device manager;
• Monitors every input/output device constantly
to assure it is functioning properly.
• Maintains a queue of each I/O devices or one
or more queues for similar I/O devices.
• Controls the different polices for accessing I/O
devices.
©Brooks/Cole, 2003
File Manager
accessing the files
The file manager
• Controls access file; access is permitted only to
those allowed, and the type of access can vary.
• Supervises the creation, deletion… of files
• Controls, naming.
• Manages where, how… files are stored.
• Responsible for archiving and backups.
©Brooks/Cole, 2003
User Interface
• User interface accepts requests from users and
interpret them to the rest of the O.S.
• User interface in Windows series is a
Graphical User Interface (GUI)
Dr. Barnawi
©Brooks/Cole, 2003
7.4
POPULAR
OPERATING
SYSTEMS
©Brooks/Cole, 2003