Re: spinlock on uniprocessor systems

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 1/31/06, pradeep singh <2500.pradeep@xxxxxxxxx> wrote:
> LDD 3rd ed page 115 says
>
>   " Spinlocks are, by their nature, intended for use on multiprocessor
> systems,although a uniprocessor workstation running a preemptive kernel
> behaves like SMP, as far as concurrency is concerned.If a nonpreemptive
> uniprocessor system ever went into a spin on a lock, it would spin forever;
> no other thread would ever be able to obtain the CPU to release the lock.
> For this reason, spinlock operations on uniprocessor systems without
> preemption enabled are optimized to do nothing, with the exception of the
> ones that change the IRQ masking status. "
>
> I want to ask what does it mean by " if a nonpreemptive uniprocessor system
> ever went into a spin on a lock, it would spin forever,no other thread would
> ever be able to obtain the CPU to release the lock "  .
>
> Why is it so? and how ? can someone plz send me a code snippet to explain
> this statement ?
>

Spinlock is a busy-wait lock means that a task will spin at the
spinlock (keep processor busy) until it won't able to acquire it. So
on SMP machine one processor can spin on spinlock and the other one
can release the lock after doing stuff with-in lock and unlock ! Now
if the system is uniprocessor and no preemption is enabled tries to
acquire the lock (which is already acquired by some other process, but
the process must schedule itself after acquiring lock to make this
happen as uniprocessor system without preemption won't allow other
process to execute at the same time) then it will spin on the lock and
won't allow the CPU to give time to the other process which is
supposed to release the lock !

--
Fawad Lateef

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux