87
OPERATING SYSTEMS Lecture 3: we will explore the role of the operating system in a computer Networks and Communication Department 1

OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

  • Upload
    lemien

  • View
    215

  • Download
    0

Embed Size (px)

Citation preview

Page 1: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

OPERATING SYSTEMS

Lecture 3: we will explore the role of the operating system in a computer

Networks and

Communication

Department

1

Page 2: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Outline

Networks and Communication Department

Define the operating system

Discuss the process of bootstrapping

Operating system evolution

Identify the components of an operating system

Memory manager

Process manager

Device manager

File manager

Page 3: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Computer System

Networks and Communication Department

Page 4: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

7.4 Figure 7.1 A computer system

Page 5: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Computer System

Networks and Communication Department

A computer is a system composed of 2 major

components:

hardware and software.

Computer hardware: is the physical equipment.

Software is the collection of programs that

allows the hardware to do its job.

Page 6: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Computer System

Networks and Communication Department

Computer software is divided into 2 broad

categories:

The operating system and application

programs

Application programs: use the computer

hardware to solve users’ problems.

The operating system: controls the access to

hardware by users.

Page 7: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Operating System Introduction

Networks and Communication Department

Page 8: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Operating System

Networks and Communication Department

An operating system: is an interface between the

hardware of a computer and the user (programs or

humans) that facilitates the execution of other

programs and the access to hardware and software

resources

Two major design goals of an operating system are:

Efficient use of hardware.

Ease of use of resources.

Page 9: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Bootstrap Process

Networks and Communication Department

Page 10: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Bootstrap Process

Networks and Communication Department

The operating system is responsible for loading

other programs into memory for execution.

However, the operating system itself is a program

that needs to be loaded into the memory and be

run. How is this dilemma solved?

Page 11: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

What is the Bootstrap process?

Networks and Communication Department

So a very small section of memory is made of ROM

and holds a small program called the bootstrap

program (Firmware).

The program is only responsible for loading the

operating system itself, or that part of it required to

start up the computer, into RAM memory.

Page 12: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Bootstrap Process

Networks and Communication Department

1. When the computer is turned on, the CPU counter

(a type of the CPU registers) is set to the first

instruction of this bootstrap program and

executes the instructions in this program.

2. When loading is done, the program counter is set

to the first instruction of the operating system in

RAM.

Page 13: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

7.13 Figure 7.2 The bootstrap process

Page 14: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Operating System Evolution

Networks and Communication Department

Operating systems have gone through a long

history of evolution

Page 15: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Operating System Evolution

Networks and Communication Department

Batch operating systems were designed in the

1950s to control mainframe computers.

At that time, computers were large machines that

used :

punched cards for input

line printers for output

tape drives for secondary storage media

Page 16: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Operating System Evolution

Networks and Communication Department

Punched Cards

Page 17: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Operating System Evolution

Networks and Communication Department

Tape

Drives

Page 18: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Operating System Evolution

Networks and Communication Department

Page 19: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Operating System Evolution

Networks and Communication Department

In Batch operating systems each program to be executed was called a job.

A programmer who wished to execute a job sends a request to the operating room along with punched cards.

The punched cards were fed to the computer by an operator.

If the program was successful, a print out of the result was sent to the programmer.

If not, a print out of the error was sent.

Page 20: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Batch System Example

Networks and Communication Department

The idea behind it was to collect a tray full of jobs in the

input room and then read them onto a magnetic tape

using a small (relatively) inexpensive computer, such as

the IBM 1401, which was very good at reading cards,

copying tapes, and printing output, but not at all good at

numerical calculations. Other, much more expensive

machines, such as the IBM 7094, were used for the real

computing.

Page 21: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Batch System Example

(a) Programmers bring cards to 1401.

(b) 1401 reads batch of jobs onto tape.

(c) Operator carries input tape to 7094.

(d) 7094 does computing.

(e) Operator carries output

tape to 1401.

(f) 1401 prints output.

Page 22: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Operating System Evolution

Networks and Communication Department

Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced. The idea is to hold several jobs in memory at a time, and only assign a resource to a job that needs it on the condition that the resource is available.

Multiprogramming brought the idea of :

time sharing: resources could be shared between different jobs, with each job being allocated a portion of time to use a resource.

Because a computer is much faster than a human, time sharing is hidden from the user—each user has the impression that the whole system is serving them exclusively.

Page 23: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Operating System Evolution

Networks and Communication Department

Time Sharing Systems required a more complex operating

system.

They had to do scheduling which is : allocating resources to

different programs and deciding which program should use

which resource and when.

During this era, a new term was coined which is a process.

A job: is a program to be run.

But a process: is a program that is in memory and waiting

for resources.

Page 24: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Operating System Evolution

Networks and Communication Department

Personal Systems: When personal computers were

introduced, there was a need for an operating system for

this new type of computer.

During this era, single-user operating systems such as DOS

(Disk Operating System) were introduced.

Page 25: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Operating System Evolution

Networks and Communication Department

The need for more speed and efficiency led to the design

of:

parallel systems: multiple CPUs on the same machine.

Each CPU can be used to serve one program or a part of

a program, which means that many tasks can be

accomplished in parallel instead of serially.

The operating systems required for this are more

complex than those that support single CPUs.

Page 26: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Operating System Evolution

Networks and Communication Department

Distributed Systems: Networking and internetworking

have created a new dimension in operating systems.

A job that was previously done on one computer can

now be shared between computers that may be

thousands of miles apart.

A program can be run partially on one computer and

partially on another if they are connected through a

network.

Resources can be distributed too.

Distributed systems combine features of the previous

generation with new duties such as controlling security.

Page 27: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Operating System Evolution

Networks and Communication Department

Real-Time Systems: A real-time system is expected to do

a task within a specific time constraint. They are used

with real-time applications, which monitor, respond to or

control external processes or environments.

Such as : traffic control, patient monitoring and military

control systems.

Page 28: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

The typical components of an operating

system

Networks and Communication Department

Page 29: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Operating System Components

Networks and Communication Department

Today’s operating systems are very complex.

An operating system needs to manage different

resources in a computer system.

It resembles an organization with several managers

at the top level.

Page 30: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Operating System Components

Networks and Communication Department

Each manager is responsible for managing

their department, but also needs to cooperate

with others and coordinate activities.

A modern operating system has at least four

duties: memory manager, process manager,

device manager and file manager.

Page 31: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

OS Components- User interface

Networks and Communication Department

Each operating system has a :

user interface: a program that accepts requests

from users (processes) and interprets them for the

rest of the operating system.

A user interface in some operating systems, such

as UNIX, is called a shell. In others, it is called a

window to denote that it is menu driven and has

a GUI (graphical user interface) component.

Page 32: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

User Operating System Interface - CLI

Networks and Communication Department

Command Line Interface (CLI) or command

interpreter allows direct command entry

Which is an operating system shell that uses

alphanumeric characters typed on a keyboard to

provide instructions and data to the operating system,

interactively.

Page 33: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

User Operating System Interface - GUI

Networks and Communication Department

User-friendly desktop metaphor interface

Usually mouse, keyboard, and monitor

Icons represent files, programs, actions, etc

Various mouse buttons over objects in the interface cause various actions (provide information, options, execute function, open directory (known as a folder)

Many systems now include both CLI and GUI interfaces

Microsoft Windows is GUI with CLI “command” shell

Apple Mac OS X as “Aqua” GUI interface with UNIX kernel underneath and shells available

Solaris is CLI with optional GUI interfaces (Java Desktop, KDE)

Page 34: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

OS Components- Memory manager

Networks and Communication Department

Although the memory size of computers has

increased tremendously in recent years, so has the

size of the programs and data to be processed.

Memory allocation must be managed to prevent

applications from running out of memory.

Operating systems can be divided into two broad

categories of memory management:

monoprogramming and multiprogramming.

Page 35: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Monoprogramming

Networks and Communication Department

In monoprogramming, most of the memory capacity is dedicated to a single program.

only a small part is needed to hold the operating system.

In this configuration, the whole program is in memory for execution.

When the program finishes running, the program area is occupied by another program.

Page 36: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Monoprogramming

Networks and Communication Department

Figure shows memory in

Monoprogramming a environment

Page 37: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Monoprogramming (Cont.)

Networks and Communication Department

There are several problems with this technique:

If the size of memory is less than the size of the program,

can the program run?

the program cannot be run

Inefficient use of memory and CPU time

Page 38: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Multiprogramming

Networks and Communication Department

In multiprogramming:

more than one program is in memory at the

same time and they are executed concurrently

with the CPU switching rapidly between the

programs

Page 39: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Multiprogramming

Networks and Communication Department

Figure shows memory in a multiprogramming

environment

Page 40: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Categories of multiprogramming

Networks and Communication Department

Page 41: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Multiprogramming (Cont.)

Networks and Communication Department

Page 42: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Multiprogramming (Cont.)

Networks and Communication Department

Nonswapping category:

This means that the program remains in

memory for the duration of execution

Two techniques belong to the this category:

Partitioning

paging

Page 43: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Multiprogramming (Cont.)

Networks and Communication Department

Swapping category:

This means that, during execution, the

program can be swapped between memory

and disk one or more times.

Two techniques belong to the this category:

Demand paging

Demand segmentation

Page 44: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Partitioning

Networks and Communication Department

The first technique used in multiprogramming.

Memory is divided into variable length sections

Each section or partition holds one program

The CPU switches between programs

With this technique, each program is entirely in

memory and occupying contiguous locations

Page 45: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Partitioning- how its work ?!

Networks and Communication Department

1. The CPU starts with one program, executing some instructions until it either encounters an input/output operation or the time allocated for that program has expired

2. Then, it saves the address of the memory location where the last instruction was executed and moves to the next program.

3. The same procedure is repeated with the second program

4. After all the programs have been served, the CPU moves back to the first program

Page 46: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Partitioning- how its work ?! (Cont.)

Networks and Communication Department

Priority levels can be used to control the amount of

CPU time allocated to each program

Its improves the efficiency of the CPU, but there are

still some issues

Page 47: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Partitioning- how its work ?! (Cont.)

Networks and Communication Department

Figure shows memory with

partitioning technique

Page 48: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Partitioning issues

Networks and Communication Department

The size of the partitions has to be determined

beforehand by the memory manager

what will happen if partition sizes are small or large?!

The memory manager can compact the partitions to

remove the holes and creates new partitions, but this

creates extra overhead on the system

Page 49: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Paging

Networks and Communication Department

Paging improves the efficiency of partitioning

Memory is divided into equally sized sections called

frames

Programs are also divided, into equally sized

sections called pages

The size of a page and frame is usually the same

and equal to the size of the block used by the

system to retrieve information from a storage

device

Page 50: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Paging - how its work!!

Networks and Communication Department

A page is loaded into a frame in memory

The program does not have to be contiguous in

memory

There is no need for the new program to wait

until set of contiguous frames are free before

being loaded into memory

Page 51: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Paging - how its work!!

Networks and Communication Department

Figure shows memory with paging technique

Page 52: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Paging issues

Networks and Communication Department

The whole program still needs to be in memory

before being executed

Ex: A program has six pages, cannot be loaded into

memory if there are only four unoccupied frames

Page 53: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Demand paging

Networks and Communication Department

In this technique the program is divided into

pages

but the pages can be loaded into memory one

by one, executed, and replaced by another

page.

In addition, a page can be loaded into any

free frame

Page 54: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Demand paging (Cont.)

Networks and Communication Department

An example of demand paging is shown in figure

below. Two pages from program A, one page from

program B, and one page from program C are in

the memory

Page 55: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Demand segmentation

Networks and Communication Department

A technique similar to paging is segmentation

A programmer thinks in terms of modules

A program is usually made up of a main program and subprograms

In demand segmentation, the program is divided into segments that match the programmer’s view

These are loaded into memory, executed, and replaced by another module from the same or a different program

since segments in memory are of equal size, part of a segment may remain empty

Page 56: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Demand segmentation

Networks and Communication Department

An example of demand

segmentation is shown in figure

Page 57: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Demand paging and segmentation

Networks and Communication Department

Demand paging and segmentation can be

combined to further improve the efficiency of the

system

A segment may be too large to fit any available

free space in memory

Memory can be divided into frames, and module

can be divided into pages

The pages of a module can then be loaded into

memory one by one and executed

Page 58: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Virtual Memory

Networks and Communication Department

Page 59: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Virtual memory

Networks and Communication Department

Demand paging and demand segmentation mean that, when a program is being executed, part of the program is in memory and part is on disk.

This means that, for example, a memory size of 10 MB can execute 10 programs, each of size 3 MB, for a total of 30 MB.

At any moment, 10 MB of the 10 programs are in memory and 20 MB are on disk.

There is therefore an actual memory size of 10 MB, but a virtual memory size of 30 MB

Page 60: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Virtual memory (Cont.)

Networks and Communication Department

Virtual memory, which implies demand paging,

demand segmentation or both, is used in almost all

operating systems today.

Figure below shows the concept.

Page 61: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

OS Components- Process manager

Networks and Communication Department

A second function of an operating system is process management, but before discussing this concept, we need to define some terms.

A program is a non-active set of instructions stored on disk. It may or may not become a job

A program becomes a job from the moment it is selected for execution until it has finished running and becomes a program again.

A process is a program in execution. It is a program that has started but has not finished.

Page 62: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

State diagrams

Networks and Communication Department

The relationship between a program, a job and

a process becomes clearer if we consider how

a program becomes a job and how a job

becomes a process.

This can be illustrated with a state diagram

that shows the different states of each of these

entities.

Page 63: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

State diagrams (Cont.)

Networks and Communication Department

Figure shows a State diagram with boundaries between program, job and process

Page 64: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

State diagrams (Cont.)

Networks and Communication Department

A program becomes a job when selected by the operating system and brought to the hold state

It remains in this state until it can be loaded into memory

When there is memory space available to load the program totally or partially, the job moves to the ready state. It now becomes a process

It remains in memory and in this state until the CPU can execute it, moving it to the running state at this time

When in the running state, one of three things can happen:

The process executes until it needs I/O resources, it goes into the waiting state

The process exhausts its allocated time slot, it goes into the ready state

The process terminates, it goes into the terminated state

Page 65: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Schedulers

Networks and Communication Department

To move a job or process from one state to

another,

The process manager uses two schedulers

The job scheduler

The process scheduler

Page 66: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Schedulers (Cont.)

Networks and Communication Department

Job scheduler:

Moves a job from the hold state to the ready state or

from the running state to the terminated state

(Figure shows job scheduler)

Page 67: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Schedulers (Cont.)

Networks and Communication Department

Process scheduler:

Moves a process between the running, waiting, and

ready states many times before it goes to the

terminated state and is no longer a process

As shown in the figure below

Page 68: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Queuing

Networks and Communication Department

In reality, there are many jobs and many

processes competing with each other for

computer resources.

Page 69: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Queuing

Networks and Communication Department

To handle multiple processes and jobs, the process manager uses queues (waiting lists).

A job control block or process control block is associated with each job or process.

This is a block of memory that stores information about that job or process.

The process manager stores the job or process control block in the queues instead of the job or process itself.

Page 70: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Queuing (Cont.)

Networks and Communication Department

Figure shows the circulation of jobs and processes

through three queues ( the job queue, the ready

queue , and the I/O queue)

Page 71: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Queuing (Cont.)

Networks and Communication Department

The job queue holds the jobs that are waiting for

memory

The ready queue holds the processes that are in

memory, ready to be run and waiting for the CPU

The I/O queue holds the processes that are waiting

for an I/O device (one queue for each I/O device)

Page 72: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Selecting next job or process

Networks and Communication Department

The process manager can have different policies for

selecting the next job or process from a queue:

It could be first in first out (FIFO), shortest length

first, highest priority first, and so on

Page 73: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Process synchronization

Networks and Communication Department

The whole idea behind process management is

to synchronize different processes with

different resources.

Whenever resources can be used by more than

one user (or process, in this case), we can have

two problematic situations: deadlock and

starvation.

Page 74: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Deadlock on a narrow bridge

Networks and Communication Department

Page 75: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Deadlock

Networks and Communication Department

There are four necessary conditions for deadlock to occur:

Mutual exclusion only one process can hold a resource

Resource holding A process holds a resource even though it cannot use it until other resources are available

No preemption The OS cannot temporarily reallocate a resource

Circular waiting All processes and resources involved form a loop

Deadlock occurs when the operating system does not

put resource restrictions on processes.

Page 76: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Deadlock example

Networks and Communication Department

Assume that there are two processes, A and B

Process A is holding File 1, and it has requested File

2 and cannot release File 1 until it acquires File 2

Process B is holding File 2, and it has requested File

1 and cannot release File 2 until it acquires File 1

Files in most system are not sharable

If there is no provision in this situation to force a

process to release a file, deadlock is created (as

shown in figure below)

Page 77: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Deadlock example (Cont.)

Networks and Communication Department

Page 78: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

How the system preventing deadlock?

Networks and Communication Department

One solution is not to allow a process to start running

until the required resources are free, but this creates

another problem (Starvation)

The second solution is: do not allow one of deadlock

conditions to happen (i.e. limit the time a process can

hold a resource)

Page 79: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

The dining philosophers problem

Networks and Communication Department

Page 80: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Starvation

Networks and Communication Department

Starvation is the opposite of deadlock. It can happen

when the operating system puts too many resource

restrictions on a process.

Page 81: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Starvation example

Networks and Communication Department

For example, imagine an operating system that specifies that a process must have possession of its required resources before it can be run

In Figure below,

Imagine that process A needs two files, File1 and File2

File1 is being used by process B and File2 is being used by process E

Process B terminates and releases File1

Process C, which needs only File1, is allowed to run

Process E terminates and releases File2

Process D, which needs only File2, is allowed to run

Page 82: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Starvation example (Cont.)

Networks and Communication Department

Page 83: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

OS Components- Device manager

Networks and Communication Department

The device manager, or input/output manager,

is responsible for access to input/ output

devices.

There are limitations on the number and speed

of input/output devices in a computer system.

The device manager is responsible for the

efficient use of input/output devices

Page 84: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Device manager responsibilities

Networks and Communication Department

The device manager monitors every input/output device constantly to ensure that the device is functioning properly.

The device manager maintains a queue for each input/output device or one or more queues for similar input/output devices.

The device manager controls the different policies for accessing input/output devices. i.e. it may use FIFO for one device and shortest length first for another

Page 85: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

OS Components- File manager

Networks and Communication Department

Operating systems today use a file manager to control access to files. The responsibilities of a file manager: Controls access to files. The type of access can vary

(read, write, execute)

Supervises the creation, deletion, and modification of files.

Controls the naming of files.

Supervises the storage of files. ( how, where,.. etc)

is responsible for archiving and backups.

Page 86: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

Networks and Communication Department

86

Any Q

uest

ions

?

Page 87: OPERATING SYSTEMS - WordPress.com System Evolution Networks and Communication Department Time Sharing Systems: to use computer system resources efficiently, multiprogramming was introduced

References

Networks and Communication Department

Behrouz Forouzan and Firouz Mosharraf,

“Foundations of computer science”, Second edition,

chapter7, pp. 188-203