From 6bd7ddb752a1f49958aeda82acd821a447e301cf Mon Sep 17 00:00:00 2001 From: Marco Realacci Date: Wed, 12 Mar 2025 11:09:27 +0100 Subject: [PATCH] vault backup: 2025-03-12 11:09:27 --- Concurrent Systems/notes/4 - Semaphores.md | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Concurrent Systems/notes/4 - Semaphores.md b/Concurrent Systems/notes/4 - Semaphores.md index d5c6c07..f1a1ebf 100644 --- a/Concurrent Systems/notes/4 - Semaphores.md +++ b/Concurrent Systems/notes/4 - Semaphores.md @@ -101,7 +101,7 @@ B.consume() := B.produce(v) := FREE.down() SP.down() - while not EMPTY[in] do + while not EMPTY[in] do # there is at least an EMPTY cell, otherwise it would have been blocked IN <- (IN+1) mod k i <- IN EMPTY[IN] <- ff @@ -111,5 +111,16 @@ B.produce(v) := BUSY.up() return - +B.consume() := + BUSY.down() + SC.down() + while not FULL[OUT] do + OUT <- (OUT+1) mod k + o <- OUT + FULL[OUT] <- ff + SC.up() + tmp <- BUF[o] + EMPTY[o] <- tt + FREE.up() + return tmp ``` \ No newline at end of file