home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!uunet.ca!ohrd!twriter
- From: twriter@rd.hydro.on.ca (Timothy Writer)
- Subject: Re: Give me safe C++
- Message-ID: <1992Dec17.235544.5983@rd.hydro.on.ca>
- Reply-To: twriter@rd.hydro.on.ca
- Organization: "Ontario Hydro - Research Division"
- References: <Bz2nDF.7B6@fiu.edu> <1992Dec12.145403.26483@ucc.su.OZ.AU> <1992Dec14.190553.14838@mole-end.matawan.nj.us> <1992Dec17.192301.23525@ucc.su.OZ.AU>
- Date: Thu, 17 Dec 92 23:55:44 GMT
- Lines: 91
-
- maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
-
- >In article <1992Dec14.190553.14838@mole-end.matawan.nj.us> mat@mole-end.matawan.nj.us writes:
-
- > [stuff deleted]
-
- > Next, I feel NO language has addressed the concept
- >of coroutines (except possibly Simula?). C provides
- >no simple exchange of control mechanism, although one
- >has to admit they can be emulated using objects in C++.
- >Yet many machines provide this facility, usually via
- >some exchange and link instruction.
-
- There was (is) a language called Concurrent Euclid which was invented at
- the University of Toronto some years ago. In my opinion, it addressed
- the problem of concurrency (coroutines) quite effectively. Euclid is
- based on Turing, another University of Toronto language with strong
- similarities to Pascal. To Turing, Euclid added monitors and processes.
- A process is simply a coroutine. Monitors encapsulate critical data and
- the procedures for manipulating them. As only one procedure is aloud to
- execute "in" a monitor, critical data is prevented from being
- simultaneously accessed by multiple procedures.
-
- Here is a very silly example. I forget much of the syntax but it
- illustractes the basic idea.
-
- counter : Monitor
-
- var count : integer = 0
-
- procedure up()
- begin
- count = count + 1
- end
-
- procedure down()
- begin
- count = count - 1
- end
-
- precedure print()
- begin
- put(count)
- end
-
- end Monitor
-
- process up()
- begin
- counter.up
- counter.print
- end
-
- process down()
- begin
- counter.down
- counter.print
- end
-
- When the program starts up it immediately creates two processes
- (coroutines) up and down. The output might look something like this.
-
- 1
- 2
- 3
- 2
- 3
- 4
- 3
- 2
- 1
- 0
- -1
- 0
- ...
-
- Euclid also provides a means of synchronizing processes using signals
- and conditions although I don't remember enough to describe it.
-
- Although there are strong similarities between Euclid and Pascal,
- Euclid is quite flexible. In fact, I believe the same team that
- implemented Euclid also built an implementation of UNIX, called TUNIS,
- written entirley in Euclid.
-
- Tim
-
- --
- Tim Writer phone: (416) 231-4111 ext. 6990
- Ontario Hydro Research Division fax: (416) 237-9285
- Toronto, Ontario e-mail: twriter@rd.hydro.on.ca
- CANADA
-