25.03.2013 Views

Cracking the Coding Interview - Fooo

Cracking the Coding Interview - Fooo

Cracking the Coding Interview - Fooo

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Solutions to Chapter 18 | Threads and Locks<br />

2 Semaphore s_b(0);<br />

3 Semaphore s_c(1);<br />

4 A {<br />

5 s_c.acquire(1);<br />

6 /***/<br />

7 s_a.release(1);<br />

8 }<br />

9 B {<br />

10 s_a.acquire(1);<br />

11 /****/<br />

12 s_b.release(1);<br />

13 }<br />

14 C {<br />

15 s_b.acquire(1);<br />

16 /******/<br />

17 s_c.release(1);<br />

18 }<br />

2 6 3<br />

<strong>Cracking</strong> <strong>the</strong> <strong>Coding</strong> <strong>Interview</strong> | Knowledge Based

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!