[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gm2] (no subject)
From: |
Gaius Mulley |
Subject: |
Re: [Gm2] (no subject) |
Date: |
Sat, 04 Jan 2003 10:31:09 +0000 |
Abi Lover <address@hidden> writes:
> In Modula-2 there are a couple of language constructs which enable you set
> up several co-routines and make them run (or appear to run)concurrently:
> they are NEWPROCES and TRANSFER. They are also very useful to enable you to
> mimic some real life situations. Is there anything equivalent to this in C
> or C++? As far as I know there didn't used to be, but GCC has added many new
> extensions to C and C++, and I don't know enough about them to know whether
> this is included. If it is not, how would you implement such a code in C or
> C++?
for both of these languages one could use threads, specifically the GNU pthread
library can be used to mimic this behaviour.
>
> I have attached a small program which illustrates the use of this construct
> on Modula-2. This code was written using the old JPI TopSpeed Modula-2,
> running on DOS. It was written by our lecturer to illustrate this principle
> more than 10 years ago, when I was taught M2 at colege for the first time.
> It is a simple program which draws three boxes on the screen: in the first a
> star keeps moving back and forth, in the second the text, "Have a nice day,"
> is constantly scrolling, and in the third you can enter text from the
> keyboard. All three events appear to be hapenning at the same time. Suppose
> you wanted to translate this code into C or C++, how would you do it?
again GNU pthreads - but the interface is not nearly as clean as SYSTEM.mod :-(.
I'm embarking on implementing a SYSTEM.mod to use pthreads in GNU Modula-2 but
while TRANSFER and NEWPROCESS are relatively straightforward, IOTRANSFER is
likely to be limited.
hope this helps,
Gaius