CS370: Operating Systems [Fall 2018] Dept. of Computer Science, Colorado State University

CS370: Operating Systems [Fall 2018] Dept. of Computer Science, Colorado State University

CS370: Operating Systems [Fall 2018] Dept. Of Computer Science, Colorado State University Frequently asked questions from the previous class survey CS 370: OPERATING SYSTEMS ¨ Could we record burst times in the PCB and use this to inform [CPU SCHEDULING] scheduling? ¨ Could a higher priority process starve? ¨ How is SJF implemented if we don’t know burst times? Shrideep Pallickara Computer Science Colorado State University CS370: Operating Systems [Fall 2018] October 9, 2018 L15.1 CS370: Operating Systems [Fall 2018] L15.2 Dept. Of Computer Science, Colorado State University October 9, 2018 Professor: SHRIDEEP PALLICKARA Dept. Of Computer Science, Colorado State University Topics covered in this lecture ¨ Scheduling Algorithms ¤ Wrap-up of SJF ¤ Priority Scheduling ¤ Round robin scheduling ¤ Lottery scheduling ¤ Multilevel feedback queues ¤ Multiprocessor/core Environments SHORTEST JOB FIRST (SJF) CS370: Operating Systems [Fall 2018] October 9, 2018 CS370: Operating Systems [Fall 2018] L15.3 October 9, 2018 L15.4 Dept. Of Computer Science, Colorado State University Professor: SHRIDEEP PALLICKARA Dept. Of Computer Science, Colorado State University Use of SJF in long term schedulers The SJF algorithm and short term schedulers ¨ Length of the process time limit ¨ No way to know the length of the next CPU burst ¤ Used as CPU burst estimate ¨ So try to predict it ¨ Motivate users to accurately estimate time limit ¨ Processes scheduled based on predicted CPU bursts ¤ Lower value will give faster response times ¤ Too low a value? n Time limit exceeded error n Requires resubmission! October 9, 2018 CS370: Operating Systems [Fall 2018] L15.5 October 9, 2018 CS370: Operating Systems [Fall 2018] L15.6 Professor: SHRIDEEP PALLICKARA Dept. Of Computer Science, Colorado State University Professor: SHRIDEEP PALLICKARA Dept. Of Computer Science, Colorado State University SLIDES CREATED BY: SHRIDEEP PALLICKARA L15.1 CS370: Operating Systems [Fall 2018] Dept. Of Computer Science, Colorado State University Prediction of CPU bursts: α controls the relative weight of recent and past Make estimates based on past behavior history th ¨ tn : Length of the n CPU burst ¨ τn+1 = αtn + (1-α) τn th ¨ τn : Estimate for the n CPU burst ¨ Value of contains our most recent information, while stores ¨ α : Controls weight of recent and past history tn τn the past history ¨ τn+1 = αtn + (1-α) τn j n+1 ¨ τn+1=αtn + (1-α) αtn-1+ ... +(1-α) αtn-j + ... +(1-α) ατ0 ¨ Burst is predicted as an exponential average of the measured lengths of previous CPU bursts ¨ α is less than 1, (1-α) is also less than one ¤ Each successive term has less weight than its predecessor October 9, 2018 CS370: Operating Systems [Fall 2018] L15.7 October 9, 2018 CS370: Operating Systems [Fall 2018] L15.8 Professor: SHRIDEEP PALLICKARA Dept. Of Computer Science, Colorado State University Professor: SHRIDEEP PALLICKARA Dept. Of Computer Science, Colorado State University An example: Predicting the length of the next CPU The choice of α in our predictive equation burst ¨ If α=1/2 ¤ Recent history and past history are equally weighted ¨ With α = ½; successive estimates of τ 4 CPU burst (ti) 6 6 4 13 13 13 t0/2 t0/4 + t1/2 t0/8 + t1/4 + t2/2 t0/16 + t1/8 + t2/4 + t3/2 12 “Guess” (τi) 10 8 6 6 5 9 11 rd ¤ By the 3 estimate, weight of what was observed at t0 has dropped to 1/8. October 9, 2018 CS370: Operating Systems [Fall 2018] L15.9 October 9, 2018 CS370: Operating Systems [Fall 2018] L15.10 Professor: SHRIDEEP PALLICKARA Dept. Of Computer Science, Colorado State University Professor: SHRIDEEP PALLICKARA Dept. Of Computer Science, Colorado State University The choice of α in our predictive equation ¨ τn+1 = αtn + (1-α) τn ¨ If α=0, τn+1= τn ¤ Current conditions are transient ¨ If α=1, τn+1= tn ¤ Only most recent bursts matter ¤ History is assumed to be old and irrelevant PRIORITY SCHEDULING CS370: Operating Systems [Fall 2018] October 9, 2018 CS370: Operating Systems [Fall 2018] L15.11 October 9, 2018 L15.12 Dept. Of Computer Science, Colorado State University Professor: SHRIDEEP PALLICKARA Dept. Of Computer Science, Colorado State University SLIDES CREATED BY: SHRIDEEP PALLICKARA L15.2 CS370: Operating Systems [Fall 2018] Dept. Of Computer Science, Colorado State University Priority Scheduling Depiction of priority scheduling in action Process Burst Time Priority ¨ Priority associated with each process P1 10 3 Here: Lower number means P2 1 1 higher priority ¨ CPU allocated to process with highest priority P3 2 4 ¨ Can be preemptive or nonpreemptive P4 1 5 P5 5 2 ¤ If preemptive: Preempt CPU from a lower priority process when a higher one is ready P2 P5 P1 P3 P4 0 1 6 16 18 19 Wait time = (6 + 0 + 16 + 18 + 1)/5 = 8.2 October 9, 2018 CS370: Operating Systems [Fall 2018] L15.13 October 9, 2018 CS370: Operating Systems [Fall 2018] L15.14 Professor: SHRIDEEP PALLICKARA Dept. Of Computer Science, Colorado State University Professor: SHRIDEEP PALLICKARA Dept. Of Computer Science, Colorado State University How priorities are set Issue with priority scheduling ¨ Internally defined priorities based on: ¨ Can leave lower priority processes waiting indefinitely ¤ Measured quantities ¨ Perhaps apocryphal tale: ¤ Time limits, memory requirements, # of open files, ratio (averages) of I/O to CPU burst ¤ MIT’s IBM 7094 shutdown (1973) found processes from 1967! ¨ External priorities ¤ Criteria outside the purview of the OS ¤ Importance of process, $ paid for usage, politics, etc. October 9, 2018 CS370: Operating Systems [Fall 2018] L15.15 October 9, 2018 CS370: Operating Systems [Fall 2018] L15.16 Professor: SHRIDEEP PALLICKARA Dept. Of Computer Science, Colorado State University Professor: SHRIDEEP PALLICKARA Dept. Of Computer Science, Colorado State University Coping with issues in priority scheduling: Can SJF be thought of as a priority algorithm? Aging ¨ Gradually increase priority of processes that wait for a long ¨ Priority is inverse of CPU burst time ¨ The larger the burst, the lower the priority ¨ Example: ¤ Note: The number we assign to represent priority levels may vary from ¤ Process starts with a priority of 127 and decrements every 15 minutes system to system ¤ Process priority becomes 0 in no more than 32 hours October 9, 2018 CS370: Operating Systems [Fall 2018] L15.17 October 9, 2018 CS370: Operating Systems [Fall 2018] L15.18 Professor: SHRIDEEP PALLICKARA Dept. Of Computer Science, Colorado State University Professor: SHRIDEEP PALLICKARA Dept. Of Computer Science, Colorado State University SLIDES CREATED BY: SHRIDEEP PALLICKARA L15.3 CS370: Operating Systems [Fall 2018] Dept. Of Computer Science, Colorado State University Round-Robin Scheduling ¨ Similar to FCFS scheduling ¤ Preemption to enable switch between processes ¨ Ready queue is implemented as FIFO ¤ Process Entry: PCB at tail of queue ¤ Process chosen: From head of the queue ¨ CPU scheduler goes around ready queue ROUND ROBIN SCHEDULING ¤ Allocates CPU to each process one after the other n CPU-bound up to a maximum of 1 quantum CS370: Operating Systems [Fall 2018] October 9, 2018 L15.19 CS370: Operating Systems [Fall 2018] L15.20 Dept. Of Computer Science, Colorado State University October 9, 2018 Professor: SHRIDEEP PALLICKARA Dept. Of Computer Science, Colorado State University Round Robin: Improving efficiency by increasing Round Robin: Choosing the quantum quantum ¨ Context switch is time consuming ¨ Let’s say quantum is 100 ms and context-switch is 1ms ¤ Saving and loading registers and memory maps ¤ Now wasted time is only 1% ¤ Updating tables ¨ But what if 50 concurrent requests come in? ¤ Flushing and reloading memory cache ¤ Each with widely varying CPU requirements ¨ What if quantum is 4 ms and context switch overhead is 1 ms? ¤ 1st one starts immediately, 2nd one 100 ms later, … ¤ 20% of CPU time thrown away in administrative overhead ¤ The last one may have to wait for 5 seconds! ¤ A shorter quantum would have given them better service October 9, 2018 CS370: Operating Systems [Fall 2018] L15.21 October 9, 2018 CS370: Operating Systems [Fall 2018] L15.22 Professor: SHRIDEEP PALLICKARA Dept. Of Computer Science, Colorado State University Professor: SHRIDEEP PALLICKARA Dept. Of Computer Science, Colorado State University If quantum is set longer than mean CPU burst? Quantum: Summarizing the possibilities ¨ Preemption will not happen very often ¨ Too short? ¤ ¨ Most processes will perform a blocking operation before Too many context switches quantum runs out ¤ Lowers CPU efficiency ¨ Switches happens only when process blocks and cannot continue ¨ Too long? ¤ Poor responses to interactive requests October 9, 2018 CS370: Operating Systems [Fall 2018] L15.23 October 9, 2018 CS370: Operating Systems [Fall 2018] L15.24 Professor: SHRIDEEP PALLICKARA Dept. Of Computer Science, Colorado State University Professor: SHRIDEEP PALLICKARA Dept. Of Computer Science, Colorado State University SLIDES CREATED BY: SHRIDEEP PALLICKARA L15.4 CS370: Operating Systems [Fall 2018] Dept. Of Computer Science, Colorado State University A round-robin analogy ¨ Hyperkinetic student studying for multiple exams simultaneously ¤ If you switch between paragraphs of different textbooks? [Quantum is too short] n You won’t get much done ¤ If you never switch? [Quantum is too long] n You never get around to studying for some of the courses LOTTERY SCHEDULING CS370: Operating Systems [Fall 2018] October 9, 2018 CS370: Operating Systems [Fall 2018] L15.25 October 9, 2018 L15.26 Dept. Of Computer Science, Colorado State University Professor: SHRIDEEP PALLICKARA

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    9 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us