DOC PREVIEW
U of I CS 241 - Scheduling Policies and Introduction to Signals

This preview shows page 1-2-14-15-29-30 out of 30 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 30 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 30 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 30 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 30 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 30 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 30 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 30 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Scheduling Policies and Introduction to SignalsCS241 AdministrativeContent of This LectureReview: Simple Processor Scheduling AlgorithmsReview: First Come First Serve (FCFS)Problems with FCFSWhy Convoy Effects?Exam QuestionInteractive Scheduling AlgorithmsRound-robinRound-robin: ExampleTime QuantumShortest Job First (SJF)Non-preemptive SJF: ExampleComparing to FCFSA Problem with SJFPriority SchedulingPriority Scheduling: ExampleSet PrioritySet/Get Process PriorityIntroduction to SignalsBasic Signal Concept (Definitions)How Signals WorkExamples of POSIX Required SignalsSlide 25Generating SignalsCommand Line Generates SignalsCommand Line Generates SignalsTimers Generate SIGALRM SignalsSummaryCS 241 Spring 2007System Programming 1Scheduling Policies and Introduction to SignalsLecture 14Klara Nahrstedt2CS241 AdministrativeRead Chapter 9. 1, 9.2 Stallings for Scheduling PoliciesRead R&R Chapter 8.1 and 8.2 for Introduction to SignalsSMP4 is ON this week (2/19-2/26)SMP3 Quiz will be on Wednesday (2/21)Regular Quiz will be on Friday (2/23) and it will cover Scheduling, Scheduling Policies and Signals Chapters 9.1-9.2 (S) and Chapters 8.1-8.5 (R&R)3Content of This LectureBasic scheduling algorithmsProblems with FIFO (FCFS)Shortest job firstRound RobinPriority SchedulingGoals:Understand how your program is executed on the machine together with other programsSMP44Review: Simple Processor Scheduling AlgorithmsBatch systemsFirst Come First Serve (FCFS)Shortest Job FirstInteractive SystemsRound RobinPriority Scheduling…5Review: First Come First Serve (FCFS)Process that requests the CPU FIRST is allocated the CPU FIRST. Also called FIFOPreemptive or Non-preemptive?Used in Batch Systems Real life analogy? Fast food restaurantImplementationFIFO queues A new process enters the tail of the queueThe schedule selects from the head of the queue. Performance Metric: Average Waiting Time. Given Parameters: Burst Time (in ms), Arrival Time and Order6Problems with FCFSNon-preemptiveNot optimal AWTCannot utilize resources in parallel:Assume 1 process CPU bounded and many I/O bounded processes result: Convoy effect, low CPU and I/O Device utilization Why?7Why Convoy Effects?Consider n-1 jobs in system that are I/O bound and 1 job that is CPU bound. I/O bound jobs pass quickly through the ready queue and suspend themselves waiting for I/O. CPU bound job arrives at head of queue and executes until complete. I/O bound jobs rejoin ready queue and wait for CPU bound job to complete. I/O devices idle until CPU bound job completes. When CPU bound job completes, other processes rush to wait on I/O again. CPU becomes idle.8Exam QuestionWould FCFS be an Appropriate Scheduling Policy for your Laptop OS? Explain why yes or why not!9Interactive Scheduling AlgorithmsUsually preemptiveTime is sliced into quantum (time intervals)Scheduling decision is also made at the beginning of each quantumPerformance CriteriaMin Response timebest proportionality Representative algorithms:Priority-basedRound-robin…10Round-robin One of the oldest, simplest, most commonly used scheduling algorithmSelect process/thread from ready queue in a round-robin fashion (take turns)Problem:• Do not consider priority• Context switch overhead11Round-robin: ExampleProcess Duration Order Arrival TimeP1 3 1 0P2 4 2 0P3 3 3 00Suppose time quantum is: 1 unit, P1, P2 & P3 never blockP1 P2 P310P1 P2 P3 P1 P2 P3 P2P1 waiting time: 4P2 waiting time: 6P3 waiting time: 6 The average waiting time (AWT): (4+6+6)/3 = 5.3312Time QuantumTime slice too largeFIFO behavior Poor response timeTime slice too smallToo many context switches (overheads) Inefficient CPU utilizationHeuristic: 70-80% of jobs block within time-slice Typical time-slice 10 to 100 ms Time spent in system depends on size of job.13Shortest Job First (SJF)Schedule the job with the shortest elapse time firstScheduling in Batch Systems Two types:Non-preemptivePreemptive (more advanced)Requirement: the elapse time needs to be known in advanceOptimal if all jobs are available simultaneously (provable) Gives the best possible AWT (average waiting time)14Non-preemptive SJF: ExampleProcess Duration Order Arrival TimeP1 6 1 0P2 8 2 0P3 7 3 0P4 3 4 003P4 (3)P1 (6)9P3 (7)16P4 waiting time: 0P1 waiting time: 3P3 waiting time: 9P2 waiting time: 16The total time is: 24The average waiting time (AWT): (0+3+9+16)/4 = 7P2 (8)24Do it yourself15Comparing to FCFSProcess Duration Order Arrival TimeP1 6 1 0P2 8 2 0P3 7 3 0P4 3 4 006P4 (3)P1 (6)14P3 (7)21P1 waiting time: 0P2 waiting time: 6P3 waiting time: 14P4 waiting time: 21The total time is the same.The average waiting time (AWT): (0+6+14+21)/4 = 10.25(comparing to 7)P2 (8)24Do it yourself16A Problem with SJFStarvationIn some condition, a job is waiting for everExample: SJFProcess A with elapse time of 1 hour arrives at time 0But ever 1 minute, a short process with elapse time of 2 minutes arriveResult of SJF: A never gets to runWhat’s the difference between starvation and a dead lock?17Priority SchedulingEach job is assigned a priority. FCFS within each priority level. Select highest priority job over lower ones.Rational: higher priority jobs are more mission-criticalExample: DVD movie player vs. send emailProblems:May not give the best AWTindefinite blocking or starvation a process18Priority Scheduling: ExampleProcess Duration Priority Arrival TimeP1 6 4 0P2 8 1 0P3 7 3 0P4 3 2 008P4 (3) P1 (6)11P3 (7)18P2 waiting time: 0P4 waiting time: 8P3 waiting time: 11P1 waiting time: 18The average waiting time (AWT): (0+8+11+18)/4 = 9.25(worse than SJF)P2 (8)24Do it yourself19Set PriorityEvery process has a default priorityUser can also change a process priorityThe Nice command20Set/Get Process Priority int getpriority(int which, id_t who); int setpriority(int which, id_t who, int value);21Introduction to SignalsWhat is Signal? A signal is a software notification to a process of an event. Why do we need Signals?In systems we need to enable asynchronous eventsExamples of asynchronous events: Email message arrives on my machine – mailing agent (user) process should retrieveInvalid memory access happens – OS should inform scheduler to remove process from the processorAlarm clock goes on – process which sets the alarm should catch it22Basic Signal Concept (Definitions) Signal is generated when the event that causes the signal occurs. Signal is delivered when the process takes action based on the signal. The


View Full Document

U of I CS 241 - Scheduling Policies and Introduction to Signals

Documents in this Course
Process

Process

28 pages

Files

Files

37 pages

File I/O

File I/O

52 pages

C Basics

C Basics

69 pages

Memory

Memory

23 pages

Threads

Threads

14 pages

Lecture

Lecture

55 pages

C Basics

C Basics

24 pages

Signals

Signals

27 pages

Memory

Memory

45 pages

Threads

Threads

47 pages

Threads

Threads

28 pages

LECTURE

LECTURE

45 pages

Threads

Threads

30 pages

Threads

Threads

55 pages

Files

Files

37 pages

SIGNALS

SIGNALS

22 pages

Files

Files

37 pages

Threads

Threads

14 pages

Threads

Threads

13 pages

Load more
Download Scheduling Policies and Introduction to Signals
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Scheduling Policies and Introduction to Signals and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Scheduling Policies and Introduction to Signals 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?