Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 4 - Processor Management Ivy Tech State College Northwest Region 01 CIS106 Microcomputer Operating Systems Gina Rue CIS Faculty.

Similar presentations


Presentation on theme: "Chapter 4 - Processor Management Ivy Tech State College Northwest Region 01 CIS106 Microcomputer Operating Systems Gina Rue CIS Faculty."— Presentation transcript:

1 Chapter 4 - Processor Management Ivy Tech State College Northwest Region 01 CIS106 Microcomputer Operating Systems Gina Rue CIS Faculty

2 2 Introduction - Processor Management Process ManagerProcess Manager –Job Scheduling –Process Scheduling –Interrupt Management

3 3 Introduction - Processor Management Single-user systemsSingle-user systems –the processor is busy only when the user is executing a job –at other times it is idle

4 4 Introduction - Processor Management MultiprogrammingMultiprogramming –Many users with many jobs on the system –The processor must be allocated to each job in a fair and efficient manner

5 5 Introduction - Processor Management Processor (CPU) Central Processing UnitProcessor (CPU) Central Processing Unit CPU: performs calculations & executes programsCPU: performs calculations & executes programs Process: single instance of executable program, a calculation is a processProcess: single instance of executable program, a calculation is a process Job or Program: work (instructions) submitted by the UserJob or Program: work (instructions) submitted by the User

6 6 Processor Management Multiprogramming requires that the processor be:Multiprogramming requires that the processor be: –Allocated to each job or each process –deallocated at an appropriate moment

7 7 Process Management A single processor can be shared by several jobs or processes if the OS has: scheduling policyscheduling policy scheduling algorithmscheduling algorithm to determine when to stop one job & proceed with another

8 8 Job Scheduling vs. Process Scheduling Process Manager is two submanagers:Process Manager is two submanagers: –Job Scheduler in charge of job scheduling –Process Scheduler in charge of process scheduling

9 9 Job Scheduler vs. Process Scheduling Job Scheduler high-level schedulerhigh-level scheduler selects jobs from a queue of incoming jobs, places them into a process queueselects jobs from a queue of incoming jobs, places them into a process queue goal to put jobs in sequence to fully use resourcesgoal to put jobs in sequence to fully use resources strives for balanced mix between jobs that require large amount of I/O interaction & jobs that require large amounts of computationstrives for balanced mix between jobs that require large amount of I/O interaction & jobs that require large amounts of computation

10 10 Process Scheduler Takes over after a job has been placed on the READY queue by the Job Scheduler –(low-level scheduler ) assigns the CPU to execute each job in READY queue –alternates between CPU cycles & I/O cycles –I/O-bound jobs: printing series of documents –CPU-bound jobs: finding 100 prime numbers

11 See Fig. 4.1 p.7911 Process Scheduler In highly interactive environments -In highly interactive environments - –3rd Layer - middle-level scheduler manages jobs swapped out & in to allow jobs to be completed faster

12 See Fig. 4.2 p.7912 Job and Process Status As a job moves through the system, it’s always in one of five states (or at least three) –HOLD –READY –WAITING –RUNNING –FINISHED

13 See Fig. 4.3 p.8013 Process Control Blocks Each process in a system is represented by data structures (PCB) that contain basic job information –Process Identification –Process Status –Process State –Accounting

14 See Fig. 4.4 p.8214 PCBs and Queuing PCBPCB –created when Job Scheduler accepts the job & is updated as the job progresses from beginning to end of its execution QueuesQueues –use PCBs to track jobs –PCBs are lists of information linked to form queues

15 15 Process Scheduling Policies Before the OS can schedule jobs in a multiprogramming environment, it needs to resolve three system limitations: –there are a finite number of resources (disk drives, printers, tape drives) –some resources, once they’re allocated, can’t be shared with another job (printers) –some resources require operator intervention - they can’t be reassigned automatically from job to job (such as tape drives)

16 16 Process Scheduling Policies What is a “good” process scheduling policy? –Maximize throughputthroughput CPU efficiencyCPU efficiency –Minimize response timeresponse time turnaround timeturnaround time waiting timewaiting time –Ensure fairness for all jobs

17 17 Process Scheduling Policies “Good” process scheduling policy contradictions –If a system favors one type of user, it may harm or does not efficiently use resources –System designer determines which criteria is most important for a specific system “maximize CPU utilization while minimizing response time and balancing the use of all system components through a mix of I/O-bound and CPU-bound jobs”“maximize CPU utilization while minimizing response time and balancing the use of all system components through a mix of I/O-bound and CPU-bound jobs”

18 18 Process Scheduling Policies Problem: Job claims the CPU for a very long time before issuing an I/O request Solution: Process Scheduler uses a timing mechanism and periodically interrupts running processes when a predetermined slice of time has expired. –An I/O request is called a “natural wait” in multiprogramming environments to allow the processor to be allocated to another job

19 19 Process Scheduling Policies Scheduling Strategies Preemptive Scheduling PolicyPreemptive Scheduling Policy –interrupts the processing of a job and transfers the CPU to another job, widely used in time-sharing environments Nonpreemptive Scheduling PolicyNonpreemptive Scheduling Policy –functions without external interrupts to the job –once a job captures the processor and begins execution, it remains RUNNING until it issues an I/O request (natural wait) or until finished (with exceptions made for infinite loops)

20 20 Process Scheduling Algorithms Based on a specific policy, Process Scheduler relies on a process scheduling algorithm to allocate the CPU and move jobs through the systemBased on a specific policy, Process Scheduler relies on a process scheduling algorithm to allocate the CPU and move jobs through the system Most current systems, with emphasis on interactive use and response time, use an algorithm that takes care of immediate requests of interactive usersMost current systems, with emphasis on interactive use and response time, use an algorithm that takes care of immediate requests of interactive users Six common process scheduling algorithms

21 See Fig. 4.5 & 4.6 p.8521 Process Scheduling Algorithms First Come First Served (FCFS)First Come First Served (FCFS) –nonpreemptive scheduling algorithm –handles jobs according to their arrival –the earlier jobs arrive, the sooner they’re served –simple algorithm to implement, it uses FIFO queue –good for batch systems, not good for interactive systems due to delay slow response time –turnaround time is unpredictable

22 See Fig. 4.7 p.8622 Process Scheduling Algorithms Shortest Job Next (SJN)Shortest Job Next (SJN) –nonpreemptive scheduling algorithm (also known as Shortest Job First or SFJ –handles jobs based on their length in their CPU cycle –good for batch systems, estimates CPU time is required to run the job given in advance –not good for interactive systems that don’t estimate in advance the CPU time required to run their jobs –optimal only when all of the jobs are available at the same time & the CPU estimates are available & accurate

23 23 Process Scheduling Algorithms Priority SchedulingPriority Scheduling –nonpreemptive scheduling algorithm –used in batch systems, although slower turnaround time to some users –gives preferential treatment to important jobs –allows programs with highest priority to be processed first –priorities can be assigned by system administrators –jobs are usually linked to one of several READY queues

24 24 Process Scheduling Algorithms Priority Scheduling priorities can be determined by the Process Manager based on characteristics intrinsic to the job such as:Priority Scheduling priorities can be determined by the Process Manager based on characteristics intrinsic to the job such as: –memory requirements –number & type of peripheral devices –Total CPU time –Amount of time already spent in the system

25 See Fig. 4.8 & 4.9 p.88-8925 Process Scheduling Algorithms Shortest Remaining Time (SRT)Shortest Remaining Time (SRT) –preemptive version of SJN algorithm –processor is allocated to the job closest to completion –requires advance knowledge of the CPU required to finish each job, can’t be used for interactive system –often used in batch systems when it is desirable to give preference to short jobs –context switching required, a job processing information must be save in its PCB for when a job is executed

26 26 Process Scheduling Algorithms Round RobinRound Robin –preemptive process scheduling algorithm –used in interactive systems because it easy to implement –based on a predetermined slice of time that’s given to each job to ensure the CPU is shared equally among all active processes & is not monopolized by any one job

27 See Fig. 4.10&11 p.90-9127 Process Scheduling Algorithms Round RobinRound Robin time slice is called a time quantum & its size is crucial to system performance –Two general rules of thumb for selecting the “proper” time quantum it should be long enough to allow for 80% of the CPU cycles to run to completionit should be long enough to allow for 80% of the CPU cycles to run to completion it should be at least 100 times longer than the time required to perform on context switchit should be at least 100 times longer than the time required to perform on context switch These rules are used in some systems are flexible

28 28 Process Scheduling Algorithms Multiple Level QueuesMultiple Level Queues –not really scheduling algorithm –it works in conjunction with other schemes –it is found in systems with jobs that can be grouped according to common characteristics –priority scheduling is one kind of multiple level queue with different queues for each priority level

29 29 Process Scheduling Algorithms Multiple Level QueuesMultiple Level Queues Four primary methods of movement –no movement between queues –movement between queues –variable time quantum per queue –Called Aging indefinite postponement-a job’s execution is delayed indefinitely because it is repeatedly preempted so other jobs can be processed which may lead to “starvation”indefinite postponement-a job’s execution is delayed indefinitely because it is repeatedly preempted so other jobs can be processed which may lead to “starvation”

30 30 A Word About Interrupts Interrupts are a way for an OS to get the attention of the CPUInterrupts are a way for an OS to get the attention of the CPU In Chapter 3, the Memory Manager issued interrupts to accommodate job requestsIn Chapter 3, the Memory Manager issued interrupts to accommodate job requests Other interrupts are caused by events internal to the processOther interrupts are caused by events internal to the process I/O interrupts are issued when a READ or WRITE command is issuedI/O interrupts are issued when a READ or WRITE command is issued

31 31 A Word About Interrupts Internal Interrupts or synchronous interrupts occur as a result of an arithmetic operation or job instruction being processed.Internal Interrupts or synchronous interrupts occur as a result of an arithmetic operation or job instruction being processed. Illegal arithmetic operationsIllegal arithmetic operations –attempts to divide by zero –floating point operation generating an overflow or underflows Illegal job instructionsIllegal job instructions –attempts to access protected or nonexistent storage –attempts to use an undefined operation code, operating on invalid data

32 32 A Word About Interrupts Interrupts handler is the control program that handles the interruption sequence. When the OS detects a nonrecoverable error, the interrupt handler follows this sequence:Interrupts handler is the control program that handles the interruption sequence. When the OS detects a nonrecoverable error, the interrupt handler follows this sequence: –type of interrupt is described & stored to be passed on to the user as an error message –state of the interrupt process is saved –interrupt is processed –processor resumes normal operation

33 33 Summary Process Manger allocates the CPU among all system usersProcess Manger allocates the CPU among all system users Distinctions between job schedulingDistinctions between job scheduling –selection of jobs based on characteristics –process scheduling –instant-by-instant allocation of CPU

34 See Tab 4.1 p.9534 Summary Interrupts are generated & resolved by interrupt handlerInterrupts are generated & resolved by interrupt handler Scheduling algorithms have uniqueScheduling algorithms have unique –characteristics –objectives –applications A system designer can choose the best policies & algorithm after evaluating their strengths & weaknessesA system designer can choose the best policies & algorithm after evaluating their strengths & weaknesses


Download ppt "Chapter 4 - Processor Management Ivy Tech State College Northwest Region 01 CIS106 Microcomputer Operating Systems Gina Rue CIS Faculty."

Similar presentations


Ads by Google