Bosko Milekic b5b2ea9a46 Plug a race where upon free this scenario could occur:
(time grows downward)
thread 1         thread 2
------------|------------
dec ref_cnt |
            | dec ref_cnt  <-- ref_cnt now zero
cmpset      |
free all    |
return      |
            |
alloc again,|
reuse prev  |
ref_cnt     |
            | cmpset, read
            | already freed
            | ref_cnt
------------|------------

This should fix that by performing only a single
atomic test-and-set that will serve to decrement
the ref_cnt, only if it hasn't changed since the
earlier read, otherwise it'll loop and re-read.
This forces ordering of decrements so that truly
the thread which did the LAST decrement is the
one that frees.

This is how atomic-instruction-based refcnting
should probably be handled.

Submitted by: Julian Elischer
2004-06-10 00:04:27 +00:00
..
2004-04-05 10:17:23 +00:00
2004-06-08 10:37:30 +00:00
2004-05-03 22:54:46 +00:00
2004-06-09 09:41:30 +00:00
2004-02-21 21:10:55 +00:00
2004-04-12 23:02:21 +00:00
2004-02-17 10:21:03 +00:00
2004-03-31 08:20:44 +00:00
2004-04-05 10:17:23 +00:00
2004-05-30 20:34:58 +00:00
2004-05-30 20:34:58 +00:00
2004-05-30 20:34:58 +00:00
2004-02-21 21:10:55 +00:00
2004-06-09 09:41:30 +00:00
2004-05-30 20:34:58 +00:00
2004-05-30 20:34:58 +00:00
2004-06-07 12:19:55 +00:00
2004-05-31 19:06:01 +00:00
2004-06-07 12:19:55 +00:00