From: Arnt Gulbrandsen (agulbra@flipper.pvv.unit.no)
Date: 05/28/93


From: agulbra@flipper.pvv.unit.no (Arnt Gulbrandsen)
Subject: Re: Thread Package for Linux
Date: 28 May 1993 15:36:26 GMT

In article <1993May28.093047.4261@swan.pyr> iiitac@swan.pyr (Alan Cox) writes:
>In article <1993May27.224157.13041@kf8nh.wariat.org> bsa@kf8nh.wariat.org (Brandon S. Allbery) writes:
>>Last time I looked at System V semaphores, they were a nightmare to use. Are
>>Linux's semaphores better in this respect? If not, then maybe we need a
>>simpler semaphore package to make this worth doing. But since the "philos"
>>demo source doesn't look *that* horrid, maybe they'll do.
>
>Linux copies the sys5 ipc. It works its horrid and maybe the wheel should
>have been re-invented to be round instead of square in this case.
>
>The lightweight threads share memory space so I suspect judicious use
>of 386/486 properties - notably the exchange register and memory instruction
>properties to do spinlocks combined with a signal would work.

The 386 has a nice instruction specifically designed for semaphores;
it will test a byte and then write 1 to it. This instruction, I can't
recall its name, leaves the Z flag nicely set up for a conditional
'block until ebx points to char(0)' call. Three instructions. Of
course, I don't know whether this is how semaphores are currently
implemented.