Thread View: comp.lang.modula2
2 messages
2 total messages
Started by Alex Bewley
Sun, 08 Nov 1987 03:14
Code for thought
Author: 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
Re: Code for thought
Author: Garon C. Yoakum
Date: Wed, 11 Nov 1987 23:31
Date: Wed, 11 Nov 1987 23:31
23 lines
1927 bytes
1927 bytes
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.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads