Re: about reference counter

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

 



> > After that, they canread/write the object at the same time, right? It
> > sounds like only the reference counter is atomic, while the content of
> > the object is not protected. Please correct me if I am wrong.
> 
> Yes, they could both use the object at the same time.  But if you need
> to protect from that, you need a lock, not only a reference count.

So what is the real purpose of using reference counter? It cannot protect other members in the object. Looks like it is only used to check if the object needed to be freed (when the counter is 0)? right? Can you give an example?

Thanks so much,

LML

> 
> > I am still using 2.4 kernel so there is no struct kref, but the
> > principle, which I am not clear, should be the same.
> 
> Feel free to backport kref to 2.4 if it would help you out.
> 
> Hope this helps,
> 
> greg k-h
> 
> --
> Kernelnewbies: Help each other learn about the Linux kernel.
> Archive:       http://mail.nl.linux.org/kernelnewbies/
> FAQ:           http://kernelnewbies.org/faq/

--
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