V1 READY P2 READY o THE SECOND PROCESS P1 READY V2 READY EXAMPLE Producer

V1 ready p2 ready o the second process p1 ready v2

This preview shows page 28 - 35 out of 79 pages.

V(&1-READY) P(&2-READY) o THE SECOND PROCESS P(&1-READY) V(&2-READY) EXAMPLE (Producer-Consumer) MONITORS A MONITOR IS A PACKAGE ENCAPSULATING PROCEDURES, VARIABLES AND DATA STRUCTURES MONITOR PROCEDURES ARE ALWAYS EXECUTED ONE AT A TIME SO MUTUAL EXCLUSION IS ALWAYS GUARANTEED MONITORS PROCEDURES CAN:
Image of page 28
+ WAIT ON A CONDITION => COND.WAIT + GET A SIGNAL => COND.SIGNAL THE MONITOR BODY IS EXECUTED WHEN A MONITOR IS STARTED (INITIALIZATION CODE) MONITORS EVENTCOUNTS - 3 OPERATIONS: + READ (E) + ADVANCE (E) + AWAIT (E, V) MESSAGE PASSING CLASSICAL SYNCHRONIZATION PROBLEMS A. PRODUCER AND CONSUMER 2 PROCESSES SHARE A COMMON BUFFER WHOSE SIZE IS FIXED PRODUCER PRODUCES ITEMS AND STORES THEM IN BUFFER CONSUMER REMOVES ITEMS FROM BUFFER AND CONSUMES THEM
Image of page 29
PRODUCER AND CONSUMER MUST BE PREVENT FROM ACCESSING THE BUFFER AT THE SAME TIME B) THE READERS-WRITERS PROBLEM 2 TYPES OF PROCESSES: + THE READERS THAT NEED TO ACCESS FILES + THE WRITERS THAT NEED TO UPDATE THEM READERS PROCESSES MUST BE PREVENT FROM ACCESING FILE WHILE SOME WRITER PROCESS UPDATE THEM. WRITERS PROCESSES MUST BE PREVENT FROM ACCESING FILE WHILE ANY OTHER PROCESS ACCESSES THEM. C) THE DINING PHILOSOPHERS FIVE PHILOSOPHERS SIT AT A TABLE. THEY SPEND THEIR TIME THINKING AND EATING SPAGHETTI; THE PROBLEM IS THAT THERE ARE ONLY 5 FORKS.
Image of page 30
A. THE SLEEPING BARBER A BARBER SHP HAS ONE BARBER CHAIR AND ONE BARBER WHO SLEEP WHEN THERE ARE NO COSTUMERS COSTUMERS DO NOT WAIT IF THE SHOP IS FULL DEADLOCK A SET OF PROCESSES IS IN A DEADLOCK STATE WHEN EVERY PROCESS IN THE SET IS WAITING FOR AN EVENT THAT CAN BE CAUSED BY ONLY ANOTHER PROCESS IN THE SET WHEN SEVERAL PROCESSES ARE BLOCKED AND EACH OF THESE PROCESSES IS WAITING FOR A RESOURCE THAT CAN ONLY BE RELEASED BY ANOTHER BLOCKED PROCESS TYPE OF RESOURCE + SERIALLY REUSABLE RESOURCE + CONSUMABLE RESOURCE MODE OF OPERATION + REQUEST
Image of page 31
+ USE + RELEASE DEADLOCK MANAGEMENT + IGNORE THE PROBLEM + DEADLOCK PREVENTION DEADLOCK + DEADLOCK AVOIDANCE NEVER OCCURS + DEADLOCK DETECTION RESOURCE ALLOCATION GRAPH VERTICES + RESOURCES EDGES + REQUEST + PROCESSES + ASSIGNEMENT NECESSARY CONDITION FOR A DEADLOCK FOUR NECESSARY CONDITION THAT MUST BE SIMULTANEOUSLY IN EFFECT
Image of page 32
MUTUAL EXCLUSION (AT LEAST ONE RESOURCE) HOLD AND WAIT CONDITION NON PREEMPTION CIRCULAR WAIT DEADLOCK PREVENTION (DENYING ONE OF THE CONDITIONS) DENYING MUTUAL EXCLUSION DENYING THE WAIT FOR CONDITION o OBTAIN ALL THE RESOURCES BEFORE USING ANY OF THEM, OR o BEFORE IT CAN REQUEST ANY ADDITIONAL RESOURCES, HOWEVER IT MUST RELEASE ALL THE RESOURCE CURRENTLY ALLOCATED DENYING THE NON PREEMPTION CONDITION o ABORT PROCESSES o APPLIED TO RESOURCES WHOSE STATE CAN BE EASILY SAVED AND RESTORED LATER PREVENTING CIRCULAR WAITS o IMPOSE A TOTAL ORDER ON ALL RESOURCES TYPE
Image of page 33
o ALL PROCESS MUST FOLLOW THAT ORDER WHEN THEY ACQUIRE NEW RESOURCES DEADLOCK AVOIDANCE - INFORMATION + THE RESOURCES CURRENTLY AVAILABLE + THE RESOURCES CURRENTLY ALLOCATED + THE FUTURE REQUESTS AND RELEASES SAFE STATE: THE SYSTEM CAN ALLOCATE RESOURCES TO EACH PROCESS (UP TO ITS
Image of page 34
Image of page 35

You've reached the end of your free preview.

Want to read all 79 pages?

  • One '20
  • Virtual memory

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

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors