WITH Ada.Text_IO; WITH Screen; PROCEDURE Columns IS ------------------------------------------------------------------ --| Shows tasks writing into their respective columns on the --| screen. This will not always work correctly, because if the --| tasks are time-sliced, one task may lose the CPU before --| sending its entire "message" to the screen. This may result --| in strange "garbage" on the screen. --| Author: Michael B. Feldman, The George Washington University --| Last Modified: December 1995 ------------------------------------------------------------------ TASK TYPE SimpleTask (Message: Character; HowMany: Screen.Height; Column: Screen.Width) IS -- This specification provides a "start button" entry. ENTRY StartRunning; END SimpleTask; TASK BODY SimpleTask IS BEGIN -- SimpleTask -- Each task will write its message in its own column ACCEPT StartRunning; FOR Count IN 1..HowMany LOOP Screen.MoveCursor(To=>(Row => Count, Column => Column)); Ada.Text_IO.Put(Item => "Hello from Task " & Message); DELAY 0.5; -- lets another task have the CPU END LOOP; END SimpleTask; -- Now we declare three variables of the type Task_A: SimpleTask(Message => 'A', HowMany => 5, Column => 1); Task_B: SimpleTask(Message => 'B', HowMany => 7, Column => 26); Task_C: SimpleTask(Message => 'C', HowMany => 4, Column => 51); BEGIN -- Columns Screen.ClearScreen; Task_B.StartRunning; Task_A.StartRunning; Task_C.StartRunning; END Columns;