# Semaphore and Spinlock

Ruben Safir ruben at mrbrklyn.com
Mon Apr 27 10:21:17 EDT 2015

```On 04/27/2015 09:18 AM, Abhishek Bist wrote:
> [ Semaphores are a bit like spinlocks, except the holder of a semaphore is a process, not a CPU. ]
> This is a very first line that is bein written on the description of semaphore on kernel newbies.So what are the different parameter
> that could justify this statement or the way it could be justified and understood.
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>

That is a good question.  In fact, I've been studying semaphores,
spinlocks and Mutexes now for 3 weeks and it still confuses me.  Our
school is working from a text called Operating Systems Concepts 9th
Edition.  It seems to avoid defining things

It should say

Definition:
Semephore
Mutex:
Spinlocks:

and then there is monitors

I have poured over a lot of sample code.  I can show you coding examples
for concurrence protection from race condition, and models for mutexes,
and even describe what a wait queue might look like, but in the end, I'm
still puzzled by this most basic of definition.  A lot of this is the
fault of the book.  They get lost in their own words, research and
thoughts and fail to deliver understand concepts to the student.

Forget operating systems.  Lets say I am writing a book about Bicycles
and the principles of Bicycle design.  And we are going to study wheels.
It makes for very ineffective communication to spend 10 pages
describing that C=2piR and other facts about circle geometry, and the
mathematical calculation of force when applied to a spoke(or a rope)
under tension, et et et and forget to define that a Wheel on a bicycle
is a round hoop, usually covered on the outer rim by a rubber tire, that
makes contact to the road and allows for the bicycle to roll.

```