看板 FB_smp 關於我們 聯絡資訊
[please remove -smp from your reply] Once again on the SMP list a lock is being used to make a reference count safe. I'd like to re-raise the issue of a safe reference counting fascility. what would be the semantics? typedef volatile u_int ref_cnt; typedef void ref_free(void *); reference_add(ref_cnt *); reference_drop(ref_cnt *, ref_free *, void *); __inline void reference_add(ref_cnt *cnt) { atomic_inc(cnt); } /* Note I use the non-existing "atomic_inc()". I think we should have this as its SO COMMONLY used. */ __inline void reference_drop(ref_cnt *cnt, ref_free *fn. void * arg) { int newcount; int oldcount; do { newcount = (oldcount = *cnt) - 1; } while (atomic_cmp_and_set(cnt, oldcount, newcount) == ACS_FAILED); } /* I can't remember off the top of my head the cmp-and-set command */ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-smp" in the body of the message