gm2
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gm2] GM2 coroutines


From: Gaius Mulley
Subject: Re: [Gm2] GM2 coroutines
Date: Mon, 02 Mar 2009 20:32:07 +0000
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux)

Benjamin Kowarsch <address@hidden> writes:

> Hi
>
> Recently I was looking at the status of GM2 again to see if we might be able 
> to
> use it for embedded work under FreeBSD.
>
> From a paper by Gaius about GM2, it would seem to me that coroutines had been
> implemented using the pthread library. I presume this was an interim shortcut
> since of course coroutines are not meant to be preempted.
>
> For what we do, it is of paramount importance to have true coroutines instead
> of pthreads. Therefore, I am wondering if true coroutines have since been
> implemented, or if not, whether there are any plans to do so.
>
> thanks
> bk

Hi Benjamin,

gm2 still uses GNU Pthreads to implement TRANSFER, NEWPROCESS and
IOTRANSFER (for the PIM dialect of Modula-2).  However it uses the low
level api within GNU PThreads to create contexts, switch contexts.
It maps file descriptors onto a pseudo interrupt vector so that
IOTRANSFER can be implemented.  These low level api calls avoid
invoking the GNU Pthread scheduler.

The low level GNU Pthread calls which are imported into SYSTEM
are:

  pth_uctx_create, pth_uctx_make,
  pth_uctx_save, pth_uctx_switch and pth_init

and it is implemented here:

http://cvs.savannah.gnu.org/viewvc/gm2/gm2-libs-coroutines/SYSTEM.mod?revision=1.10&root=gm2&view=markup&pathrev=MAIN

I've taken a couple of projects I wrote years ago under the Logitech
compiler and rebuilt them using GNU Modula-2 and coroutines for work.
There are some tiny examples here (testtransfer.mod and
testiotransfer.mod):

   http://cvs.savannah.gnu.org/viewvc/gm2/gm2-libs-coroutines/?root=gm2

and some examples of their use in an executive:

   http://cvs.savannah.gnu.org/viewvc/gm2/examples/executive/?root=gm2

hope this helps,
Gaius




reply via email to

[Prev in Thread] Current Thread [Next in Thread]