FreeBSD/lib/libthr/thread/thr_pshared.c
/*
 * Among all processes sharing a lock only one executes
 * pthread_lock_destroy().  Other processes still have the hash and
 * mapped off-page.
 *
 * Mitigate the problem by checking the liveness of all hashed keys
 * periodically.  Right now this is executed on each
 * pthread_lock_destroy(), but may be done less often if found to be
 * too time-consuming.
 */
Among all processes sharing a lock only one executes
pthread_lock_destroy().  Other processes still have the hash and
mapped off-page.

Mitigate the problem by checking the liveness of all hashed keys
periodically.  Right now this is executed on each
pthread_lock_destroy(), but may be done less often if found to be
too time-consuming.
Among all processes sharing a lock only one executes pthread_lock_destroy () . Other processes still have the hash and mapped off - page . Mitigate the problem by checking the liveness of all hashed keys periodically . Right now this is executed on each pthread_lock_destroy () but may be done less often if found to be too time - consuming .
static void
pshared_gc(struct pthread *curthread)
{
	struct pshared_hash_head *hd;
	struct psh *h, *h1;
	int error, i;
	pshared_wlock(curthread);
	for (i = 0; i < HASH_SIZE; i++) {
		hd = &pshared_hash[i];
		LIST_FOREACH_SAFE(h, hd, link, h1) {
			error = _umtx_op(NULL, UMTX_OP_SHM, UMTX_SHM_ALIVE,
			    h->val, NULL);
			if (error == 0)
				continue;
			LIST_REMOVE(h, link);
			munmap(h->val, PAGE_SIZE);
			free(h);
		}
	}
	pshared_unlock(curthread);
}
static void pshared_gc ( struct pthread * curthread ) { struct pshared_hash_head * hd ; struct psh * h , * h1 ; int error , i ; pshared_wlock ( curthread ) ; for ( i = 0 ; i < HASH_SIZE ; i ++ ) { hd = & pshared_hash [ i ] ; LIST_FOREACH_SAFE ( h , hd , link , h1 ) { error = _umtx_op ( NULL , UMTX_OP_SHM , UMTX_SHM_ALIVE , h -> val , NULL ) ; if ( error == 0 ) continue ; LIST_REMOVE ( h , link ) ; munmap ( h -> val , PAGE_SIZE ) ; free ( h ) ; } } pshared_unlock ( curthread ) ; }
Among all processes sharing a lock only one executes
 pthread_lock_destroy().
Among all processes sharing a lock only one executes pthread_lock_destroy () .