I managed to grab a semaphore implementation in ksh originally written by
Ed Schaefer and John Spurgeon for UNIX Review in 2004. The original has dissappeared but my slightly fixed copy is available at:
http://www.cs.umb.edu/~rouilj/#Semaphore
In addition to per user seamphores it also supports a queing mechanism to help prevent starvation.
The only current issue with it is that it works only on a single machine,
I have a plan on how to make it work across multiple machines, but that's not implemented yet.
-- rouilj