©brooks/cole, 2003 chapter 7 operating systems dr. barnawi

42
©Brooks/Cole, 2003 Chapter 7 Operating Systems Dr. Barnawi

Post on 21-Dec-2015

279 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: ©Brooks/Cole, 2003 Chapter 7 Operating Systems Dr. Barnawi

©Brooks/Cole, 2003

Chapter 7

OperatingSystems

Dr. Barnawi

Page 2: ©Brooks/Cole, 2003 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

Page 3: ©Brooks/Cole, 2003 Chapter 7 Operating Systems Dr. Barnawi

©Brooks/Cole, 2003

O .S. DEFINITIONO .S. DEFINITIONO .S. DEFINITIONO .S. DEFINITION

7.17.1

Page 4: ©Brooks/Cole, 2003 Chapter 7 Operating Systems Dr. Barnawi

©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

Page 5: ©Brooks/Cole, 2003 Chapter 7 Operating Systems Dr. Barnawi

©Brooks/Cole, 2003

O.S. EVOLUTIONO.S. EVOLUTIONO.S. EVOLUTIONO.S. EVOLUTION

7.27.2

Dr. Barnawi

Page 6: ©Brooks/Cole, 2003 Chapter 7 Operating Systems 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

Page 7: ©Brooks/Cole, 2003 Chapter 7 Operating Systems Dr. Barnawi

©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

Page 8: ©Brooks/Cole, 2003 Chapter 7 Operating Systems Dr. Barnawi

©Brooks/Cole, 2003

3. Personal System

• Introduced for personal computers.

• Examples Disk Operating System (DOS)

Page 9: ©Brooks/Cole, 2003 Chapter 7 Operating Systems Dr. Barnawi

©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.

Page 10: ©Brooks/Cole, 2003 Chapter 7 Operating Systems Dr. Barnawi

©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

Page 11: ©Brooks/Cole, 2003 Chapter 7 Operating Systems Dr. Barnawi

©Brooks/Cole, 2003

COMPONENTSCOMPONENTSCOMPONENTSCOMPONENTS

7.37.3

Page 12: ©Brooks/Cole, 2003 Chapter 7 Operating Systems Dr. Barnawi

©Brooks/Cole, 2003

Figure 7-2

Components of an operating system

Page 13: ©Brooks/Cole, 2003 Chapter 7 Operating Systems Dr. Barnawi

©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.

Page 14: ©Brooks/Cole, 2003 Chapter 7 Operating Systems Dr. Barnawi

©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

Page 15: ©Brooks/Cole, 2003 Chapter 7 Operating Systems 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.

Page 16: ©Brooks/Cole, 2003 Chapter 7 Operating Systems Dr. Barnawi

©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

Page 17: ©Brooks/Cole, 2003 Chapter 7 Operating Systems Dr. Barnawi

©Brooks/Cole, 2003

Figure 7-5

Categories of multiprogramming

Programs stay in memory during execution

Programs can swap between memory and disk during execution

Dr. Barnawi

Page 18: ©Brooks/Cole, 2003 Chapter 7 Operating Systems 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

Page 19: ©Brooks/Cole, 2003 Chapter 7 Operating Systems Dr. Barnawi

©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

Page 20: ©Brooks/Cole, 2003 Chapter 7 Operating Systems Dr. Barnawi

©Brooks/Cole, 2003

Figure 7-7

Paging

Memory is divided into equal sized sections (frames)

Program is divided into pages

• 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

Page 21: ©Brooks/Cole, 2003 Chapter 7 Operating Systems Dr. Barnawi

©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

Page 22: ©Brooks/Cole, 2003 Chapter 7 Operating Systems Dr. Barnawi

©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.

Page 23: ©Brooks/Cole, 2003 Chapter 7 Operating Systems Dr. Barnawi

©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.

Page 24: ©Brooks/Cole, 2003 Chapter 7 Operating Systems Dr. Barnawi

©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.

Page 25: ©Brooks/Cole, 2003 Chapter 7 Operating Systems Dr. Barnawi

©Brooks/Cole, 2003

Figure 7-8

Virtual memory (swapping)- Example

6 MB24 MB

6 programs each 4 MB

At one time, 1 MB of each program is in the memory and 3 MB are in the Disk.

Program #1

#2

#3

#4

#5

#6

Frame (1 MB)

Page (1 MB)

Dr. Barnawi

Page 26: ©Brooks/Cole, 2003 Chapter 7 Operating Systems 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.

Page 27: ©Brooks/Cole, 2003 Chapter 7 Operating Systems Dr. Barnawi

©Brooks/Cole, 2003

Figure 7-9 State diagram with the boundaries between a program, a job, and a process

Page 28: ©Brooks/Cole, 2003 Chapter 7 Operating Systems Dr. Barnawi

©Brooks/Cole, 2003

Figure 7-10

Job scheduler

• Job scheduler is responsible for creating a process from job and terminating a process.

Page 29: ©Brooks/Cole, 2003 Chapter 7 Operating Systems Dr. Barnawi

©Brooks/Cole, 2003

Figure 7-11

Process scheduler

• Process scheduler moves a process from one state to another.

Dr. Barnawi

Page 30: ©Brooks/Cole, 2003 Chapter 7 Operating Systems 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.

Page 31: ©Brooks/Cole, 2003 Chapter 7 Operating Systems Dr. Barnawi

©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…

Page 32: ©Brooks/Cole, 2003 Chapter 7 Operating Systems Dr. Barnawi

©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

Page 33: ©Brooks/Cole, 2003 Chapter 7 Operating Systems Dr. Barnawi

©Brooks/Cole, 2003

Figure 7-13

Deadlock

Page 34: ©Brooks/Cole, 2003 Chapter 7 Operating Systems Dr. Barnawi

©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.

Page 35: ©Brooks/Cole, 2003 Chapter 7 Operating Systems Dr. Barnawi

©Brooks/Cole, 2003

Figure 7-15.a

Starvation

Starvation happens when OS puts too many restriction on resources

Page 36: ©Brooks/Cole, 2003 Chapter 7 Operating Systems Dr. Barnawi

©Brooks/Cole, 2003

Figure 7-15.b

Starvation

Dr. Barnawi

Page 37: ©Brooks/Cole, 2003 Chapter 7 Operating Systems Dr. Barnawi

©Brooks/Cole, 2003

Figure 7-15.c

Starvation

Dr. Barnawi

Page 38: ©Brooks/Cole, 2003 Chapter 7 Operating Systems Dr. Barnawi

©Brooks/Cole, 2003

Figure 7-16

Dining philosophers-Dijkstra

Page 39: ©Brooks/Cole, 2003 Chapter 7 Operating Systems Dr. Barnawi

©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.

Page 40: ©Brooks/Cole, 2003 Chapter 7 Operating Systems Dr. Barnawi

©Brooks/Cole, 2003

File Manageraccessing 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.

Page 41: ©Brooks/Cole, 2003 Chapter 7 Operating Systems Dr. Barnawi

©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

Page 42: ©Brooks/Cole, 2003 Chapter 7 Operating Systems Dr. Barnawi

©Brooks/Cole, 2003

POPULARPOPULAROPERATINGOPERATING

SYSTEMSSYSTEMS

POPULARPOPULAROPERATINGOPERATING

SYSTEMSSYSTEMS

7.47.4