Article View: comp.lang.modula2
Article #3933Code for thought
From: Alex Bewley
Date: Sun, 08 Nov 1987 03:14
Date: Sun, 08 Nov 1987 03:14
47 lines
2089 bytes
2089 bytes
This is just an idea off the top of my head, and haven't really considered
if it would be possible. So, I'm going to ask all of you.
As you all know, one can create processes in Modula-2. Suppose you were to
design a system that was totally process oriented (ie. each procedure was
made into a process). Could you make a time scheduler process (run with
IOTRANSFER off the system clock) to switch other processes (ie. force them
to switch) giving each one equal cpu time? Here's some sample (may not work)
code.
...
ProcessList = ARRAY [0..10] OF PROCESS;
...
PROCEDURE TimeScheduler;
BEGIN
IOTRANSFER(TimeSchedule,ProcessList[i],1Ch); (* pc timer interrupt *)
IF clockticks = thisamount THEN
INC(i):
TRANSFER(ProcessList[i-1],ProcessList[i]);
END;
END TimeScheduler;
PROCEDURE A; BEGIN SimpleTerm.WriteString("Hi there - A"); END A;
PROCEDURE B; BEGIN SimpleTerm.WriteString("Hi there - B"); END B;
PROCEDURE C; BEGIN SimpleTerm.WriteString("Hi there - C"); END C;
BEGIN
...
NEWPROCESS(Ap,ADR(workspace),SIZE(workspace),A);
ProcessList[0] := Ap;
...
NEWPROCESS(TimeSchedule, ADR(workspace), SIZE(workspace), TimeScheduler);
TRANSFER(mainP, TimeSchedule);
...
END;
The code is far from grammitically correct, but hopefully you get the idea.
Suppose task switching is not possible this way. How would one go about
doing it in Modula-2.
Alex Bewley
BOTCHAIR@UOGUELPH
Technical Details
Message-ID:
<INFO-M2%87110722341208@UCF1VM>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!rutgers!ames!ucbcad!ucbvax!UOGUELPH.BITNET!BOTCHAIRShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!rutgers!ames!ucbcad!ucbvax!UOGUELPH.BITNET!BOTCHAIR From: BOTCHAIR@UOGUELPH.BITNET (Alex Bewley) Newsgroups: comp.lang.modula2 Subject: Code for thought Message-ID: <INFO-M2%87110722341208@UCF1VM> Date: Sat, 7-Nov-87 22:14:37 EST Article-I.D.: UCF1VM.INFO-M2%87110722341208 Posted: Sat Nov 7 22:14:37 1987 Date-Received: Tue, 10-Nov-87 05:11:23 EST Sender: daemon@ucbvax.BERKELEY.EDU Reply-To: Info-Modula2 Distribution List <INFO-M2%UCF1VM.bitnet@jade.berkeley.edu> Organization: The ARPA Internet Lines: 47