Your SlideShare is downloading. ×
0
Chapter 4  processor management
Chapter 4  processor management
Chapter 4  processor management
Chapter 4  processor management
Chapter 4  processor management
Chapter 4  processor management
Chapter 4  processor management
Chapter 4  processor management
Chapter 4  processor management
Chapter 4  processor management
Chapter 4  processor management
Chapter 4  processor management
Chapter 4  processor management
Chapter 4  processor management
Chapter 4  processor management
Chapter 4  processor management
Chapter 4  processor management
Chapter 4  processor management
Chapter 4  processor management
Chapter 4  processor management
Chapter 4  processor management
Chapter 4  processor management
Chapter 4  processor management
Chapter 4  processor management
Chapter 4  processor management
Chapter 4  processor management
Chapter 4  processor management
Chapter 4  processor management
Chapter 4  processor management
Chapter 4  processor management
Chapter 4  processor management
Chapter 4  processor management
Chapter 4  processor management
Chapter 4  processor management
Chapter 4  processor management
Chapter 4  processor management
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Chapter 4 processor management

1,338

Published on

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,338
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
48
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Chapter Four : Processor Management <ul><li>Introduction </li></ul><ul><li>Job Scheduling Versus Process Scheduling </li></ul><ul><li>Process Scheduler </li></ul><ul><li>Process Identification </li></ul><ul><li>Process Status </li></ul><ul><li>Process State </li></ul><ul><li>Accounting </li></ul><ul><li>Process Scheduling Policies </li></ul><ul><li>Process Scheduling Algorithms </li></ul><ul><li>Cache Memory </li></ul><ul><li>Interrupts </li></ul><ul><li>Job Scheduling </li></ul><ul><li>Process Scheduling </li></ul><ul><li>Interrupt Management </li></ul>
  • 2. How Does Processor Manager Allocate CPU(s) to Jobs? <ul><li>Process Manager performs job scheduling, process scheduling and interrupt management. </li></ul><ul><li>In single-user systems , processor is busy only when user is executing a job—at all other times it is idle. </li></ul><ul><ul><li>Processor management is simple. </li></ul></ul><ul><li>In multiprogramming environment , processor must be allocated to each job in a fair and efficient manner. </li></ul><ul><ul><li>Requires scheduling policy and a scheduling algorithm. </li></ul></ul>
  • 3. Some Important Terms <ul><li>Program – inactive unit, such as a file stored on a disk. </li></ul><ul><ul><li>To an operating system, a program or job is a unit of work that has been submitted by user. </li></ul></ul><ul><ul><li>“ Job” is usually associated with batch systems. </li></ul></ul><ul><li>Process (task) – active entity, which requires a set of resources, including a processor and special registers to perform its function. </li></ul><ul><ul><li>A single instance of an executable program . </li></ul></ul>
  • 4. Important Terms - 2 <ul><li>Thread of control (thread) – a portion of a process that can run independently. </li></ul><ul><li>Processor ( CPU, central processing unit) –part of machine that performs calculations and executes programs. </li></ul><ul><li>Multiprogramming requires that the processor be “allocated” to each job or to each process for a period of time and “deallocated” at an appropriate moment. </li></ul>
  • 5. Job Scheduling vs. Process Scheduling <ul><li>Processor Manager has 2 sub-managers: </li></ul><ul><li>Job Scheduler </li></ul><ul><ul><li>in charge of job scheduling. </li></ul></ul><ul><li>Process Scheduler </li></ul><ul><ul><li>in charge of process scheduling. </li></ul></ul>
  • 6. Job Scheduler <ul><li>High-level scheduler. </li></ul><ul><li>Selects jobs from a queue of incoming jobs. </li></ul><ul><li>Places them in process queue (batch or interactive), based on each job’s characteristics . </li></ul><ul><li>Goal is to put jobs in a sequence that uses all system’s resources as fully as possible . </li></ul><ul><li>Strives for balanced mix of jobs with large I/O interaction and jobs with lots of computation. </li></ul><ul><ul><li>Tries to keep most system components busy most of time. </li></ul></ul>
  • 7. Process Scheduler <ul><li>Low-level scheduler – assigns the CPU to execute processes of those jobs placed on ready queue by Job Scheduler. </li></ul><ul><li>After a job has been placed on the READY queue by Job Scheduler, Process Scheduler that takes over. </li></ul><ul><ul><li>Determines which jobs will get CPU, when, and for how long. </li></ul></ul><ul><ul><li>Decides when processing should be interrupted. </li></ul></ul><ul><ul><li>Determines queues job should be moved to during execution. </li></ul></ul><ul><ul><li>Recognizes when a job has concluded and should be terminated. </li></ul></ul>
  • 8. CPU Cycles and I/O Cycles <ul><li>To schedule CPU, Process Scheduler uses common trait among most computer programs: they alternate between CPU cycles and I/O cycles. </li></ul>
  • 9. Poisson Distribution Curve <ul><li>I/O-bound jobs (such as printing a series of documents) have many brief CPU cycles and long I/O cycles. </li></ul><ul><li>CPU-bound jobs (such as finding the first 300 prime numbers) have long CPU cycles and shorter I/O cycles. </li></ul><ul><li>Total effect of all CPU cycles, from both I/O-bound and CPU-bound jobs, approximates a Poisson distribution curve. </li></ul><ul><ul><li>Figure 4.1 </li></ul></ul>
  • 10. Processor Manager : Middle-Level Scheduler <ul><li>In a highly interactive environment there’s a third layer </li></ul><ul><ul><li>called middle-level scheduler . </li></ul></ul><ul><li>Removes active jobs from memory to reduce degree of multiprogramming and allows jobs to be completed faster. </li></ul>
  • 11. Job and Process Status <ul><li>Job status -- one of the 5 states that a job takes as it moves through the system. </li></ul><ul><ul><li>HOLD </li></ul></ul><ul><ul><li>READY </li></ul></ul><ul><ul><li>WAITING </li></ul></ul><ul><ul><li>RUNNING </li></ul></ul><ul><ul><li>FINISHED </li></ul></ul>
  • 12. Job and Process Status I/O or event completion Scheduler dispatch I/O or event wait Admitted Interrupt Exit Finished Handled by Process Scheduler Handled by Job Scheduler Hold Ready Running Waiting
  • 13. Transition Among Process States <ul><li>HOLD to READY : Job Scheduler using a predefined policy. </li></ul><ul><li>READY to RUNNING : Process Scheduler using some predefined algorithm </li></ul><ul><li>RUNNING back to READY : Process Scheduler according to some predefined time limit or other criterion. </li></ul><ul><li>RUNNING to WAITING : Process Scheduler and is initiated by an instruction in the job. </li></ul><ul><li>WAITING to READY : Process Scheduler and is initiated by signal from I/O device manager that I/O request has been satisfied and job can continue. </li></ul><ul><li>RUNNING to FINISHED : Process Scheduler or Job Scheduler. </li></ul>
  • 14. Process Control Block (PCB) <ul><li>Process Control Block (PCB) -- data structure that contains basic info about the job </li></ul><ul><ul><li>Process identification </li></ul></ul><ul><ul><li>Process status (HOLD, READY, RUNNING, WAITING) </li></ul></ul><ul><ul><li>Process state (process status word, register contents, main memory info, resources, process priority) </li></ul></ul><ul><ul><li>Accounting (CPU time, total amount of time, I/O operations, number input records read, etc.) </li></ul></ul>
  • 15. PCBs and Queuing <ul><li>PCB of job created when Job Scheduler accepts it </li></ul><ul><ul><li>updated as job goes from beginning to termination. </li></ul></ul><ul><li>Queues use PCBs to track jobs. </li></ul><ul><ul><li>PCBs, not jobs, are linked to form queues. </li></ul></ul><ul><ul><li>E.g., PCBs for every ready job are linked on READY queue; all PCBs for jobs just entering system are linked on HOLD queue. </li></ul></ul><ul><ul><li>Queues must be managed by process scheduling policies and algorithms. </li></ul></ul>
  • 16. Process Scheduling Policies <ul><li>Before operating system can schedule all jobs in a multiprogramming environment, it must resolve three limitations of system: </li></ul><ul><ul><li>finite number of resources (such as disk drives, printers, and tape drives) </li></ul></ul><ul><ul><li>some resources can’t be shared once they’re allocated (such as printers) </li></ul></ul><ul><ul><li>some resources require operator intervention (such as tape drives). </li></ul></ul>
  • 17. A Good Scheduling Policy <ul><li>Maximize throughput by running as many jobs as possible in a given amount of time. </li></ul><ul><li>Maximize CPU efficiency by keeping CPU busy 100 % of time. </li></ul><ul><li>Ensure fairness for all jobs by giving everyone an equal amount of CPU and I/O time. </li></ul><ul><li>Minimize response time by quickly turning around interactive requests. </li></ul><ul><li>Minimize turnaround time by moving entire jobs in/out of system quickly. </li></ul><ul><li>Minimize waiting time by moving jobs out of READY queue as quickly as possible. </li></ul>
  • 18. Interrupts <ul><li>There are instances when a job claims CPU for a very long time before issuing an I/O request. </li></ul><ul><ul><li>builds up READY queue &amp; empties I/O queues. </li></ul></ul><ul><ul><li>Creates an unacceptable imbalance in the system. </li></ul></ul><ul><li>Process Scheduler uses a timing mechanism to periodically interrupts running processes when a predetermined slice of time has expired. </li></ul><ul><ul><li>suspends all activity on the currently running job and reschedules it into the READY queue. </li></ul></ul>
  • 19. Preemptive &amp; Non-preemptive Scheduling Policies <ul><li>Preemptive scheduling policy interrupts processing of a job and transfers the CPU to another job. </li></ul><ul><li>Non-preemptive scheduling policy functions without external interrupts. </li></ul><ul><ul><li>Once a job captures processor and begins execution, it remains in RUNNING state uninterrupted. </li></ul></ul><ul><ul><li>Until it issues an I/O request (natural wait) or until it is finished (exception for infinite loops). </li></ul></ul>
  • 20. Process Scheduling Algorithms <ul><li>First Come First Served (FCFS) </li></ul><ul><li>Shortest Job Next (SJN) </li></ul><ul><li>Priority Scheduling </li></ul><ul><li>Shortest Remaining Time (SRT) </li></ul><ul><li>Round Robin </li></ul><ul><li>Multiple Level Queues </li></ul>
  • 21. First Come First Served (FCFS) <ul><li>Non-preemptive. </li></ul><ul><li>Handles jobs according to their arrival time -- the earlier they arrive, the sooner they’re served. </li></ul><ul><li>Simple algorithm to implement -- uses a FIFO queue. </li></ul><ul><li>Good for batch systems; not so good for interactive ones. </li></ul><ul><li>Turnaround time is unpredictable. </li></ul>
  • 22. FCFS Example <ul><li>Process CPU Burst (Turnaround Time) </li></ul><ul><li>A 15 milliseconds </li></ul><ul><li>B 2 milliseconds </li></ul><ul><li>C 1 millisecond </li></ul><ul><li>If they arrive in order of A, B, and C. </li></ul><ul><li>What does the time line look like? </li></ul><ul><li>What’s the average turnaround time? </li></ul>
  • 23. Shortest Job Next (SJN) <ul><li>Non-preemptive. </li></ul><ul><li>Handles jobs based on length of their CPU cycle time. </li></ul><ul><ul><li>Use lengths to schedule process with shortest time. </li></ul></ul><ul><li>Optimal – gives minimum average waiting time for a given set of processes. </li></ul><ul><ul><li>optimal only when all of jobs are available at same time and the CPU estimates are available and accurate. </li></ul></ul><ul><li>Doesn’t work in interactive systems because users don’t estimate in advance CPU time required to run their jobs. </li></ul>
  • 24. Priority Scheduling <ul><li>Non-preemptive. </li></ul><ul><li>Gives preferential treatment to important jobs. </li></ul><ul><ul><li>Programs with highest priority are processed first. </li></ul></ul><ul><ul><li>Aren’t interrupted until CPU cycles are completed or a natural wait occurs. </li></ul></ul><ul><li>If 2+ jobs with equal priority are in READY queue, processor is allocated to one that arrived first (first come first served within priority). </li></ul><ul><li>Many different methods of assigning priorities by system administrator or by Processor Manager. </li></ul>
  • 25. Shortest Remaining Time (SRT) <ul><li>Preemptive version of the SJN algorithm. </li></ul><ul><li>Processor allocated to job closest to completion. </li></ul><ul><ul><li>This job can be preempted if a newer job in READY queue has a “time to completion” that&apos;s shorter. </li></ul></ul><ul><li>Can’t be implemented in interactive system -- requires advance knowledge of CPU time required to finish each job. </li></ul><ul><li>SRT involves more overhead than SJN. </li></ul><ul><ul><li>OS monitors CPU time for all jobs in READY queue and performs “context switching”. </li></ul></ul>
  • 26. Context Switching Is Required by All Preemptive Algorithms <ul><li>When Job A is preempted </li></ul><ul><ul><li>All of its processing information must be saved in its PCB for later (when Job A’s execution is continued). </li></ul></ul><ul><ul><li>Contents of Job B’s PCB are loaded into appropriate registers so it can start running again ( context switch ). </li></ul></ul><ul><li>Later when Job A is once again assigned to processor another context switch is performed. </li></ul><ul><ul><li>Info from preempted job is stored in its PCB. </li></ul></ul><ul><ul><li>Contents of Job A’s PCB are loaded into appropriate registers. </li></ul></ul>
  • 27. Round Robin <ul><li>Preemptive. </li></ul><ul><li>Used extensively in interactive systems because it’s easy to implement. </li></ul><ul><li>Isn’t based on job characteristics but on a predetermined slice of time that’s given to each job. </li></ul><ul><ul><li>Ensures CPU is equally shared among all active processes and isn’t monopolized by any one job. </li></ul></ul><ul><li>Time slice is called a time quantum </li></ul><ul><ul><li>size crucial to system performance (100 ms to 1-2 secs) </li></ul></ul>
  • 28. If Job’s CPU Cycle &lt; Time Quantum <ul><li>If job’s last CPU cycle &amp; job is finished, then all resources allocated to it are released &amp; completed job is returned to user. </li></ul><ul><li>If CPU cycle was interrupted by I/O request, then info about the job is saved in its PCB &amp; it is linked at end of the appropriate I/O queue. </li></ul><ul><ul><li>Later, when I/O request has been satisfied, it is returned to end of READY queue to await allocation of CPU. </li></ul></ul>
  • 29. Time Slices Should Be ... <ul><li>Long enough to allow 80 % of CPU cycles to run to completion. </li></ul><ul><li>At least 100 times longer than time required to perform one context switch. </li></ul><ul><li>Flexible -- depends on the system. </li></ul>
  • 30. Multiple Level Queues <ul><li>Not a separate scheduling algorithm. </li></ul><ul><li>Works in conjunction with several other schemes where jobs can be grouped according to a common characteristic. </li></ul><ul><li>Examples: </li></ul><ul><ul><li>Priority-based system with different queues for each priority level. </li></ul></ul><ul><ul><li>Put all CPU-bound jobs in 1 queue and all I/O-bound jobs in another. Alternately select jobs from each queue to keep system balanced. </li></ul></ul><ul><ul><li>Put batch jobs “background queue” &amp; interactive jobs in a “foreground queue”; treat foreground queue more favorably than background queue. </li></ul></ul>
  • 31. Policies To Service Multi-level Queues <ul><li>No movement between queues. </li></ul><ul><li>Move jobs from queue to queue. </li></ul><ul><li>Move jobs from queue to queue and increasing time quantums for “lower” queues. </li></ul><ul><li>Give special treatment to jobs that have been in system for a long time ( aging ). </li></ul>
  • 32. Cache Memory <ul><li>Cache memory -- quickly accessible memory that’s designed to alleviate speed differences between a very fast CPU and slower main memory. </li></ul><ul><li>Stores copy of frequently used data in an easily accessible memory area instead of main memory. </li></ul>
  • 33. Types of Interrupts <ul><li>Page interrupts to accommodate job requests. </li></ul><ul><li>Time quantum expiration. </li></ul><ul><li>I/O interrupts when issue READ or WRITE command. </li></ul><ul><li>Internal interrupts (synchronous interrupts) result from arithmetic operation or job instruction currently being processed. </li></ul><ul><li>Illegal arithmetic operations (e.g., divide by 0). </li></ul><ul><li>Illegal job instructions (e.g., attempts to access protected storage locations). </li></ul>
  • 34. Interrupt Handler <ul><li>Describe &amp; store type of interrupt (passed to user as error message). </li></ul><ul><li>Save state of interrupted process (value of program counter, mode specification, and contents of all registers). </li></ul><ul><li>Process the interrupt </li></ul><ul><ul><li>Send error message &amp; state of interrupted process to user. </li></ul></ul><ul><ul><li>Halt program execution </li></ul></ul><ul><ul><li>Release any resources allocated to job are released </li></ul></ul><ul><ul><li>Job exits the system. </li></ul></ul><ul><li>Processor resumes normal operation. </li></ul>
  • 35. Key Terms <ul><li>aging </li></ul><ul><li>cache memory </li></ul><ul><li>context switching </li></ul><ul><li>CPU-bound </li></ul><ul><li>first come first served </li></ul><ul><li>high-level scheduler </li></ul><ul><li>I/O-bound </li></ul><ul><li>indefinite postponement </li></ul><ul><li>internal interrupts </li></ul><ul><li>interrupt </li></ul><ul><li>interrupt handler </li></ul><ul><li>Job Scheduler </li></ul><ul><li>job status </li></ul><ul><li>low-level scheduler </li></ul><ul><li>middle-level scheduler </li></ul><ul><li>multiple level queues </li></ul><ul><li>multiprogramming </li></ul><ul><li>non-preemptive scheduling policy </li></ul>
  • 36. Key Terms - 2 <ul><li>preemptive scheduling policy </li></ul><ul><li>priority scheduling </li></ul><ul><li>process </li></ul><ul><li>Process Control Block </li></ul><ul><li>Process Scheduler </li></ul><ul><li>process scheduling algorithm </li></ul><ul><li>process scheduling policy process status </li></ul><ul><li>processor </li></ul><ul><li>queue </li></ul><ul><li>response time </li></ul><ul><li>round robin </li></ul><ul><li>shortest job next (SJN) </li></ul><ul><li>shortest remaining time </li></ul><ul><li>synchronous interrupts </li></ul><ul><li>time quantum </li></ul><ul><li>time slice </li></ul><ul><li>turnaround time </li></ul>

×