28.11.2014 Views

System call - Processi, thread

System call - Processi, thread

System call - Processi, thread

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

main ()<br />

{ p<strong>thread</strong>_t th1, th2,th3;<br />

sem_init (&m, 0, 1);<br />

sem_init(&s1,0,1);<br />

sem_init(&s2,0,0);<br />

sem_init(&s3,0,0);<br />

if (p<strong>thread</strong>_create(&th1, NULL, <strong>thread</strong>1_process, NULL) < 0)<br />

{ fprintf (stderr, "p<strong>thread</strong>_create error for <strong>thread</strong> 1\n");<br />

exit (1);<br />

}<br />

if (p<strong>thread</strong>_create(&th2, NULL,<strong>thread</strong>2_process,NULL) < 0)<br />

{ fprintf (stderr, "p<strong>thread</strong>_create error for <strong>thread</strong> 2\n");<br />

exit (1);<br />

}<br />

if (p<strong>thread</strong>_create(&th3,NULL,<strong>thread</strong>3_process, NULL) < 0)<br />

{ fprintf (stderr, "p<strong>thread</strong>_create error for <strong>thread</strong> 3\n");<br />

exit (1);<br />

}<br />

M-fosset - Sistemi Operativi 2004-2005

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!