User Tools

Site Tools


os:semaphores_execution_order
Return to Home page

Semaphores execution order

Return to Operating Systems Course

Which are the possible execution orders of these three threads executed concurrently?

sem_t s1, s2, s3;
sem_init(&s1, 0, 2);	sem_init(&s2, 0, 0);	sem_init(&s3, 0, 0);
 
P1				P2			P3
sem_wait(&s1);			sem_wait(&s2);		sem_wait(&s3);
A;				C;			P;
sem_wait(&s1);			sem_post(&s3);		sem_post(&s1);
B;				sem_wait(&s3);
sem_post(&s2);			E;
sem_wait(&s1);			sem_post(&s1);
F;
sem_post(&s3);
sem_wait(&s1);
G;

Explanation

Solution

ABCPFEG
ABCEFDG

If you found any error, or if you want to partecipate to the editing of this wiki, please contact: admin [at] skenz.it

You can reuse, distribute or modify the content of this page, but you must cite in any document (or webpage) this url: https://www.skenz.it/os/semaphores_execution_order
/web/htdocs/www.skenz.it/home/data/pages/os/semaphores_execution_order.txt · Last modified: 2024/04/08 22:35 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki
Privacy Policy