Newsgroups: comp.sys.transputer
From: andyr@wizzy.com (Andy Rabagliati)
Subject: Accessing High Priority timer from a low priority process
Organization: W.Z.I.
Date: Fri, 24 Jun 1994 17:21:41 GMT
Message-ID: <Crww86.CJE@wizzy.com>

The transputer has two process priorities, a high priority that
pre-empts a low priority process.

The clocks run at different rates - High priority ticks once a
microsecond, low priority ticks once every 64 microseconds.

[ An early indication that 32 bits wasn't enough, let alone 16 .. ]

The precision of the high priority clock can be useful in a low priority
process, and the question is "how to get at it?".

With old occam toolsets, I used to do the following :-

INT start, finish, interval :
SEQ
  PRI PAR
    TIMER TIME :
    TIME ? start
    SKIP
  some.thing.very.complicated.that.I.wish.to.time()
  PRI PAR
    TIMER TIME :
    TIME ? finish
    SKIP
  interval := finish MINUS start

But the new toolsets often complain about a nested PRI PAR.

Now what I do is :-

CHAN OF INT TIME :
PRI PAR
  PAR
    TIMER CLOCK :
    INT now :
    WHILE TRUE
      SEQ
        CLOCK ? now
	TIME ! now

    ...  other high priority processes

  PAR
    INT start, finish, interval :
    SEQ
      TIME ? start    -- throw away
      some.thing.very.complicated.that.I.wish.to.time()
      TIME ? start
      TIME ? finish
      interval := finish MINUS start

    ... other low priority processes
    

You should have one high priority CLOCK process per low priority process
needing a high priority clock.

I thought I would share the technique.

Cheers,    Andy.

--
Parallel processing ?                       Sometimes you need a professional
Andy Rabagliati  .  andyr@wizzy.com  .  W.Z.I. Consulting  .  +1.719.635.6099

