Suppose I have two common variables - aand b- related to each other. When several applications use these common variables, access to them must be an atomic operation, otherwise the connection may be broken. Therefore, to ensure mutual exclusion, I placed their modification in a critical section protected by a lock.
critical_code
{
P(mutex)
a := something
b := something
V(mutex)
}
Suppose my hardware / OS / compiler supports atomic variables. Then I changed my code above as follows.
code
{
atomic a := something
atomic b := something
}
Can this code provide mutual exclusion when accessing multiple applications?
Regards,
Srinivas Nayak
user290273