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.

Esempio:<br />

main ()<br />

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

/* il mutex e` inizialmente libero: */<br />

p<strong>thread</strong>_mutex_init (&M, NULL);<br />

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

{ fprintf (stderr, "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, "create error for <strong>thread</strong> 2\n");<br />

exit (1);<br />

}<br />

p<strong>thread</strong>_join (th1, NULL);<br />

p<strong>thread</strong>_join (th2, NULL);<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!