Skip to content
Snippets Groups Projects
Commit ba7564c3 authored by Florian Schmaus's avatar Florian Schmaus
Browse files

Merge branch 'improve-code-comment' into 'master'

[SemaphoreWorkerSleepStrategy] Improve code comment

See merge request i4/manycore/emper!385
parents 8f8c44f5 6921210c
No related branches found
No related tags found
No related merge requests found
...@@ -135,23 +135,23 @@ class AbstractSemaphoreWorkerSleepStrategy ...@@ -135,23 +135,23 @@ class AbstractSemaphoreWorkerSleepStrategy
[[nodiscard]] inline auto mustNotify() -> bool { [[nodiscard]] inline auto mustNotify() -> bool {
/* On external work we always increment the semaphore unless we observe /* On external work we always increment the semaphore unless we observe
* that its value is > workerCount. * that its value is > workerCount.
* If we observe semValue > workerCount we are ensured that some worker will iterate * If we observe semValue > workerCount we know that some worker will iterate
* its dispatchLoop again and must observe the new work. * its dispatchLoop() again and hence will observe the new work.
*
* For work from within emper we could skip wakeup if we observe no one sleeping. * For work from within EMPER, we could skip wakeup() if we observe no one sleeping.
* This is sound because wakeupSleepingWorkers() is called from a active * This is sound because wakeupSleepingWorkers() is called from a active
* worker which will observe its own new work in its next dispatchLoop before * worker which will observe its own new work in its next dispatchLoop() before
* going to sleep. * going to sleep.
* BUT this supposed not harmful race may not be harmful for guarantying * BUT this supposed not harmful race may not be harmful for guaranteeing
* progress but it is harmfull for latency. * progress but it is harmful for latency.
* Inserting new work in the system races with workers about to sleep * Inserting new work in the system races with workers about to sleep
* actually able to execute the work in a timely manner. * actually able to execute the work in a timely manner.
*
* The overhead of increasing the semaphore "to" much are unnessesary atomic * The overhead of increasing the semaphore "to" much are unnecessary atomic
* operations on global state. This overhead was not measured in contrast to * operations on global state. This overhead was not measured in contrast to
* the harm caused to latency by beeing parsimonious when using the semaphore. * the harm caused to latency by beeing parsimonious when using the semaphore.
*
* Note that sem_getvalue() is allowed to return 0 if there are * Note that sem_getValue() is allowed to return 0 if there are
* waiting workers, hence we need to set the threshold at least to * waiting workers, hence we need to set the threshold at least to
* 0. This has the disadvantage that we will perform one * 0. This has the disadvantage that we will perform one
* unnecessary sem_post. If we are sure the wakeupSem * unnecessary sem_post. If we are sure the wakeupSem
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment