1 (* Copyright (C) 2005-2020
2 Free Software Foundation, Inc. *)
3 (* This file is part of GNU Modula-2.
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *)
22 FROM Debug IMPORT Halt ;
23 FROM StdIO IMPORT PushOutput ;
24 FROM StrIO IMPORT WriteString, WriteLn ;
25 FROM TimerHandler IMPORT EVENT, TicksPerSecond, Sleep, ArmEvent,
26 Cancel, WaitOn, ReArmEvent ;
27 FROM SYSTEM IMPORT TurnInterrupts ;
28 FROM COROUTINES IMPORT PROTECTION ;
29 FROM Executive IMPORT DESCRIPTOR, InitProcess, Resume, Ps ;
30 FROM SYSTEM IMPORT ADR ;
31 FROM libc IMPORT write, printf ;
42 OldInts := TurnInterrupts (MIN (PROTECTION)) ;
43 printf ("1 second process has come to life\n");
46 Sleep (1*TicksPerSecond) ;
48 printf ("%d seconds\n", n);
57 PROCEDURE FourSeconds ;
61 OldInts := TurnInterrupts (MIN (PROTECTION)) ;
62 printf ("4 seconds process has come to life\n");
65 Sleep (4*TicksPerSecond) ;
67 printf ("4 second alarm (%d occurance)\n", n);
76 PROCEDURE SixSeconds ;
80 OldInts := TurnInterrupts (MAX (PROTECTION)) ;
81 printf ("6 seconds process has come to life\n");
84 Timeout := ArmEvent (6*TicksPerSecond) ;
87 WriteString ('...someone cancelled it...')
90 printf ("6 second alarm (%d occurance)\n", n)
97 StackSize = 0100000H ;
102 OldInts : PROTECTION ;
105 OldInts := TurnInterrupts (MIN (PROTECTION)) ;
106 printf ("got to OS\n") ;
108 printf ("now to create three processes...\n") ;
110 p1 := Resume (InitProcess (OneSecond , StackSize, '1')) ;
111 p4 := Resume (InitProcess (FourSeconds, StackSize, '4')) ;
112 p6 := Resume (InitProcess (SixSeconds , StackSize, '6')) ;
114 Sleep (20*TicksPerSecond) ;
115 printf ("successfully completed, finishing now.\n")