[lkml]   [1996]   [Oct]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: Could this become a race condition?
> extern inline void lock_super(struct super_block * sb)
> {
> if (sb->s_lock)
> __wait_on_super(sb);
> sb->s_lock = 1;
> }
> What happen if two execution threads (particurlarly on a SMP machine)
> check the value of the variable sb->s_lock _at the same time_, and see
> that the value is zero? Both the 2 threads will set this variable to 1,
> and consider that they have the lock on the super_block ?

Kernel threads of code are only pre-empted by interrupts so its safe except
from an interrupt. The SMP kernel only allows one processor in kernel space
at a time so it doesnt arise either.

In future when we take the giant leap and set the kernel up for finer
grained SMP locking your comment will become true.


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