Avoid data race in finalized_count (gctest)
authorIvan Maidanski <ivmai@mail.ru>
Fri, 3 Nov 2017 08:03:04 +0000 (11:03 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Fri, 3 Nov 2017 08:03:27 +0000 (11:03 +0300)
commit8acc13755db635d7c8244279bd2a20ad68e48cc0
tree4b38cc95dc9f9b498e08317ac606065051a53a63
parent1bdad3666a13aa506297fb8a816e1460c5fa1b22
Avoid data race in finalized_count (gctest)

* tests/test.c (FINALIZER_LOCK, FINALIZER_UNLOCK): New macro.
* tests/test.c [GC_PTHREADS] (incr_lock): Move static variable out
of finalizer() and mktree() (use a single lock variable to access
finalized_count in finalizer, mktree and tree_test).
* tests/test.c (dropped_something): Change type back to int; remove
volatile.
* tests/test.c (finalizer, mktree): Use FINALIZER_[UN]LOCK() instead
of PCR_ThCrSec_Enter/ExitSys(), pthread_mutex_[un]lock(),
Enter/LeaveCriticalSection().
* tests/test.c (tree_test): Use FINALIZER_[UN]LOCK() to avoid data
race when accessing finalized_count and dropped_something; do not use
AO_load() and AO_store() to access dropped_something.
* tests/test.c
tests/test.c