0
7.3kviews
Describe how the swap() instruction can be used to provide mutual exclusion that satisfies the bounded-waiting requirement.
1 Answer
0
192views
  • process synchronization is a technique which is used to coordinate the process that are using shared data.

  • It is a condition where several processes tries shared data concurrently and outcome of the process depends on the particular order of the execution that leads to data inconsistency and this condition is called as race condition.

  • This condition can be avoided using the technique called as process synchronization in which we allow only one process to enter and manipulate critical section.

  • Critical section problem must satisfy following requirements.

1] Mutual exclusion: No other process is allowed to enter in critical section, if a process in executing in critical section.

2] Progress : When no process in the critical section then any process from outside that request for critical section execution can enter for critical section without any delay, only those process can enter that have requested and have finite time to enter the process.

3] Bounded waiting : An upper bound must exist on the number of times a process enter so that processes are allowed to enter so that other processes are allows to enter their critical section after a process has made a request to enter its critical section and before the request is granted.

4] Process synchronization handled by two approach.

1) S/W Approach – uses Boolean variable flag.

2) HID Approach – uses lock & unlock technique.

Hardware Approach :

  • The hardware approach of synchronization can be done through lock and unlock technique.

  • Locking part is done in entry system so that only one process is allowed to enter into critical section.

  • After it complete its execution, the process is moved to exit section, where unlock operation is done so that other process on the lock section can repeat this process in the lock section can repeat this process of execution. This process is designed in such a way that all the three conditions of the critical section are satisfied.

  • Test-and-set operation – This allows Boolean value (T/F) as a hardwork synchronization, which is atomic in mature i.e. no other interrupt is allowed to accessed. This is mainly used in mutual exclusion operation/application. Similar type of operation can achieved through compare and swap function.

  • In this process a variable is allowed to access in critical section while its lock operation is ON and fill then other process is in BUSY waiting state, hence critical section requirement are achieved.

d0,

{

Waiting [i] = TRUE ; Key = TRUE

While (waiting [i] & & Key ) ; key = swap (clock, & key);

Waiting [i] = FALSE

/* critical section * /

J = (I + 1) % n ;

While ((j ! = I ) & & ! waiting [j])

J – (j + 1 ) % n ;

If (j = = 1) lock = FALSE;

Else

Waiting [j] = FALSE

/ * Remainder Section 1* /

}

While (TRUE)

Please log in to add an answer.

Continue reading...

The best way to discover useful content is by searching it.

Search