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

Re: PAR SKIP or PAR SKIP SKIP ?



Oyvind,

> PROC RESCHEDULE()
>   PAR
>     SKIP
>     -- SKIP -- My add
> :

The INMOS compiler for the transputer (and, hence, KRoC) already has
RESCHEDULE as a compiler-known special PROC.  This is implemented is
transputer ASM and is as efficient as you can get.

If you had to write one yourself in occam, the above code would need
your added second SKIP for the INMOS transputer compiler (and KRoC).
This is because PAR compiles to run its first (n-1) components as new
parallel processes, with the last component as a continuation of the
invoking process.  So:

  PAR
    SKIP

would compile down to:

  SKIP

and not force any reschedule.  Of course, there's nothing to stop cleverer
(future) KRoC compilers compiling the PAR-SKIP-SKIP down to SKIP as well,
so we can't rely on such tricks!  That's why RESCHEDULE is provided as
a compiler-known primitive.  If that sort of thing is needed, maybe it
ought to be an occam keyword?

Incidentally, PAR on its own (with no component processes) is perfectly
legal occam - as is SEQ on its own, IF and ALT.

So, we could apply occam's razor and remove SKIP and STOP from the language!
Instead of SKIP, write PAR (or SEQ).  Instead of STOP, write ALT (or IF).

;-)

Peter.

===========================================================================

#USE "course.lib"  -- just to get the "out.string" routine

PROC just.for.fun (CHAN OF BYTE key, scr, err)
  SEQ
    out.string ("*c*nAbout to RESCHEDULE ()...*c*n", 0, scr)
    RESCHEDULE ()
    out.string ("*c*nAbout to PAR ...*c*n", 0, scr)
    PAR
    out.string ("*c*nAbout to SEQ ...*c*n", 0, scr)
    SEQ
    out.string ("*c*nAbout to ALT ...*c*n", 0, scr)
    ALT                                               -- this is STOP
    out.string ("*c*nAbout to IF ...*c*n", 0, scr)    -- won't get here
    IF                                                -- this is also STOP
: