Re: [PATCH] msvcp120: implement _Cnd_* functions (try 2)
On 11/09/15 16:38, Daniel Lehman wrote:
+static int (__cdecl*p__Mtx_init)(_Mtx_t*); This function has different header.
+ if (0) /* causes crash in later_Cnd_* calls on Windows */ + p__Cnd_destroy(&cm.cnd); This is not what I meant. I'm attaching a patch (generated on top of yours with the test I had in mind). It only shows the problem, the test needs more work.
+ for(i = 0; i < NUM_THREADS; i++) + p__Thrd_create(&threads[i], cnd_bcast_thread, (void*)&cm); ... + p__Mtx_lock(&mtx); + cm.go = 1; + p__Mtx_unlock(&mtx); Please add some kind of synchronization to make sure the thread is waiting on condition variable before setting cm.go to 1.
+ cm.go = 0; + p__Thrd_create(&threads[0], cnd_signal_thread, (void*)&cm); + p__Mtx_lock(&mtx); + while(!cm.go) { + r = p__Cnd_wait(&cnd, &mtx); + ok(!r, "failed to wait\n"); + } Here's a similar synchronization problem. In most cases p__Cnd_wait will not be called.
+ diff = p__Xtime_diff_to_millis2(&after, &before); + ok(r == 2, "should have timed out\n"); + ok(diff > 2000 - TIMEDELTA, "got %d\n", diff); This test failed once on my computer (in ~10 runs, diff == 1800).
Thanks, Piotr
participants (1)
-
Piotr Caban