This preview shows page 1. Sign up to view the full content.
Unformatted text preview: ecific Resources
Each thread has it’s own:
Thread ID (integer)
Stack, Registers, Program Counter
errno (if not - errno would be useless!) Threads within the same process can
communicate using shared memory.
Must be done carefully! Posix Threads
We will focus on Posix Threads - most widely
supported threads programming API.
Solaris - you need to link with “-lpthread”
On many systems this also forces the
compiler to link in re-entrant libraries (instead
of plain vanilla C libraries). Thread Creation
const pthread_attr_t *attr,
void *(*func)( void *),
void *arg); func is the function to be called.
When func() returns the thread is terminated. pthread_create()
The return value is 0 for OK.
View Full Document
- Spring '08