Lecture 019

Concurrency Issue

races: outcome depends on arbitrary scheduling decisions deadlock: waiting on each other livelock: going around but with no actual progress starvation/fairness: overall system makes progress but some individuals wait indefinitely

client functions

client functions

flaw

flaw

Approaches for Concurrent Servers

Process-based

process-based: kernel interleaves multiple logical flows, with private address space

process-based

process-based

process-based workflow

process-based workflow

Event-based

event-based: programmer manually interleave logical flows, same address space, I/O multiplexing

Thread-based

thread-based: kernel interleaves multiple logical flows, share address space. Hybrid of process-based and event-based.

thread space

thread space

thread relation

thread relation

thread concurrency

thread concurrency

Pthreads Library

Pthreads: Standard interface for ~60 functions that manipulate threads from C programs

thread workflow

thread workflow

Joinable thread: must be reaped with pthread_join() and killed by other threads

Detached thread: cannot be reaped or killed

Producer-Consumer Model: a model for pass in argument for sub thread

Table of Content