Attention is currently required from: Julius Werner, Eric Peers, Felix Held. Hello build bot (Jenkins), Julius Werner, Felix Held,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/56230
to look at the new patch set (#5).
Change subject: lib/thread: Add mutex ......................................................................
lib/thread: Add mutex
We need a way to protect shared resources. Since we are using cooperative multitasking the mutex implementation is pretty trivial.
The delays are implemented using a timer queue. So the task with the next expiration date will always be at the beginning of the queue.
If a task (A) wishes to yield control to the next task (B) that is holding onto the mutex, without encountering a delay of its own (i.e., udelay(0)), then we need to ensure the next task (B) is at the head of the queue. We do this by using a `0 us` delay in mutex_lock. If we were to use anything larger than a `0 us` delay, a `udelay(0)` by the task (A) that just unlocked the mutex will most likely not schedule the next task (B) that was holding onto the mutex.
BUG=b:179699789 TEST=Verify thread lock and unlock.
Signed-off-by: Raul E Rangel rrangel@chromium.org Change-Id: Ife1ac95ec064ebcdd00fcaacec37a06ac52885ff --- M src/include/thread.h M src/lib/thread.c 2 files changed, 31 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/30/56230/5