====== Week 5 ====== ~~NOTOC~~ ===== Programming Assignment 2 ===== * UPC Exercises 1.1 through 1.7 * Due: Tue, Feb 17, 11:59pm (tonight!) * Here's a link: [[https://www.cs.vassar.edu/~cs377/private/|private]] ===== Lecture Notes ===== **Semaphores** * Introduced by [[https://en.wikipedia.org/wiki/Edsger_W._Dijkstra|Edsger Dijkstra]] in the mid-1960s * Ben-Ari Ch 6 * slides: {{slides.pdf|PDF}} * begin slide 6.1, p. 105 * Two operations: * wait(s) * Traditional: P(s) * originally: from the Dutch word, //passeren// ("to pass") * later: //prolagen//---formed from the Dutch words //proberen// ("to try") and //verlagen// ("to decrease") * Definition: < await (s > 0) s = s - 1; > * signal(s) * Traditional: V(s) * originally: from the Dutch word, //vrijgeven// ("to release") * later: //verhogen// ("to increase") * Definition: < s = s + 1; > * ''wait(s)'' and ''signal(s)'' work the same for binary and counting (general) semaphores * binary semaphore: value is always either ''1'' or ''0'' * general semaphore: value is nonnegative ** Class exercises ** * The Bear and the Honeybees (handout) {{cs377-bear-honeybees.pdf|PDF}} * try to solve with a single binary semaphore * (discuss) * try using split binary semaphores * where for binary semaphores s1 and s2: 0 <= s1+s2 <= 1 * technique: pass the baton ===== Midterm Programming Assignment ===== * Dining UPC Philosophers {{diningupcphils.pdf |PDF}} * Assigned: Thu, Feb 19 * Due: Tue, Mar 3, 11:59pm (Tue before Spring break)