Note: Multithreaded Programming

####Creating POSIX Threads

pthread_create

####Structure pointer approach

P46

####Passing arguments to threads

  1. copy all arguments to the thread’s stack: isn’t supported in either POSIX or Win-32
  2. pass a pointer to local storage: should make sure this storage doesn’t go out of scope until the thread is finished with it
  3. pass a pointer to static or global storage: works only if one thread at a time is using the storage
  4. pass a pointer to dynamically allocated storage: works only if we can free the storage exactly when the thread is finished with it

####Threads terminate

####Deadlock conditions

  1. a thread can hold an item while waiting for another
  2. a thread cannot be forced toyield the items it is holding
  3. each container has a finite capacity
  4. a circular wait

####Semaphore

####Conditional variables

####async-signal

####Question

####Bear in mind

  1. it’s unsafe to make more than 1 call to pthread_join on any particular thread
  2. for each call to pthread_create there should be exactly one call to either pthread_join or pthread_detach.
  3. pthread_cleanup_push must match exactly with pthread_cleanup_pop

####Notes during db assignment

Your Comments

comments powered by Disqus