27.10.2014 Views

Cracking the Coding Interview, 4 Edition - 150 Programming Interview Questions and Solutions

Cracking the Coding Interview, 4 Edition - 150 Programming Interview Questions and Solutions

Cracking the Coding Interview, 4 Edition - 150 Programming Interview Questions and Solutions

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Solutions</strong> to Chapter 18 | Threads <strong>and</strong> 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!