Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Aug 1997 21:05:26 +0200
From:      Poul-Henning Kamp <phk@critter.dk.tfs.com>
To:        Steve Passe <smp@csn.net>
Cc:        Poul-Henning Kamp <phk@dk.tfs.com>, smp@freebsd.org
Subject:   Re: bug ? 
Message-ID:  <3668.871585526@critter.dk.tfs.com>
In-Reply-To: Your message of "Thu, 14 Aug 1997 12:05:09 MDT." <199708141805.MAA02086@Ilsa.StevesCafe.com> 

next in thread | previous in thread | raw e-mail | index | archive | help

In message <199708141805.MAA02086@Ilsa.StevesCafe.com>, Steve Passe writes:
>Hi,
>
>> 
>> this is from sys/kern/kern_lock.c, isn't line 76 & 77 bogus ?
>> 
>>    64 |  */
>>    65 | int lock_wait_time = 100;
>>    66 | #define PAUSE(lkp, wanted)                                          
>    \
>>    67 |                 if (lock_wait_time > 0) {                           
>    \
>>    68 |                         int i;                                      
>    \
>>    69 |                                                                     
>    \
>>    70 |                         simple_unlock(&lkp->lk_interlock);          
>    \
>>    71 |                         for (i = lock_wait_time; i > 0; i--)        
>    \
>>    72 |                                 if (!(wanted))                      
>    \
>>    73 |                                         break;                      
>    \
>>    74 |                         simple_lock(&lkp->lk_interlock);            
>    \
>>    75 |                 }                                                   
>    \
>>    76 |                 if (!(wanted))                                      
>    \
>>    77 |                         break;
>>    78 | 
>>    79 | #else /* NCPUS == 1 */
>
>I think it's necessary.  In a multiprocessor system there is a chance
>another CPU could grab the lock between lines 73 & 74.  So line 76 is a
>test to guarantee that its still "!(wanted)" after re-acquiring the
>simple_lock.  There is also the possibility that you timeout without getting
>"wanted", line 76 deals with this.

Ok, but what does the "break" break out of ?  

That's where it looks bogus to me...

I also don't understand why you don't check at the top, but always
take a simple_unlock/simple_lock pair, even in the best case situation..

--
Poul-Henning Kamp           | phk@FreeBSD.ORG       FreeBSD Core-team.
http://www.freebsd.org/~phk | phk@login.dknet.dk    Private mailbox.
whois: [PHK]                | phk@tfs.com           TRW Financial Systems, Inc.
Power and ignorance is a disgusting cocktail.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3668.871585526>