-- Code of Figure 14.11, page 659 from -- Kenneth C. Louden, Programming Languages -- Principles and Practice 2nd Edition -- Copyright (C) Brooks-Cole/ITP, 2003 -- A Semaphore as a task type in Ada83 task type Semaphore is entry initSem (n: in integer); entry wait; entry signal; end; task body Semaphore is count : integer; begin accept initSem (n: in integer) do count := n; end; loop select when count > 0 => accept wait; count := count - 1 ; or accept signal; count := count + 1; or terminate; end select; end loop; end Semaphore;