🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #3078

Re: Are Concurrent Processes the same as threads?

#3078
From: Bob Lang 3P21 x3172
Date: Fri, 01 Dec 1995 11:21
45 lines
3143 bytes
On 25 Nov 1995, Arcadio Alivio Sincero wrote:
> I was reading a FAQ on the Modula 3 language, and it said amongst the 
> things it adds to Modula 2 is the support of lightweight processes, or 
> threads.  Now, I thought this functionality was already present in Modula 2.
> [snipped to save space]
> Arcadio

Threads, tasks, whatever *are* present in Modula-2, but in a very primitive
form.  Perhaps a more accurate name is "co-routine".  Like any other
concurrent process, a co-routine has its own program counter (and other 
machine registers) allowing it to pause while another task or co-routine
is running and then pick up where it left off.  However, a co-routine
normally passes control to another co-routine at a specified control change
point.  In modula-2, these are specified by the TRANSFER statement.  The
TRANSFER must also specify *which* co-routine is going to be started.

This sounds fairly limiting, but it is possible to use it as the basis of
a multitasking executive using semaphores.  (I have written an example
executive in MODULA-2 for UNIX - mail me for details if interested).

A major limitation, however, is the integration of existing I/O libraries
and interrupts.  Using (say) InOut.ReadCard will usually cause ALL co-routines
to stop whilst the read takes place - most unsatisfactory.  The only way
around it is to provide a new version of InOut (and all other IO libraries)
so that they are aware of the presence of co-routines and will allow one
co-routine to continue whilst another is paused, waiting for user input.
Mod-2 provides IOTRANSFER which allows the programmer to write interrupt 
handlers in Modula-2.  In principle, this could be used to produce the 
new IO libs required, but life is too short as far as I'm concerned ;-)

IMO, it is a pity that processes/tasks/threads were not integrated into
the language and the I/O libs were not specified as "tasking aware".  This
would have given Mod-2 considerable extra power over the dreaded C-word
language!

Regards

Bob
~    ~~~  ~~~~	    ~~   ~~~  ~~ ~~   ~~  ~~~~~  ~~~~	 __	~~  ~~  ~~~ ~
 ~~~~~~~~~   ~~~~~~~~~~~  ~~~~    ~~~~ ~~~~~  ~~~~     _<Zx\	  _ -/       
     Bob Lang	 ~~~~                                	   ||  _-  -/  	_     
~~~~ lr-lang@csm.uwe.ac.uk ~~~~~~~                        // _- -_ -/_- /    
 ~~~ University of the West Of England	 ~~~~          	 //_- _ - _/- =/     
					~~~~~  ~~~~~~~~ (_-_-_- =_-===_/ ~~~~~
~~~ ~~~~~~~~~~ ~~~~~~  ~~~~~~~~~   ~~~~~~~ ~~~~~~~ ~~~~~~~  ~~~~~  ~~~~~~~ ~~
Technical Details
Message-ID: <1995Dec1.112121.4341@pat.uwe.ac.uk>
Path: arc1-ca.pugleaf.net!bath.ac.uk!uwe-bristol!sister!lr-lang
References: <497qmr$3sf@cville-srv.wam.umd.edu> <Pine.ULT.3.91.951127130941.20362A-100000@bert.cs.byu.edu>

Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.modula2
Path: arc1-ca.pugleaf.net!bath.ac.uk!uwe-bristol!sister!lr-lang
From: lr-lang@csm.uwe.ac.uk (Bob Lang 3P21 x3172)
Subject: Re: Are Concurrent Processes the same as threads?
Message-ID: <1995Dec1.112121.4341@pat.uwe.ac.uk>
Sender: usenet@pat.uwe.ac.uk (uwe nntp usenet poster)
Nntp-Posting-Host: usenet@pat.uwe.ac.uk (uwe nntp usenet poster)
Organization: University of the West of England.
X-Newsreader: xrn 7.04-beta-2
References: <497qmr$3sf@cville-srv.wam.umd.edu> <Pine.ULT.3.91.951127130941.20362A-100000@bert.cs.byu.edu>
Date: Fri, 1 Dec 1995 11:21:21 GMT