Messages in this thread | | | From | roy rosen <> | Date | Sat, 18 Jun 2016 15:17:50 +0300 | Subject | Description of complete() is either misleading or there is a bug |
| |
The Description says "Threads will be awakened in the same order in which they were queued." Reading this the programmer may thing that it implies that the first thread to get to wait_for_completion_timeout would also be the first thread to proceed and this is incorrect, at least at the following scenario:
thread A calls wait_for_completion_timeout and goes to sleep. when complete is called it wakes up and completes execution of timeout = action(timeout); in function do_wait_for_common. Now lets say that another thread B calls wait_for_completion_timeout. now x->done is 1 so this thread sets x->done to 0 and goes on with its execution. Now thread A continues its execution, it goes to the next line:
} while (!x->done && timeout);
and goes back to sleep. And so thread B executed first although thread A started waiting first.
So either the Description is wrong or the implementation of wait_for_completion_timeout and the functions it calls is wrong.
| |