5ae580a421aa2d6e50defcb4479bd4b01a901818
[des2015.git] / mart / ex03 / explanations.txt
1 3a.
2 Since the first task is started first the main loop halts until it's finished.
3
4 3b.
5 This works because the semaphore queue is FIFO. So the first one locks the
6 semaphore to update the global variable, the second task also wants to do this
7 but he has to wait in the queue and will be the next in line. After the first
8 task releases the semaphore the second task locks it and the first task has to
9 line up in the queue again. This goes on, tasks taking turns, till the tasks
10 are finished.
11
12 3c.
13 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.