Question

In: Computer Science

Q3) Explain; how the synchronization mechanism (semaphores) can be used, to ensure a correct access to...

Q3) Explain; how the synchronization mechanism (semaphores) can be used, to ensure a
correct access to exclusive resources.

Solutions

Expert Solution

A semaphore can control the access of a exclusive resource through the use of a counter. If the counter value is greater than 0, then the process can access the resource, otherwise it has to wait untill the other processes does not free up the resource.
For example, let say there is a resource that can be shared by 2 processes at a time but not a third one.
So, we will set the initial value of the semaphore to 2. The first process that requests for the resource will be able to use it, and it will reduce the value of this semaphore to 1.
Now, the second process that requests for the same resource will also reduce the value of the semaphore to 0.
If a third process requests for the resource, it will not be able to execute because the semaphore value is not greater than 0.
This process can only execute when one of the above processes release the resource and thus increase the value of semaphore.

This is how semaphore ensure a correct access to exclusive resources.

Hope this helps. Please rate the answer if you like it.
Do leave a comment. Any suggestion/query is much appreciated.


Related Solutions

How can you ensure that all access to effective and equitable activities? Give at least six...
How can you ensure that all access to effective and equitable activities? Give at least six examples (200 words total)
Explain in few sentences how atomic swap is implemented for synchronization.
Explain in few sentences how atomic swap is implemented for synchronization.
Explain how the healthcare administrator can ensure that inventory management and the material ma... explain how...
Explain how the healthcare administrator can ensure that inventory management and the material ma... explain how the healthcare administrator can ensure that inventory management and the material management cycle is effective (both for patients welfare and the organizations profit margin). Make sure to include the who, what, when, where and why for maintenance of these cycles (i.e. who is in control of these tasks, what tasks are included in these responsibilities, when will they be monitored, why are these cycles...
Describe the mechanism and process of natural selection and how Darwin used it to explain the...
Describe the mechanism and process of natural selection and how Darwin used it to explain the diversity seen in his theory of common descent.
Describe the mechanism and methodology used to ensure that operational needs are met through short-term financing....
Describe the mechanism and methodology used to ensure that operational needs are met through short-term financing. Explain why this methodology is important to a medium sized oil company .
Explain how propeller synchronization system works and also how the Synchrophasing system works. What are the...
Explain how propeller synchronization system works and also how the Synchrophasing system works. What are the benefits?
Which statement is NOT correct? The Virtual storage Access Method a. is used for very large files ..
Which statement is NOT correct? The Virtual storage Access Methoda. is used for very large files that need both direct access and batch processing.b. may use an overflow area for records.c. provides an exact physical address for each record.d. is appropriate for files that require few insertions or deletions. 
Briefly explain how a company can use KPI’s as a monitoring and control mechanism.
Briefly explain how a company can use KPI’s as a monitoring and control mechanism.
Explain how a person with a disability can access and make use of an advocate/advocacy service...
Explain how a person with a disability can access and make use of an advocate/advocacy service to lodge a complaint.
Explain how camels can manage without water in desert? Explain the molecular mechanism. (1 point)
Explain how camels can manage without water in desert? Explain the molecular mechanism. (1 point)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT