D
dm
Guest
Hello, folks!
Consider following code, please:
--- 8< ---
// create semaphore with empty bucket
semaphore MySemaphore = new();
....
fork
begin : A
// blocks "A" thread
MySemaphore.get(1);
// ... critical section ...
MySemaphore.put(1);
end
begin : B
#1; disable A;
end
join
--- >8 ---
(1) fork-join thread "A" is blocked here with get() method -- because
there is unsufficient number of keys in the bucket (note, that in case
of multiple requests after this one -- that blocked the process
execution -- they are placed into FIFO waiting queue)
(2) after 1 time unit passes, thread "A" is disabled
According to the LRM, disabled block just immediately jumps to its
end. The question is: what is correct behavior for waiting FIFO?
-----------waiting-FIFO---------
| 4 | 3 | 2 | 1 |
| | | | |
| | | disab| |
--------------------------------
get() should be:
1) removed from the waiting FIFO
or
2) kept in the FIFO -- when execution will enter to "A" thread again,
it will immediately go to the "blocked place"?
Consider following code, please:
--- 8< ---
// create semaphore with empty bucket
semaphore MySemaphore = new();
....
fork
begin : A
// blocks "A" thread
MySemaphore.get(1);
// ... critical section ...
MySemaphore.put(1);
end
begin : B
#1; disable A;
end
join
--- >8 ---
(1) fork-join thread "A" is blocked here with get() method -- because
there is unsufficient number of keys in the bucket (note, that in case
of multiple requests after this one -- that blocked the process
execution -- they are placed into FIFO waiting queue)
(2) after 1 time unit passes, thread "A" is disabled
According to the LRM, disabled block just immediately jumps to its
end. The question is: what is correct behavior for waiting FIFO?
-----------waiting-FIFO---------
| 4 | 3 | 2 | 1 |
| | | | |
| | | disab| |
--------------------------------
get() should be:
1) removed from the waiting FIFO
or
2) kept in the FIFO -- when execution will enter to "A" thread again,
it will immediately go to the "blocked place"?