CSC369H1 Lecture Notes - Lecture 4: Abstract Data Type, Spinlock, Mutual Exclusion

92 views44 pages

Document Summary

Today: final synchronization strategies, sleep locks, condition variables, monitors. *val = old; int val=1; while(val) swap(&val, lock): and more: compare-and-swap (cas), load- linked/store conditional (ll/sc) . Sleep locks: instead of spinning, put thread into blocked state while waiting to acquire a lock, requires a queue for waiting threads, in os/161 this is called a wait channel (thread. c) Locks vs. semaphores: a binary semaphore (with initial value 1) can be used just like a lock, why bother with both abstractions, semantic difference logically, a lock has an. Owner and can only be released by its owner: permits some error checking, helps reason about the correct behavior, let"s look at a synchronization problem . Producer / consumer: classic synchronization problem, think how you would implement a pipe. Consumer() { while(1) { while(1) { write(); read(); This slide is here for the in-class exercise. sem_wait(&mysem); sem_post(&mysem);

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents