●。 pthread create() Process A Thread 1 Global pthread create() Variables Code Process a Thread 2 Stack Stack SIE NTUT. Taiwan
11 CSIE, NTUT, Taiwan Process A Thread 1 Global Variables Code Stack Process A Thread 2 Stack pthread_create() pthread_create()
pthread create() o The return value is o for oK nonzero error number on error. o Thread id is returned in tid SIE NTUT. Taiwan
12 CSIE, NTUT, Taiwan pthread_create() The return value is 0 for OK. nonzero error number on error. Thread ID is returned in tid
●。 Thread ds o Each thread has a unique id, a thread can find out it's id by calling pthread selfo o Thread IDs are of type pthread t which is usually an unsigned int. When debugging it's often useful to do something like this printf("Threadu: n",pthread self()i 13 SIE NTUT. Taiwan
13 CSIE, NTUT, Taiwan Thread IDs Each thread has a unique ID, a thread can find out it's ID by calling pthread_self(). Thread IDs are of type pthread_t which is usually an unsigned int. When debugging it's often useful to do something like this: printf("Thread%u:\n",pthread_self());
●●。 Thread arguments o When func( )is called, the value arg specified in the call to pthread create() is passed as a parameter O Func()can have only I parameter, and it can 't be larger than the size of a void 14 SIE NTUT. Taiwan
14 CSIE, NTUT, Taiwan Thread Arguments When func() is called, the value arg specified in the call to pthread_create() is passed as a parameter. Func() can have only 1 parameter, and it can't be larger than the size of a void *