1 / 108

OS Project: Sleeping Barber & Gaming Parlor Solutions

This project involves solving the Sleeping Barber and Gaming Parlor problems using semaphores, mutex variables, monitors, and condition variables for thread synchronization and avoiding deadlock.

Download Presentation

OS Project: Sleeping Barber & Gaming Parlor Solutions

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. CS510 Operating System Foundations Jonathan Walpole

  2. 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

  3. Scheduling

  4. Process State Model New Process Termination Ready Running Blocked

  5. 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 does it take to get a response • Missed deadlines

  6. Broad Classes of Scheduler • Priority-based? • Threads have priorities • Priorities can be assigned statically or dynamically • Preemptive? • Threads can be switched at any time

  7. Example 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

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

  9. First-Come, First-Served (FIFO) Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

  10. First-Come, First-Served (FIFO) Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

  11. 0 5 10 15 20 First-Come, First-Served (FIFO) 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

  12. 0 5 10 15 20 First-Come, First-Served (FIFO) 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) 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) 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) 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) 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) 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) 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) 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) 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) 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) 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) Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

  24. 0 5 10 15 20 First-Come, First-Served (FIFO) 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

  25. 0 5 10 15 20 First-Come, First-Served (FIFO) 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

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

  27. 0 5 10 15 20 Shortest Job First 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

  28. 0 5 10 15 20 Shortest Job First 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 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 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 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 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 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 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 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 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 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 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 Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2

  40. 0 5 10 15 20 Shortest Job First 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

  41. 0 5 10 15 20 Shortest Job First 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

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

  43. 0 5 10 15 20 Shortest Remaining Time 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 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 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 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 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 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 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 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