tailieunhanh - Lecture Operating systems: Lesson 23 - Dr. Syed Mansoor Sarwar

Lecture Operating systems: Lesson 23 - Dr. Syed Mansoor Sarwar. The main topics covered in this lesson include: busy waiting, new definition of semaphore, process synchronization, deadlock and starvation, binary and counting semaphores, semaphore implementation, problems with semaphores, . | Operating Systems Lecture 23 Syed Mansoor Sarwar Agenda for Today Review of previous lecture Busy waiting New definition of semaphore Process synchronization Deadlock and starvation Binary and counting semaphores Recap of lecture 28 April 2022 Copyright Virtual University of Pakistan Review of Lecture 22 A good hardware based solution Semaphores Semaphore-based solution for the critical section problem Busy waiting 28 April 2022 Copyright Virtual University of Pakistan Busy Waiting Processes wait by executing CPU instructions Problem Wasted CPU cycles Solution Modify the definition of semaphore 28 April 2022 Copyright Virtual University of Pakistan Semaphore Implementation Define a semaphore as a record typedef struct int value struct process L semaphore 28 April 2022 Copyright Virtual University of Pakistan Semaphore Implementation Assume two simple operations block suspends the process that invokes it. wakeup P resumes the execution of a blocked process P. 28 April 2022 Copyright Virtual University of Pakistan Semaphore Implementation The negative value of indicates the number of processes waiting for the semaphore A pointer in the PCB needed to maintain a queue of processes waiting for a semaphore 28 April 2022 Copyright Virtual University of Pakistan Semaphore wait Semaphore operations now defined as void wait semaphore S if lt 0 add this process to block 28 April 2022 Copyright Virtual University of Pakistan Semaphore signal void signal semaphore S if Two Implementations Busy-waiting version is better when critical sections are small and queue-waiting version is better for long critical sections when waiting is for longer periods of time . 28 April 2022 Copyright Virtual University of Pakistan Process Synchronization Execute statement B in Pj only after statement A has been executed in Pi Use semaphore S initialized to 0 Pi Pj A wait S signal S 28 April 2022 B Copyright Virtual University of Pakistan Process .

TỪ KHÓA LIÊN QUAN