SlideShare a Scribd company logo
Mutual Exclusion and
Synchronization
Mutual exclusion and synchronization
Mutual exclusion and synchronization
Wikipedia
We have features for every step of the way
Design, organize, and collaborate
Semaphore
                    
                    
                o

                o

            

            

            
Stylize, edit, and animate your media
Broadcast and compress for seamless delivery
semSignal semWait    
semWait                
                wait
                       
                       
Mutual exclusion and synchronization
Mutual exclusion and synchronization
semaphore s=1;

P0 ()               P1 ()
{                   {
  semWait (s);        semWait (s);
   <CS>                <CS>
   semSignal (s);      semSignal (s);
}                   }
Mutual exclusion and synchronization
•


n   •

    •



    15
semaphore s=1;

P0 ()                P1 ()
{                    {
  semWaitB (s);        semWaitB (s);
   <CS>                 <CS>
   semSignalB (s);      semSignalB (s);
}                    }



                                          16
Producer and Consumer

                            •

                            •
                        –
                            •
                        –




                            17
•
    •
–
–

    •
–




    18
producer:                consumer:
while (true)             while (true)
 {                        {
/* produce item v   */    while (in <= out)
   b[in] = v;               /* do nothing */;
   in++
}                          w = b[out];
                           out = (out + 1);
                         /* consume item w */
                         }


                                            19
n



    delay




            (n=1)




            20
21
22
n




wait




           23
y                    x                                        •
                                                                z
    x                        Processes
                                                                    z y
W(z)                         z             n>=0 y              x
 W(y)                   z                n>=0 y           n>=1 x
  W(x)                               z            y            x
                                 z           n>=0 y            x
     <CS>

     S(x)           (n>=0)               z                  z             •
   S(y)                          y                    z
S(z)            x        y                                      y
..
                                                x

                                                                          24
S                                    a              P3 P2 P1             •
S                                             semWait       W semSignal



    P1   P2     P3     P2     P1     P3         P2      P2     P3     P1
W(a)     W(a)   S(a)   W(a)   S(a)   S(a)      W(a)     W(a)   S(a)   W(a)


                                                                              •
                                       P3                       P2 P1         •
                                       P2                       P3 P1         •
                                       P1                       P3 P2         •




                                                                             25
P1    P2    P3     P2     P1     P3     P2    P2    P3      P1

    W(a) W(a)   S(a)   W(a)   S(a)   S(a)   W(a) W(a)   S(a)   W(a)

a    0    -1     0      -1     0      1      0    -1     0      -1


          P2           P2                         P2            P1




                                                               26
27
28
n   n       •
        n
            •

            •


            •
        –




            29
•




30
31
Monitor

              •
              •
              •
          –
          –
          –
              •




              32
33
cwait(c)    •
              c



                  csignal (c)   •
         cwait




wait/signal                     •




                         34
35
•



•



•




36
•




37
mayconsume    •



                capacity
                           •
             mayproduce



mayproduce                 •



                           38

More Related Content

PPT
Lec16 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- Fi...
KEY
App inventor独自カラー
PPTX
Rsa in CTF
PPS
Subtraction
PPT
Lecture28
PPTX
Comparison Of Dengue Cases Between Chosen District In Selangor By Using Fouri...
PPT
dos mutual exclusion algos
PPT
Mutual exclusion
Lec16 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- Fi...
App inventor独自カラー
Rsa in CTF
Subtraction
Lecture28
Comparison Of Dengue Cases Between Chosen District In Selangor By Using Fouri...
dos mutual exclusion algos
Mutual exclusion

Viewers also liked (20)

PDF
8. mutual exclusion in Distributed Operating Systems
PPTX
Réseau sémaphore 7
PDF
Ucepkt winter fdtp broucher
PPTX
Multiprocessing -Interprocessing communication and process sunchronization,se...
PPTX
Mutual Exclusion
PDF
Pbcbt an improvement of ntbcbt algorithm
PDF
Mutual Exclusion in Wireless Sensor and Actor Networks
PPTX
Lecture 4
PPTX
Chapter05 new
PDF
A New Function-based Framework for Classification and Evaluation of Mutual Ex...
PPTX
Multiprocessors(performance and synchronization issues)
PPT
Inter process communication
PPT
Offshore Software Development Company
PPTX
Mutual Exclusion using Peterson's Algorithm
PDF
CS6601 DISTRIBUTED SYSTEMS
PPT
Lamport’s algorithm for mutual exclusion
PPT
Semaphores OS Basics
PPT
Mutual Exclusion Election (Distributed computing)
PDF
Semaphores
PPT
OS Process Synchronization, semaphore and Monitors
8. mutual exclusion in Distributed Operating Systems
Réseau sémaphore 7
Ucepkt winter fdtp broucher
Multiprocessing -Interprocessing communication and process sunchronization,se...
Mutual Exclusion
Pbcbt an improvement of ntbcbt algorithm
Mutual Exclusion in Wireless Sensor and Actor Networks
Lecture 4
Chapter05 new
A New Function-based Framework for Classification and Evaluation of Mutual Ex...
Multiprocessors(performance and synchronization issues)
Inter process communication
Offshore Software Development Company
Mutual Exclusion using Peterson's Algorithm
CS6601 DISTRIBUTED SYSTEMS
Lamport’s algorithm for mutual exclusion
Semaphores OS Basics
Mutual Exclusion Election (Distributed computing)
Semaphores
OS Process Synchronization, semaphore and Monitors
Ad

Recently uploaded (20)

PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
Lesson notes of climatology university.
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
Complications of Minimal Access Surgery at WLH
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
Pharma ospi slides which help in ospi learning
PPTX
master seminar digital applications in india
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Lesson notes of climatology university.
Module 4: Burden of Disease Tutorial Slides S2 2025
Supply Chain Operations Speaking Notes -ICLT Program
Pharmacology of Heart Failure /Pharmacotherapy of CHF
102 student loan defaulters named and shamed – Is someone you know on the list?
Microbial disease of the cardiovascular and lymphatic systems
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Complications of Minimal Access Surgery at WLH
human mycosis Human fungal infections are called human mycosis..pptx
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Pharma ospi slides which help in ospi learning
master seminar digital applications in india
VCE English Exam - Section C Student Revision Booklet
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
Ad

Mutual exclusion and synchronization

Editor's Notes

  • #2: Ahmadniroomand