CS 4953 Special Studies in Computer Science:
Advanced Topics in Concurrency and Communication Fall 2003
The midterm exam will be open book - USP only.
It will cover the chapters that were discussed in class up to the exam:
- Chapter 9: Times and Timers
- Chapter 12: POSIX Threads
- Chapter 13:Thread Synchronization
- Chapter 14: Critical Sections and Semaphores
- Chapter 15: POSIX IPC
- Chapter 16: Producer Consumer Synchronization
- Chapter 18: Connection-Oriented Communication
- Chapter 20: Connectionless Communication and Multicast
Chapter 9: Times and Timers
- gettimeoffay uses struct timeval: seconds and microseconds since the epoch
- XSI uses struct timeval and struct itimerval: seconds and microseconds
- TMR uses struct timespec and struct itimerspec: seconds and nanoseconds
- Resoultion of timer expiration is not as good as that of getting the time.
- Absolute vs. relative time for periodic timers, timer drift
Chapter 12: POSIX Threads
- One parameter is passed, a pointer to whatever
- Make sure the values passed do not change before the thread can access them.
- A pointer is returned, but it cannot point to automatic storage of the thread.
- Must save the thread ID of each thread if you are going to join them.
- Look at Programs 12.7 and 12.8
Chapter 13: Thread Synchronization
- Mutex locks:
- Usually statically allocated and initialized.
- Use to protect short critical sections.
- Condition Variables: used with a mutex
- pthread_cond_wait is always called in a loop.
- May have spurious wake ups.
- Look at Program 13.13.
- Signal Handling with threads:
- Preferred method:
- block all signals in all threads
- dedicated thread that calls sigwait
- Don't need to worry about async-signal safety
- Look at Program 13.14
Chapter 14 POSIX:SEM semaphores unnamed and named
- unnamed semaphores:
- usually used between threads of a single process
- creation and initialization are done together
- cannot easily be used between processes
- named semaphores:
- may be used between processes or threads
- creation and initialization are done together
- fatal flaw: Cannot twll which ones exist
Chapter 15 POSIX:XSI IPC
- message queues, semaphores and shared memory
- start with a key: IPC_PRIVATE, ftok from path, directly
- use a get routine to get an ID.
- ipcs on the command line will list all
- ipcrm can be used to remove them
- trouble with semaphores: creation and initialization are separate operations.
Chapter 18: Connection-oriented communication
- UICI has three routines: u_open, u_accept, u_connect
- UICI name resolution: addr2name and name2addr
- 4 implementations of name resolution - some are thread safe
Chapter 20: Connectionless communication and multicast