X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=mart%2Fex03%2Fexplanations.txt;h=5ae580a421aa2d6e50defcb4479bd4b01a901818;hb=684df3dff41d6b109bf1733ac75c347f27afa464;hp=f53474f8fd37ac531876d839cc89c7a4462fca52;hpb=6ef9df24af633025d2a8501f9ea50deedb95e1c9;p=des2015.git diff --git a/mart/ex03/explanations.txt b/mart/ex03/explanations.txt index f53474f..5ae580a 100644 --- a/mart/ex03/explanations.txt +++ b/mart/ex03/explanations.txt @@ -2,5 +2,12 @@ Since the first task is started first the main loop halts until it's finished. 3b. +This works because the semaphore queue is FIFO. So the first one locks the +semaphore to update the global variable, the second task also wants to do this +but he has to wait in the queue and will be the next in line. After the first +task releases the semaphore the second task locks it and the first task has to +line up in the queue again. This goes on, tasks taking turns, till the tasks +are finished. 3c. +Using semaphore, we can start task that has higher priority than the others. As we can see from the output, the order of the task is based on its priority.