Re: Why fput is SMP safe?

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

 



On Sun, Mar 02, 2003 at 03:56:39PM -0500, Haoqiang Zheng wrote:
> I don't understand why fput is SMP safe. It calls atomic_dec_and_test(), if 
> the return value is true, it then directly goes to the clean up section. 
> But after atomic_dec_and_test() (and before the clean up is done), another 
> process can still call fget(). I mean, I doesn't see fput acquire any lock 
> that can prevent fget be executed. Where I am wrong?

You need to take into account, that if atomic_dec_and_test decremented
to zero, no other pointer to the file exists, so noone can call fget
beyond that point.

-------------------------------------------------------------------------------
						 Jan 'Bulb' Hudec <bulb@ucw.cz>
--
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