How does one implement mutex on a single processor system without using spinlock mechanism. Mutex is to be implemented in user space (for any user level library like pthread lib for example).
On a single processor system a spin lock won't work at all. There's only one processor so if that one processor tries to acquire a locked mutex, it will start spinning, and there will be no other processor available to unlock the mutex. The processor will be stuck spinning forever.
Rather on a single processor system one needs to use two other techniques. First, if the mutex is supposed to protect some data structure during interrupt handlers, then you achieve mutual exclusion simply by turning off interrupts during the critical section.
For mutexes used for "normal" threads when a thread (let's call it "A") tries to acquire a mutex and finds it locked, it calls into the scheduler which selects some other thread(s) to run for a while before retrying to run thread A. This can actually be viewed as a form of spinning (test the lock, find it busy, call the scheduler to run some other thread, eventually come back to me, test the lock again, and so on ...). So a slightly more sophisticated approach is to associate a queue with each mutex. When thread A tries to acquire the mutex and finds it locked, it places itself on the queue associated with the mutex, then calls the scheduler, which selects some other thread(s) to run for a while. Eventually one of those other threads unlocks the mutex. At that point the thread that unlocked the mutex removes thread A from the queue and places thread A in the schedulers "ready-to-run" list. Eventually the scheduler will decide to run thread A again, thread A will again try to acquire the mutex, and (unless someone else has locked the mutex in the meantime) will find it unlocked this time.