@utrcgw.utc.com:mark@ardnt1 (mark) (05/07/90)
Hello,
I need help with the correct useage IOTRANSFER within Modula-2 on
an Amiga. For class I am writing a simple scheduler.
What I want to do is basically the following:
From the main program start several processes (actually coroutines).
StartProcess( ProcessOne , Size );
StartProcess( ProcessTwo , Size );
StartProcess( ProcessThree, Size );
and then start scheduling these processes
StartScheduler;
This will start a process called 'Scheduler'. This process will
execute an IOTRANSFER call that transfers execution from whatever
process is currently executing (ProcessOne, ProcessTwo, or ProcessThree)
back to the Scheduler process which will determine which process to execute
next.
I have an Amiga 1000 and am using the TDI compiler (yes I know that there
are better Modula-2 compilers available, but this may be the last class
that requires Modula-2).
The TDI documentation has the syntax of the IOTRANSFER call as follows:
IOTRANSFER( SourceProcess , DestinationProcess , SomeAddress )
Which (as I understand it) will transfer execution from 'SourceProcess'
to 'DestinationProcess' when (and this is what I'm a little fuzzy on)
an interrupt, referenced by 'SomeAddress', occurs.
I have looked through the RKMs but have not found anything (yet?) to help
me on this one.
Listed below is an example of the procedures 'Scheduler' and 'StartScheduler'.
NOTE: The code below is not Amiga code it actually code for an IBM (sorry
for the three letter word) that I would like to modify if possible.
It executes the following lines of code:
IOTRANSFER(op,np,8); <=== transfer from 'op' to 'np' when an
interrupt 8 occurs.
Int8; <=== execute the normal interrupt handler
I would like to do an IOTRANSFER that will transfer from 'op' to 'np' when a
certain amount of time has passed.
ANY SUGGESTIONS ?
SAMPLE CODE ?
USEFUL INFORMATION ?
CHIT-CHAT ?
Please email any help you can give me. Sorry for the length of this
message. Any and all responses are welcome.
Thanks in advance,
Mark
PS: The semester is almost over, so quick responses would be
doubly appreciated.
------------------------------------------------------------------------------
| Mark Stucky | Email: |
| United Technologies Research Center | mark%ardnt1@utrcgw.utc.com |
| East Hartford, CT. | mast%utrc@utrcgw.utc.com |
| Work: (203)727-7343 Home: (203)646-4360 |
------------------------------------------------------------------------------
PROCEDURE Scheduler;
VAR
nextt,
oldt : Task;
op,np : PROCESS;
Int8 : PROC; (* <==== IBM *)
TYPE
code = ARRAY[0..2] OF SHORTCARD; (* <==== IBM *)
CONST
Int8code = code(0CDH,08H,0CBH); (* INT 08H / RETF *) (* <==== IBM *)
BEGIN
DI;
Int8 := PROC(ADR(Int8code)); (* <==== IBM *)
Stop := FALSE;
SchedTime := 0;
LOOP
np := cp^.cor;
LOOP
IOTRANSFER(op,np,8);
Int8; (* <==== IBM *)
INC(SchedTime);
IF Stop THEN EXIT END;
CheckTimeQ;
Slice;
np := cp^.cor;
END;
Stop := FALSE;
TRANSFER(op,np); (* no return until restarted *)
END;
END Scheduler;
PROCEDURE StartScheduler;
VAR
ie : CARDINAL;
BEGIN
ie := GetFlags(); DI;
IF NOT Started THEN
Started := TRUE;
IF SchedStack = NIL THEN (* first time *)
ALLOCATE( SchedStack, 512 );
NEWPROCESS( Scheduler, SchedStack, 512, SchedProc );
END;
TRANSFER( cp^.cor, SchedProc );
END;
SetFlags(ie);
END StartScheduler;