Open main menu

lensowiki β

Changes

lensowiki:Sandbox

No change in size, 22:34, 24 September 2008
Question 4 - Communicator: testing concurrent editing
==Question 4 - Communicator==
;Implementation:
We recognize the invariant that there will always be an unequal amount of speakers and listeners, because speakers and listeners are almost immediately paired off and return. The S/L on the larger queue will acquire lock, perform their actions, wake opposing queue and immediately return (if they slept they would be put on the end of the queue). S/L on smaller queue will acquire lock, perform their actions, sleep, and once woken up again by opposing queue, return.
 
Special condition for 1 on 1. Use a Boolean flag which indicates a transfer is in progress. The 2nd S/L will set the flag to true, perform its actions and wake the 1st S/L; any intruding 3rd S/L will not attempt to acquire the lock as long as this flag is true—this 3rdSL will sleep in its respective queue. The 1st S/L will be woken up by the 2nd S/L, set the Boolean to false, and return.
;Testing: DO ME.
==Question 5 - Priority Scheduler==
PriorityQueue
Bureaucrats, emailconfirmed, Administrators
436
edits