Lec08 - Last Class Synchronization Wrap-up on CPU...

Info icon This preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Computer Science Lecture 8, page 1 CS377: Operating Systems Last Class: Synchronization Wrap-up on CPU scheduling MLFQ and Lottery scheduling Synchronization Mutual exclusion Critical sections Example: Too Much Milk Locks Synchronization primitives are required to ensure that only one thread executes in a critical section at a time. Computer Science Lecture 8, page 2 CS377: Operating Systems Today: Synchronization: Locks and Semaphores More on hardware support for synchronization Implementing locks using disabling interrupts, test&set and busy waiting What are semaphores? Semaphores are basically generalized locks. Like locks, semaphores are a special type of variable that supports two atomic operations and offers elegant solutions to synchronization problems. They were invented by Dijkstra in 1965.
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Computer Science Lecture 8, page 3 CS377: Operating Systems Hardware Support for Synchronization Implementing high level primitives requires low-level hardware support What we have and what we want Concurrent programs Low-level atomic operations (hardware) load/store interrupt disable test&set High-level atomic operations (software) lock semaphore monitors send & receive Computer Science Lecture 8, page 4 CS377: Operating Systems Implementing Locks By Disabling Interrupts There are two ways the CPU scheduler gets control: Internal Events: the thread does something to relinquish control (e.g., I/O). External Events: interrupts (e.g., time slice) cause the scheduler to take control away from the running thread. On uniprocessors, we can prevent the scheduler from getting control as follows: Internal Events: prevent these by not requesting any I/O operations during a critical section. External Events: prevent these by disabling interrupts (i.e., tell the hardware to delay handling any external events until after the thread is finished with the critical section) Why not have the OS support Lock.Acquire() and Lock.Release as system calls?
Image of page 2
Computer Science Lecture 8, page 5 CS377: Operating Systems Implementing Locks by Disabling Interrupts For uniprocessors, we can disable interrupts for high-level primitives like locks, whose implementations are private to the kernel. The kernel ensures that interrupts are not disabled forever, just like it already does during interrupt handling.
Image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern