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.

• Creazione di <strong>thread</strong>s:<br />

#include <br />

int p<strong>thread</strong>_create(p<strong>thread</strong>_t *<strong>thread</strong>,p<strong>thread</strong>_attr_t *attr,<br />

void *(*start_routine)(void *), void * arg);<br />

• Dove:<br />

• <strong>thread</strong>: e` il puntatore alla variabile che raccogliera` il <strong>thread</strong>_ID (PID)<br />

• start_routine: e` il puntatore alla funzione che contiene il codice del<br />

nuovo <strong>thread</strong><br />

• arg: e` il puntatore all’eventuale vettore contenente i parametri della<br />

funzione da eseguire<br />

• attr: puo` essere usato per specificare eventuali attributi da associare al<br />

<strong>thread</strong> (di solito: NULL):<br />

• ad esempio parametri di scheduling: priorita` etc.(solo per superuser!)<br />

• Legame con gli altri <strong>thread</strong>s (ad esempio: detached o no)<br />

• Ritorna : 0 in caso di successo, altrimenti un<br />

codice di errore (!=0)<br />

M-fosset - Sistemi Operativi 2004-2005<br />

LinuxThreads

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

Saved successfully!

Ooh no, something went wrong!