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.

Ad esempio:<br />

int A, B;<br />

void * codice(void *){ /*definizione del codice del <strong>thread</strong> */<br />

…}<br />

main()<br />

{p<strong>thread</strong>_t t1, t2;<br />

..<br />

p<strong>thread</strong>_create(&t1,NULL, codice, NULL);<br />

p<strong>thread</strong>_create(&t2,NULL, codice, NULL);<br />

..<br />

}<br />

LinuxThreads: creazione di<br />

<strong>thread</strong>s<br />

‣ Vengono creati due <strong>thread</strong> (di tid t1 e t2) che eseguono le<br />

istruzioni contenute nella funzione codice:<br />

• I due <strong>thread</strong> appartengono allo stesso task (processo) e condividono le<br />

variabili globali del programma che li ha generati (ad esempio A e B).<br />

M-fosset - Sistemi Operativi 2004-2005

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

Saved successfully!

Ooh no, something went wrong!