sharkey101
sharkey101

Reputation: 1

Violation of mutual exclusion?

I want to know if mutual exclusion is upheld for these 2 process'. Assuming everything is atomic

int ba = 0 , int bt = 0

Process D

    while(true) {
    D1: non critical section
    D2a: if (bt = -1) {
    D2b: ba = -1;
    D2c: } else ( ba = 1)
    D3: while ( ba == bt) {}
    D4: critical section
    D5: ba = 0; }

Process E

    while(true) {
    E1: non critical section
    E2a: if (ba = -1) {
    E2b: bt = 1;
    E2c: } else ( bt = -1)
    E3: while ( bt == -ba) {}
    E4: critical section
    E5: bt = 0; }

Ive been trying to find an execution order where mutual exclusion is not upheld. I tried all different possible orders such as D1 -> D2c, followed by E1 -> E2c and vice versa but it seems like mutex is upheld no matter the order, because of the while loops only one process can enter their critical section at a time while the other waits. Im wondering if Im missing something?

Upvotes: 0

Views: 37

Answers (0)

Related Questions