Why is locking a shared data structure important and how do

Why is locking a shared data structure important and how do mutexes and semaphores differ when locking a data structure?

Solution

Why is locking a shared data structure important ? :

When any process reads some data structure it expects that while it reads the data structure, no other process changes it. That is really important for correct execution of the process. Now this is where locking comes in, you put a \"lock\" around the object and start working on it ( read/write ). Now if another process wants to read it, it won\'t be able to and it shouldn\'t be until the lock by first process is removed, and similarly for writing too.

In short, if one process P puts a lock around some data structure, it is ensured by the operating systrem that no other process can read/write that data structure until P removes the lock i.e. until P removes the lock, only P has access to that datastructure

How do mutexes and semaphores differ when locking a data structure?

Mutex can be released only by thread( or process ) that had acquired it. In case of semaphores, any other process can also signal it.

Why is locking a shared data structure important and how do mutexes and semaphores differ when locking a data structure?SolutionWhy is locking a shared data str

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site