thread specific resources each thread has its own

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: 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 pthread_create( pthread_t *tid, 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. positiv...
View Full Document

Ask a homework question - tutors are online