Thread arguments cont complex parameters can be

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: read Arguments (cont.) Complex parameters can be passed by creating a structure and passing the address of the structure. The structure can't be a local variable (of the function calling pthread_create)!! - threads have different stacks! Thread args example struct { int x,y } two_ints; void *blah( void *arg) { struct two_ints *foo = (struct two_ints *) arg; printf("%u sum of %d and %d is %d\n", pthread_self(), foo->x, foo->y, foo->x+foo->y); return(NULL); } Thread Lifespan Once a thread is created, it starts executing the function func() specified in the call to pthread_create(). If func() returns, the thread is terminated. A thread can also be terminated by calling...
View Full Document

Ask a homework question - tutors are online