[M3devel] dynamic chose between user/kernel threads?

Mika Nystrom mika at async.caltech.edu
Thu Jan 8 09:19:26 CET 2009


Jay writes:
>--_659eacae-e435-4dfa-807c-8eaabce063a9_
>Content-Type: text/plain; charset="iso-8859-1"
>Content-Transfer-Encoding: quoted-printable
>
...
>PROCEDURE Fork()=3D
>BEGIN  IF KernelThreads
>     RETURN ThreadPThread.Fork()=3B
>  ELSE
>     RETURN ThreadPosix.Fork()=3B
>          END=3B
>        END Fork.
...

If it's implemented properly, on many architectures LOCK should be
at most a couple of instructions.  I think adding a couple of
branches to it may make a significant difference.  On those
architectures it really ought to be inlined, too...

Here's the "quick path" for LockMutex under user threads:

      INC (inCritical);
        IF m.holder = NIL THEN
          <* ASSERT self # NIL *>
          m.holder := self;
          DEC (inCritical);
          RETURN;
        END;
 
    Mika



More information about the M3devel mailing list