chapter 7 operating systems. define the purpose and functions of an operating system. understand the...

46
Chapter 7 Operating Systems

Upload: silas-walters

Post on 03-Jan-2016

245 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

Chapter 7

OperatingSystems

Page 2: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

Define the purpose and functions of an operating system.Define the purpose and functions of an operating system.

Understand the components of an operating system.Understand the components of an operating system.

Understand the concept of virtual memory.Understand the concept of virtual memory.

Understand the concept of deadlock and starvation.Understand the concept of deadlock and starvation.

After reading this chapter, the reader should After reading this chapter, the reader should be able to:be able to:

OOBJECTIVESBJECTIVES

List some of the characteristics of popular operating systemsList some of the characteristics of popular operating systemssuch as Windows 2000, UNIX, and Linux.such as Windows 2000, UNIX, and Linux.

Page 3: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

Computer System

Application programs –use the computer hardware to solve users’ problems.

Operating systems –control the access of hardware by users.

Page 4: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

DEFINITIONDEFINITIONDEFINITIONDEFINITION

7.17.1

Page 5: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

An operating system An operating system is an is an interfaceinterface between between the the hardware of a computerhardware of a computer and and the the user (program or human)user (program or human) that facilitates that facilitates the execution of the other programsthe execution of the other programs and and the access to hardware and the access to hardware and software resourcessoftware resources..

Note:Note:

Page 6: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

Goals of An operating systemGoals of An operating system

1. 1. EfficientEfficient use of hardware use of hardware

2. 2. EasyEasy to use resources. to use resources.

Note:Note:

Page 7: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

EVOLUTIONEVOLUTIONEVOLUTIONEVOLUTION

7.27.2

Page 8: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

Batch systems

Card-reader + line-printer + tape-drive Job – a program to be executed.

Page 9: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

Time-sharing systems

MultiprogrammingHold several jobs in memoryOnly assign a resource to a job that needs it

on the condition that the resource is available. Time-sharing –

Resources can be shared between different jobs.Each job can be allocated a portion of time to use the resource.

Page 10: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

Time-sharing systems

Scheduling – allocating the resources to different programs and deciding which program should use which resource when.

A job is a program to be run. A process is a program that is

in memory and waiting for resources.

program job process

Page 11: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

Personal systems

Personal computer Single-user operating systems.

Page 12: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

Parallel systems

Multiple CPUs on the same machine. Each CPU can be used to serve

one program or a part of a program.

Many tasks can be accomplished in parallel instead of serially.

Page 13: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

Distributed systems

A program can be run partially on one computer and partially on another computer if they are connected through an internetwork such as the Internet.

Resources can distributed.

Page 14: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

COMPONENTSCOMPONENTSCOMPONENTSCOMPONENTS

7.37.3

Page 15: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

Components of an operating system

User Interface (Shell)is responsible for communication outside the OS.

Page 16: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

Memory Manager

Memory managementMonoprogrammingMultiprogramming

Memory allocation must be managed to prevent the “running out of memory” syndrome.

Page 17: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

Monoprogramming

Most of the memory capacity is dedicated to one single program.

The whole program is in memory for execution.

When the program finishes running, it is replaced by another program.

Page 18: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

Monoprogramming

Memory managerLoad the program into memoryRun itReplace it with the next program

Problems of Monoprogramming The program must fit in memory.When the I/O operations are being carried out,

the CPU is idle.

Page 19: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

Multiprogramming

More than one program is in memory at the same time, and they are executed concurrently.

The CPU switches between the programs.

Page 20: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

Categories of multiprogramming

Nonswapping – the program remains in memory during execution.

Swapping – the program can be swapped between memory and disk one or more times during execution.

Page 21: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

Partitioning Memory is divided into variable length sections. Each program is entirely in memory and occupying

contiguous locations. The CPU switches between programs.

It executes some instructions until it either encounters an I/O operation or the allocated time has expired.

Fragmentation internal fragmentation – memory space that is internal to

a partition, but is not being used. external fragmentation – Enough memory space exists

but not contiguous.

Page 22: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

Partitioning

Page 23: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

Paging Memory is divided into

equally sized sections called frames. The program is divided into

equally sized sections called pages. The program does not have to be contiguous in

memory. The whole program still needs to be in memory

before being executed.

Fragmentation internal fragmentation – the last frame. No external fragmentation – Allows non-contiguous

allocation.

Page 24: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

Paging

Page 25: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

Demand Paging & Demand Segmentation

Demand Paging -The pages can be loaded into memory one by one on demand.

Demand Segmentation – The program is divided into segments that match the programmer’s view (modules).

Demand Paging and Segmentation

Page 26: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

Virtual memory Demand Paging & Demand Segmentation –

Part of the program is in main memory andpart is on the disk.

A physical memory size of 10MB can execute 10 programs, each of size 3MB.→ A virtual memory size of 30MB.

Page 27: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

Process manager Program – a nonactive set of instructions stored on disk. Job – a program becomes a job

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

May be Residing on disk (Hold) In memory waiting for an I/O event (Waiting) In memory waiting for execution (Ready) In memory while being executed by CPU (Running) Has finished executing and becomes a program again (Terminated)

Process - a program in execution - a job in memory

Page 28: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

State diagram A process in the running state, one of three tings can happen:

exhausts its allocated slot of time execute until it needs I/O terminated

Page 29: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

Process manager uses two schedulers to move a job/process from one state to another: Job scheduler –

create a process from a job terminate a process

Process scheduler – move a process from one state to another.

Page 30: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

Job scheduler

Page 31: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

Process scheduler

Page 32: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

Queuing (waiting list) Process manager uses queues to handle multiple processes/jobs

Waiting for CPU (Ready queue) Waiting for memory (Job queue) Waiting for I/O device (I/O queue)

JCB/PCB (Job control block/Process control block) –store information about that job/process

Process manager stores the JCB/PCB in the queues instead of the job/process itself. Process manager can have different policies

for selecting next job/process from a queue. FIFO(First In First Out) Shortest length first Priority

Page 33: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

Queues for process management

Page 34: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

Process management – synchronize different processes with different resources.

Deadlock – occurs if OS allows a process to start running without first checking to see

if the required resources are ready and allows the process to hold it as long as it want.

Process Synchronization

Page 35: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

Four necessary conditions for deadlock: 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 – OS cannot temporarily reallocate a resource

Circular wait – all processes and resources involved form a loop

Don’t allow anyone to happen.

Deadlock

Page 36: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

Deadlock on a bridge

Page 37: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

DeadlockDeadlock occurs when OS occurs when OS does notdoes not put put resource restrictionsresource restrictions on on processes.processes.

Note:Note:

Page 38: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

Dining philosophers

Page 39: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

Starvation

Starvation – It can happen when OS puts too many resource restrictions on a process.

[ex.] OS specifies possession of all the required resources before a process can be run

Page 40: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

Starvation

Page 41: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

Starvation

Page 42: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

Figure 7-15.c

Starvation

Page 43: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

I/O manager – is responsible for access to I/O devices.Assure that the devices are functioning properly. Maintain queuesControl scheduling policies

Device manager

Page 44: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

controls access to the files. Creation/deletion/modification Naming Storage of files Archiving and backup

Archive – copy files to a long-term storage medium for backup.

File manager

Page 45: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

POPULARPOPULAROPERATINGOPERATING

SYSTEMSSYSTEMS

POPULARPOPULAROPERATINGOPERATING

SYSTEMSSYSTEMS

7.47.4

Page 46: Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the

Windows 2000 GUI Virtual memory Multiprogramming

UNIX Portable OS (written mostly in C) A powerful set of utilities (commands) Device independent (include device drivers in OS itself)

Linux Based on UNIX Make UNIX more efficient when run on an Intel

microprocessor

Popular Operating Systems