cpu scheduling ii
play

CPU Scheduling - II Process Synchronization Tevfik Ko ar - PDF document

CSC 4103 - Operating Systems Roadmap Spring 2008 Multilevel Feedback Queues Estimating CPU bursts Lecture - VII CPU Scheduling - II Process Synchronization Tevfik Ko ar Louisiana State University January 12 th , 2008 1 2


  1. CSC 4103 - Operating Systems Roadmap Spring 2008 • Multilevel Feedback Queues • Estimating CPU bursts Lecture - VII CPU Scheduling - II • Process Synchronization Tevfik Ko � ar Louisiana State University January 12 th , 2008 1 2 Multilevel Queue Multilevel Queue Scheduling • Ready queue is partitioned into separate queues: foreground (interactive) background (batch) • Each queue has its own scheduling algorithm – foreground – RR – background – FCFS • Scheduling must be done between the queues – Fixed priority scheduling; (i.e., serve all from foreground then from background). Possibility of starvation. – Time slice – each queue gets a certain amount of CPU time which it can schedule amongst its processes; i.e., 80% to foreground in RR – 20% to background in FCFS 3 4 Example of Multilevel Feedback Queue Multilevel Feedback Queue • A process can move between the various queues; • Three queues: aging can be implemented this way – Q 0 – RR with time quantum 8 milliseconds • Multilevel-feedback-queue scheduler defined by – Q 1 – RR time quantum 16 milliseconds the following parameters: – Q 2 – FCFS – number of queues • Scheduling – scheduling algorithms for each queue – A new job enters queue Q 0 which is served FCFS. When it gains – method used to determine when to upgrade a process CPU, job receives 8 milliseconds. If it does not finish in 8 – method used to determine when to demote a process milliseconds, job is moved to queue Q 1 . – method used to determine which queue a process will – At Q 1 job is again served FCFS and receives 16 additional enter when that process needs service milliseconds. If it still does not complete, it is preempted and moved to queue Q 2 . 5 6

  2. Determining Length of Next CPU Burst Multilevel Feedback Queues • Can only estimate the length • Can be done by using the length of previous CPU bursts, using exponential averaging + 7 8 Examples of Exponential Averaging Exercise • � =0 – � n+1 = � n – Recent history does not count • � =1 – � n+1 = � t n – Only the actual last CPU burst counts • If we expand the formula, we get: � n +1 = � t n +(1 - � ) � t n -1 + … +( 1 - � ) j � t n - j + … +( 1 - � ) n +1 � 0 • Since both � and (1 - � ) are less than or equal to 1, each successive term has less weight than its predecessor 9 10 Prediction of the Length of the Next CPU Burst Process Synchronization Alpha = 1/2, T0 = 10 11 12

  3. Background Producer • Concurrent access to shared data may result in data while (true) inconsistency /* produce an item and put in nextProduced • Maintaining data consistency requires mechanisms while (count == BUFFER_SIZE) to ensure the orderly execution of cooperating ; // do nothing processes buffer [in] = nextProduced; • Consider consumer-producer problem: in = (in + 1) % BUFFER_SIZE; – Initially, count is set to 0 count++; – It is incremented by the producer after it produces a new buffer } – and is decremented by the consumer after it consumes a buffer. 13 14 Consumer Race Condition • count++ could be implemented as while (1) register1 = count register1 = register1 + 1 { count = register1 while (count == 0) • count-- could be implemented as register2 = count ; // do nothing register2 = register2 - 1 count = register2 nextConsumed = buffer[out]; out = (out + 1) % BUFFER_SIZE; • Consider this execution interleaving with “count = 5” initially: count--; S0: producer execute register1 = count {register1 = 5} S1: producer execute register1 = register1 + 1 {register1 = 6} /* consume the item in nextConsumed S2: consumer execute register2 = count {register2 = 5} } S3: consumer execute register2 = register2 - 1 {register2 = 4} S4: producer execute count = register1 {count = 6 } S5: consumer execute count = register2 {count = 4} 15 16 Summary Acknowledgements • “Operating Systems Concepts” book and supplementary Hmm. • Multilevel Feedback Queues material by A. Silberschatz, P . Galvin and G. Gagne • Estimating CPU bursts . • Process Synchronization • “Operating Systems: Internals and Design Principles” book and supplementary material by W. Stallings • “Modern Operating Systems” book and supplementary material by A. Tanenbaum • Next Lecture: Process Synchronization • Reading Assignment: Chapter 6 from Silberschatz. • R. Doursat and M. Yuksel from UNR 17 18

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend