Subject: Re: pkg/10704
To: Simon Burge <simonb@wasabisystems.com>
From: Nathan J. Williams <nathanw@MIT.EDU>
List: port-alpha
Date: 02/14/2001 00:15:33
Simon Burge <simonb@wasabisystems.com> writes:

> The other option is to implement TAS as a syscall on mips (as at
> least Ultrix does).  I put in a half-hearted attempt in the past
> to make a generic MI atomic interface - maybe the ``solution'' for
> now is a MIPS-only sysarch() call...

There is another option, which is to implement a restartable region of
code for a program. I don't have the paper reference handy; I'll dig
it out at work tomorrow..

Basically, you implement test-and-set in software, and tell the kernel
where the start and end of the routine is. When a process returns to
usesrpace from the kernel, it checks if the PC is in that range, and
if so, sets it back to the beginning of the range. This provides
mutual exclusion semantics among programs on a uniprocessor system.

The results in the paper that describe this claim that it's actually
faster than native atomic test-and-set instructions on many
processors, because you only take a hit in the rare case of being
preempted in a very short section of code.

Of course, you're still screwed in the MP case, and it does add code
to the common-case kernel exit routine, so it's not a complete
no-brainer (or maybe you could do something like the
syscall_plain/fancy dance for userret() to only take the hit on
processes that want this? Hmm...).

        - Nathan