我使用helgrind
来自Valgrind
. 但它报告了一个受锁保护的代码的竞争。错误地将其报告为Valgrind
比赛条件,或者我错过了什么。代码如下。
pthread_mutex_lock(&G_Memory->lock_array[pb->exp_lock_index]);
pb->subtree_cost += b->subtree_cost;
pb->interaction_synch += 1; // <--- race here (cost_zones.c:91)
pthread_mutex_unlock(&G_Memory->lock_array[pb->exp_lock_index]);
Valgrind/Helgrind
报告以下
==29768== Possible data race during read of size 8 at 0x56bf8e0 by thread #4
==29768== at 0x404C51: ComputeSubTreeCosts (cost_zones.c:91)
...................
==29768== This conflicts with a previous write of size 8 by thread #1
==29768== at 0x404C5F: ComputeSubTreeCosts (cost_zones.c:91)
...................