| 3348 | |
| 3349 | |
| 3350 | ProcessBase* ProcessManager::dequeue() |
| 3351 | { |
| 3352 | // TODO(benh): Remove a process from this thread's runq. If there |
| 3353 | // are no processes to run, and this is not a dedicated thread, then |
| 3354 | // steal one from another threads runq. |
| 3355 | |
| 3356 | running.fetch_sub(1); |
| 3357 | |
| 3358 | runq.wait(); |
| 3359 | |
| 3360 | // Need to increment `running` before we dequeue from `runq` so that |
| 3361 | // `Clock::settle` properly waits. |
| 3362 | running.fetch_add(1); |
| 3363 | |
| 3364 | //////////////////////////////////////////////////////////// |
| 3365 | // NOTE: contract with the run queue is that we'll always // |
| 3366 | // call `wait` _BEFORE_ we call `dequeue`. // |
| 3367 | //////////////////////////////////////////////////////////// |
| 3368 | return runq.dequeue(); |
| 3369 | } |
| 3370 | |
| 3371 | |
| 3372 | // NOTE: it's possible that a thread not controlled by libprocess is |