1 / 108

Project 3

Project 3. Part 1: The Sleeping Barber problem Use semaphores and mutex variables for thread synchronization You decide how to test your code!! We ’ re not providing the sample output for this one! Part 2: The Gaming Parlor problem Use monitors and condition variables for synchronization

calix
Download Presentation

Project 3

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Project 3 • Part 1: The Sleeping Barber problem • Use semaphores and mutex variables for thread synchronization • You decide how to test your code!! • We’re not providing the sample output for this one! • Part 2: The Gaming Parlor problem • Use monitors and condition variables for synchronization • Avoid deadlock when handling resource requests • Sample output given in handout

  2. Jonathan Walpole Computer Science Portland State University CS 333Introduction to Operating Systems Class 8 - Scheduling

  3. Process state model New Process Termination Ready Running Blocked

  4. CPU scheduling criteria • CPU Utilization – how busy is the CPU? • Throughput – how many jobs finished/unit time? • Turnaround Time –how long from job submission to job termination? • Response Time – how long (on average) does it take to get a “response” from a “stimulus”? • Missed deadlines – were any deadlines missed?

  5. Scheduler options • Priorities • May use priorities to determine who runs next • Dynamic vs. Static algorithms • Dynamically alter the priority of the tasks while they are in the system (possibly with feedback) • Static algorithms typically assign a fixed priority when the job is initially started. • Preemptive vs. Nonpreemptive • Preemptive systems allow the task to be interrupted at any time so that the O.S. can take over again.

  6. Scheduling policies • First-Come, First Served (FIFO) • Shortest Job First (non-preemptive) • Shortest Job First (with preemption) • Round-Robin Scheduling • Priority Scheduling • Real-Time Scheduling

  7. First-Come, First-Served (FIFO) • Start jobs in the order they arrive (FIFO queue) • Run each job until completion

  8. First-Come, First-Served (FIFO) • Start jobs in the order they arrive (FIFO queue) • Run each job until completion Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

  9. First-Come, First-Served (FIFO) Total time taken, from submission to completion • Start jobs in the order they arrive (FIFO queue) • Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

  10. 0 5 10 15 20 First-Come, First-Served (FIFO) Total time taken, from submission to completion • Start jobs in the order they arrive (FIFO queue) • Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 Arrival Times of the Jobs

  11. 0 5 10 15 20 First-Come, First-Served (FIFO) Total time taken, from submission to completion • Start jobs in the order they arrive (FIFO queue) • Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

  12. 0 5 10 15 20 First-Come, First-Served (FIFO) Total time taken, from submission to completion • Start jobs in the order they arrive (FIFO queue) • Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

  13. 0 5 10 15 20 First-Come, First-Served (FIFO) Total time taken, from submission to completion • Start jobs in the order they arrive (FIFO queue) • Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

  14. 0 5 10 15 20 First-Come, First-Served (FIFO) Total time taken, from submission to completion • Start jobs in the order they arrive (FIFO queue) • Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

  15. 0 5 10 15 20 First-Come, First-Served (FIFO) Total time taken, from submission to completion • Start jobs in the order they arrive (FIFO queue) • Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

  16. 0 5 10 15 20 First-Come, First-Served (FIFO) Total time taken, from submission to completion • Start jobs in the order they arrive (FIFO queue) • Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

  17. 0 5 10 15 20 First-Come, First-Served (FIFO) Total time taken, from submission to completion • Start jobs in the order they arrive (FIFO queue) • Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

  18. 0 5 10 15 20 First-Come, First-Served (FIFO) Total time taken, from submission to completion • Start jobs in the order they arrive (FIFO queue) • Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

  19. 0 5 10 15 20 First-Come, First-Served (FIFO) Total time taken, from submission to completion • Start jobs in the order they arrive (FIFO queue) • Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

  20. 0 5 10 15 20 First-Come, First-Served (FIFO) Total time taken, from submission to completion • Start jobs in the order they arrive (FIFO queue) • Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

  21. 0 5 10 15 20 First-Come, First-Served (FIFO) Total time taken, from submission to completion • Start jobs in the order they arrive (FIFO queue) • Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

  22. 0 5 10 15 20 First-Come, First-Served (FIFO) Total time taken, from submission to completion • Start jobs in the order they arrive (FIFO queue) • Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

  23. 0 5 10 15 20 First-Come, First-Served (FIFO) Total time taken, from submission to completion • Start jobs in the order they arrive (FIFO queue) • Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 0 2 2 6 1 3 4 4 5 4 6 5 7 5 8 2 10

  24. 0 5 10 15 20 First-Come, First-Served (FIFO) Total time taken, from submission to completion • Start jobs in the order they arrive (FIFO queue) • Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 0 3 2 2 6 1 7 3 4 4 5 9 4 6 5 7 12 5 8 2 10 12

  25. Shortest Job First • Select the job with the shortest (expected) running time • Non-Preemptive

  26. 0 5 10 15 20 Shortest Job First • Select the job with the shortest (expected) running time • Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 Same Job Mix

  27. 0 5 10 15 20 Shortest Job First • Select the job with the shortest (expected) running time • Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

  28. 0 5 10 15 20 Shortest Job First • Select the job with the shortest (expected) running time • Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

  29. 0 5 10 15 20 Shortest Job First • Select the job with the shortest (expected) running time • Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

  30. 0 5 10 15 20 Shortest Job First • Select the job with the shortest (expected) running time • Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

  31. 0 5 10 15 20 Shortest Job First • Select the job with the shortest (expected) running time • Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

  32. 0 5 10 15 20 Shortest Job First • Select the job with the shortest (expected) running time • Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

  33. 0 5 10 15 20 Shortest Job First • Select the job with the shortest (expected) running time • Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

  34. 0 5 10 15 20 Shortest Job First • Select the job with the shortest (expected) running time • Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

  35. 0 5 10 15 20 Shortest Job First • Select the job with the shortest (expected) running time • Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

  36. 0 5 10 15 20 Shortest Job First • Select the job with the shortest (expected) running time • Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

  37. 0 5 10 15 20 Shortest Job First • Select the job with the shortest (expected) running time • Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

  38. 0 5 10 15 20 Shortest Job First • Select the job with the shortest (expected) running time • Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

  39. 0 5 10 15 20 Shortest Job First • Select the job with the shortest (expected) running time • Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 0 2 2 6 1 3 4 4 7 4 6 5 9 5 8 2 1

  40. 0 5 10 15 20 Shortest Job First • Select the job with the shortest (expected) running time • Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 0 3 2 2 6 1 7 3 4 4 7 11 4 6 5 9 14 5 8 2 1 3

  41. 0 5 10 15 20 Shortest Remaining Time • Preemptive version of SJF Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 Same Job Mix

  42. 0 5 10 15 20 Shortest Remaining Time • Preemptive version of SJF Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

  43. 0 5 10 15 20 Shortest Remaining Time • Preemptive version of SJF Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

  44. 0 5 10 15 20 Shortest Remaining Time • Preemptive version of SJF Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

  45. 0 5 10 15 20 Shortest Remaining Time • Preemptive version of SJF Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

  46. 0 5 10 15 20 Shortest Remaining Time • Preemptive version of SJF Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

  47. 0 5 10 15 20 Shortest Remaining Time • Preemptive version of SJF Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

  48. 0 5 10 15 20 Shortest Remaining Time • Preemptive version of SJF Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

  49. 0 5 10 15 20 Shortest Remaining Time • Preemptive version of SJF Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

  50. 0 5 10 15 20 Shortest Remaining Time • Preemptive version of SJF Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

More Related