Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: 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: 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 Organization: The ARPA Internet Lines: 47 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