lkml.org 
[lkml]   [2002]   [Jul]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: lock_kernel check...
Zwane Mwaikambo wrote:
> On Tue, 9 Jul 2002, Dave Hansen wrote:
>
>
>>It isn't absoulutely a bad thing to return while you have a lock held.
>> It might be hard to understand, or even crazy, but not immediately
>>wrong :)
>>
>>// BKL protects both "a", and io port 0xF00D
>>bar()
>>{
>> lock_kernel();
>> return inb(0xF00D);
>>}
>>
>>int a;
>>foo()
>>{
>> a = bar();
>> a--;
>> unlock_kernel();
>>}
>
> But broken nonetheless, that kinda thing just looks ugly. Especially when
> someone tries to call bar multiple times or consecutively or with the lock
> already held or...

Yes, it is horribly ugly, but it is not broken. As a function, if you
document what you require your caller to do, there shouldn't be a
problem.

Also, it is valid to have nested holds of the BKL. You can never
deadlock with another lock_kernel() which was done in the same process.

--
Dave Hansen
haveblue@us.ibm.com

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:27    [W:0.041 / U:1.156 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site