| 1 |
(* Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. *) |
| 2 |
(* This file is part of GNU Modula-2. |
| 3 |
|
| 4 |
This library is free software; you can redistribute it and/or |
| 5 |
modify it under the terms of the GNU Lesser General Public |
| 6 |
License as published by the Free Software Foundation; either |
| 7 |
version 2.1 of the License, or (at your option) any later version. |
| 8 |
|
| 9 |
This library is distributed in the hope that it will be useful, |
| 10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 |
Lesser General Public License for more details. |
| 13 |
|
| 14 |
You should have received a copy of the GNU Lesser General Public |
| 15 |
License along with this library; if not, write to the Free Software |
| 16 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *) |
| 17 |
|
| 18 |
MODULE testiotransfer ; |
| 19 |
|
| 20 |
|
| 21 |
FROM SYSTEM IMPORT ADDRESS, PROCESS, TRANSFER, NEWPROCESS, |
| 22 |
BYTE, LISTEN, IOTRANSFER, ListenLoop ; |
| 23 |
|
| 24 |
FROM COROUTINES IMPORT PROTECTION ; |
| 25 |
FROM RTint IMPORT InitTimeVector, ReArmTimeVector ; |
| 26 |
FROM Storage IMPORT ALLOCATE ; |
| 27 |
FROM libc IMPORT printf, exit ; |
| 28 |
|
| 29 |
CONST |
| 30 |
Debugging = FALSE ; |
| 31 |
|
| 32 |
|
| 33 |
PROCEDURE Timer ; |
| 34 |
CONST |
| 35 |
MaxCount = 1000 ; |
| 36 |
VAR |
| 37 |
v: CARDINAL ; |
| 38 |
c: CARDINAL ; |
| 39 |
BEGIN |
| 40 |
printf ('clock starting\n') ; |
| 41 |
v := InitTimeVector (500, 0, MAX (PROTECTION)) ; |
| 42 |
c := 0 ; |
| 43 |
LOOP |
| 44 |
INC (c) ; |
| 45 |
IF Debugging |
| 46 |
THEN |
| 47 |
printf ('about to call IOTRANSFER: %d\n', c) |
| 48 |
END ; |
| 49 |
IOTRANSFER (p2, p1, v) ; |
| 50 |
IF Debugging |
| 51 |
THEN |
| 52 |
printf ('back from IOTRANSFER: %d\n', c) |
| 53 |
END ; |
| 54 |
ReArmTimeVector (v, 500, 0) ; |
| 55 |
IF Debugging |
| 56 |
THEN |
| 57 |
printf ('ReArmed timer: %d\n', c) |
| 58 |
END ; |
| 59 |
IF c = MaxCount |
| 60 |
THEN |
| 61 |
printf ("%d IOTRANSFERs successfully completed\nexit 0\n", c) ; |
| 62 |
exit (0) |
| 63 |
END |
| 64 |
END |
| 65 |
END Timer ; |
| 66 |
|
| 67 |
|
| 68 |
CONST |
| 69 |
MaxStack = 16 * 1024 * 1024 ; |
| 70 |
|
| 71 |
VAR |
| 72 |
s1, s2 : ADDRESS ; |
| 73 |
p1, p2 : PROCESS ; |
| 74 |
BEGIN |
| 75 |
(* exit (1) ; *) (* disable test for now. *) |
| 76 |
ALLOCATE (s1, MaxStack) ; |
| 77 |
ALLOCATE (s2, MaxStack) ; |
| 78 |
NEWPROCESS (Timer, s2, MaxStack, p2) ; |
| 79 |
printf ('now to TRANSFER...\n') ; |
| 80 |
TRANSFER (p1, p2) ; |
| 81 |
printf ('now to LISTEN\n') ; |
| 82 |
ListenLoop |
| 83 |
(* |
| 84 |
LOOP |
| 85 |
LISTEN |
| 86 |
END |
| 87 |
*) |
| 88 |
END testiotransfer. |