CS 703 Advanced Operating Systems By Mr Farhan
CS 703 - Advanced Operating Systems By Mr. Farhan Zaidi
Lecture No. 14
Overview of today’s lecture n n n Thread usage paradigms Paper by Hauser et al. Pros and Cons of different paradigms
Uses of threads n To exploit CPU parallelism q n To exploit I/O parallelism q q n Run two CPUs at once in the same program Run I/O while computing, or do multiple I/O Listen to the “window” while also running code, e. g. allow commands during an interactive game For program structuring q E. g. , timers
Paradigms of thread usage (from Hauser et al paper) n n n Defer work General pumps Slack processes Sleepers One-shots n n n Deadlock avoidance Rejuvenation Serializers Encapsulated fork Exploiting parallelism
Defer work n n A very common scenario for thread usage Client may see unexpected response… something client requested is fired off to happen in the background q Forking off examples n n n q a document print operation Updating a window Sending an email message Issue? What if thread hangs for some reason. Client may see confusing behavior on a subsequent request!
Pumps n n n Components of producer-consumer pipelines that take input in, operate on it, then output it “downstream” Value is that they can absorb transient rate mismatches Slack process: a pump used to explicitly add delay, employed when trying to group small operations into batches
Sleepers, one-shots n n These are threads that wait for some event, then trigger, then wait again Examples: q q Call this procedure every 20 ms, or after some timeout Can think of device interrupt handler as a kind of sleeper thread
Deadlock avoiders n Thread created to perform some action that might have blocked, launched by a caller who holds a lock and doesn’t want to wait
Bohr-bugs and Heisenbugs n n n Bruce Lindsey, refers to models of the atom A Bohr nucleas was a nice solid little thing. Same with a Bohr-bug. You can hit it reproducibly and hence can fix it A Heisenbug is hard to pin down: if you localize an instance, the bug shifts elsewhere. Results from non-deterministic executions, old corruption in data structures, etc….
Task rejuvenation n A nasty style of thread q q q Application had multiple major subactivities, such as input handler, renderer. Something awful happened. So create a new instance and pray
Others n Serializers: a queue, and a thread that removes work from it and processes that work item by item q for (; ; ) { get_next_event(); handle_event(); } n n Concurrency exploiters: for multiple CPUs Encapsulated forks: Hidden threads used in library packages
- Slides: 12