Ch 3
Shared memory programming: threads You will learn Create threads Run threads Kill threads Semaphores Race conditions Deadlocks Synchronization issues Control thread execution Debug threaded programs
Concurrent execution Processes compete for the CPU Fork creates processes that compete with each other for the cpu Child gets a copy of parents code Concurrent execution
Threads Operate within the parent process Benefits of threads Improve performance Background tasks Asynchronous processing Improving program structure
Make a multithreaded pgm behave like a sequential one Design Concerns
Set of rules that force a system to behave in a specific way Example: sequential consistency model All events that work on shared memory happen in a 1 at a time order Problematic when combining 2 sequentially consistent events, resulting in inconsistent. Figure 3.6 Example: linearizability Events appear to happen in a one at a time order Appear to take place instantly, done by linearization points (when they take effect) Consistency Model
Implications of linearization points Methods can be totally ordered by linearization points Locking has the effect of taking place instantly as far as others are concerned. Discuss page 68, 69, 70 Implications of linearization points
semaphores
Producer / Consumer