Computer Science OS Question: A synchronization mechanism consists of 2 atomic r
ID: 3694337 • Letter: C
Question
Computer Science OS Question:
A synchronization mechanism consists of 2 atomic routines, ENQ(r) and DEQ(r). "r" is a resource variable that has two fields, inuse (boolean) and queue (a queue) which is a queue of processes waiting to acquire the resource. The definitions of ENQ and DEQ are:
ENQ(r) : if (r.inuse==1) then begin
insert current process in r.queue
block
end
else r.inuse = 1;
DEQ(r) : if r.queue == nil then inuse = false
else delete a process from r.queue and activate it.
Construct an implementation of ENQ/DEQ using semaphores. You can use other variables, etc that you need, but no other atomic code or synchronization constructs other than P or V can be used.
Please show work/explain!
Explanation / Answer
The resource is a Semaphore initialized to 1
P(r) = Enq(r)
V(r) = DEQ(r)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.