Teaching‎ > ‎CS350 Spring 2009 TF‎ > ‎

2009-04-10

posted Apr 10, 2009, 11:03 AM by Site Admin Role
  • Singly linked list based stack, single thread.
  • Creating 32 producer and 32 consumer threads. Use pthread_create() to start threads. Each thread routine must look like this: void *thread_main(void *arg) {...}, i.e. takes one void * argument and returns a void * value.
  • Use pthread_join() to wait until another thread finishes.
  • What is causing the double-free error?
  • Establishing critical section using pthread mutex.
    • Entry code: pthread_mutex_lock()
    • Exit code: pthread_mutex_unlock()
    • Mutex needs to be initialized using pthread_mutex_init() before use, and destroyed with pthread_mutex_destroy() when no longer needed.
  • The "volatile" keyword for variables prevents compiler optimization from erroneously retaining value of memory location when it could be changed outside of the current control flow. Dekker's and Peterson's algorithm all need to use the volatile keyword in order to compile correctly.
  • See that the multi-threaded program actually saturates CPU on an 8 processor AMD Opteron machine.
ċ
stack_mt_test.c
(4k)
Site Admin Role,
Apr 10, 2009, 12:35 PM
Comments