This is an appendix to Understanding Unix/Linux Programming written for people interested in Ada programming on POSIX systems.

Event-Driven Programming: Writing a Video Game

Section 7.3.1, page 200-203

The first program shows the basic logic of a curses program: hello1.adb.

Compiling and running the program is easy:

% gnatmake -P hello1
% ./hello1

[...] Predict the output of this second example: hello2.adb.

Section 7.4, page 204-206

Animation example 1: hello3.adb

Animation example 2: hello4.adb

Animation example 3: hello5.adb

Section 7.5.2, page 207-210

Note that neither alarm() nor pause() have direct equivalents in POSIX/Ada. To make the functioning of the examples more obvious I have made function Alarm and procedure Pause available in package C_Signals.

[...] We combine these ideas to write the program sleep1.adb.

Section 7.6.1, page 210-211

In Ada the delay statement does the job of both the sleep() and the usleep() function.

Section 7.6.4, page 212-215

The program ticker_demo.adb demonstrates the use of an interval timer.

Section 7.7.3, page 219-222

Compile and run sigdemo3.adb to learn how processes on your system respond to combinations of signals.

Section 7.10, page 229-231

Procedure Send_Signal in package POSIX.Signals sends a signal to a process.

Section 7.11.1, page 231-234

bounce1d.adb: Controlled Animation on a Line

Section 7.11.2, page 234-239

The main program:
The support package: (specification)
bounce.adb (body)

Explorations, page 246

7.3, sigprocmask

Skip this. It is strictly for single threaded programs.

Programming exercises, pages 247-248


You can of course use delay statements also for fine-grained pauses, so there is no need to look into usleep.


[...] (Hint: Read the section Delay Statements, Duration, and Time in the Ada Reference Manual.)


Go to next chapter.

Collected examples:
Based on:
Understanding Unix/Linux Programming, Bruce Molay, ISBN 0-13-008396-8.
Main page:
Written by:
Jacob Sparre Andersen.
Latest update:
19th of April, 2008