cvs commit: src/sys/kern kern_proc.c

Pawel Jakub Dawidek pjd at FreeBSD.org
Wed Jun 9 19:03:13 GMT 2004


On Wed, Jun 09, 2004 at 11:54:06AM -0700, Julian Elischer wrote:
+> > Ok, I get it now. Even if there will be a race between two threads, i.e.:
+> > 
+> > 	[ref_cnt is 2]
+> > 
+> > 	thread1					thread2
+> > 
+> > 	atomic_substract(obj, 1)
+> > 	[ref_cnt is 1]
+> > 						atomic_substract(obj, 1)
+> > 						[ref_cnt is 0]
+> > 	atomic_cmpset(obj, 0, 1) -> true
+> > 	[do clean up]
+> > 						atomic_cmpset(obj, 0, 1) -> false
+> > 						[skip cleanups]
+> > 
+> > (thread2 sets ref_cnt to 0, but thread1 destroys objects) we free object
+> > only once. Cool, I like it:)
+> 
+> The method shown above has, however the disadvantage of being
+> less than obvious.  ALso thread 2 is likely to get a page fault, which
+> is a less than perfect result..
+> 
+> the reference count must never be read or written after the [cleanup]
+> because  it may free the page on which teh counter is kept.

Right... Nice catch. So Bosko probebly have to rethink his model.

-- 
Pawel Jakub Dawidek                       http://www.FreeBSD.org
pjd at FreeBSD.org                           http://garage.freebsd.pl
FreeBSD committer                         Am I Evil? Yes, I Am!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/cvs-src/attachments/20040609/b0b1d842/attachment.bin


More information about the cvs-src mailing list