[dev] spinlock implementation

Igor Sysoev is at rambler-co.ru
Sat Aug 16 23:40:32 MSD 2008

On Sat, Aug 16, 2008 at 09:36:21PM +0200, Manlio Perillo wrote:

> Igor Sysoev ha scritto:
> >On Sat, Aug 16, 2008 at 02:09:58PM +0200, Manlio Perillo wrote:
> >
> >>I'm reading the nginx spinlock implementation, since I would like to use 
> >>it in a separate project I'm working on.
> >>
> >>The code is quite simple, however there is a thing I'm not sure to 
> >>unserstand:
> >>why ngx_cpu_pause is called only if Nginx detects that more than 1
> >>cpu are in use?
> >
> >If nginx detects more than 1 CPU, then it tries to acquire lock in short
> >loop. If system has the single CPU then the loop is useless: another
> >process/thead holding the lock does not run at the moment and will not
> >release the lock in nearest future.
> >
> What about a single CPU with hyperthreading enabled?

This is SMP case, i.e. ngx_cpu > 1.

Igor Sysoev

More information about the nginx mailing list