BOTCHAIR@UOGUELPH.BITNET (Alex Bewley) (11/08/87)
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
garon@pedro.UUCP (Garon C. Yoakum) (11/12/87)
In article <INFO-M2%87110722341208@UCF1VM>, BOTCHAIR@UOGUELPH.BITNET (Alex Bewley) writes: > > 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? Personally, I have written such a system with modula/2. Although I don't think it is very practical for normal programming techniques, I do think it works great for object orientated technicques. One of the obvious problems with using interupts for procedure calls in time. Interupts take a lot of time to process. Therefore, I only use them to process actions, exceptions, events, etc. Just in case your interested, here are some of the things my modula/2 scheduler does: 1 - Assignes process' priorities for scheduling 2 - Dynamically allocates/deallocates memory for processes 3 - Dynamically adds/deletes processes There are a few of the reasons why I perfer programming in modula/2. In any of the other many languages I can program in, I would have had to add some assembler subroutines. Thereby limiting maintainabiltiy, portability, and other niceties.