On Thursday 10 January 2008 03:12:28 Sebastien Dugue wrote:
> The thread waiting on the condvar may miss a wakeup if the
> signaling thread does not lock the mutex before calling
> pthread_cond_signal().
>
> Also remove the unneeded locking when recording the statistics.
>
> Signed-off-by: Sebastien Dugue <[EMAIL PROTECTED]>
Acked-by: Darren Hart <[EMAIL PROTECTED]>
> Cc: Darren Hart <[EMAIL PROTECTED]>
> Cc: Tim Chavez <[EMAIL PROTECTED]>
> ---
> .../realtime/func/async_handler/async_handler.c | 4 +---
> .../func/async_handler/async_handler_tsc.c | 4 +---
> 2 files changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/testcases/realtime/func/async_handler/async_handler.c
> b/testcases/realtime/func/async_handler/async_handler.c index
> f5ba9c8..7a73116 100644
> --- a/testcases/realtime/func/async_handler/async_handler.c
> +++ b/testcases/realtime/func/async_handler/async_handler.c
> @@ -137,17 +137,16 @@ void *handler_thread(void *arg)
> usleep(10);
> pthread_mutex_lock(&mutex);
> start = rt_gettime();
> - pthread_mutex_unlock(&mutex);
> if (pthread_cond_signal(&cond) != 0) {
> perror("pthread_cond_signal");
> atomic_set(CHILD_QUIT, &step);
> break;
> }
> + pthread_mutex_unlock(&mutex);
>
> /* wait for the event handler to schedule */
> while (atomic_get(&step) != CHILD_HANDLED)
> usleep(10);
> - pthread_mutex_lock(&mutex);
> delta = (long)((end - start)/NS_PER_US);
> if (delta > PASS_US)
> ret = 1;
> @@ -160,7 +159,6 @@ void *handler_thread(void *arg)
> max = MAX(max, delta);
> }
> atomic_set((i == iterations-1) ? CHILD_QUIT : CHILD_START,
> &step);
> - pthread_mutex_unlock(&mutex);
> }
> printf("recording statistics...\n");
> printf("Min: %ld us\n", min);
> diff --git
> a/testcases/realtime/func/async_handler/async_handler_tsc.c
> b/testcases/realtime/func/async_handler/async_handler_tsc.c index
> 8cbbbdc..6131a8b 100644
> --- a/testcases/realtime/func/async_handler/async_handler_tsc.c
> +++ b/testcases/realtime/func/async_handler/async_handler_tsc.c
> @@ -187,17 +187,16 @@ void *handler_thread(void *arg)
> usleep(10);
> pthread_mutex_lock(&mutex);
> rdtscll(start);
> - pthread_mutex_unlock(&mutex);
> if (pthread_cond_signal(&cond) != 0) {
> perror("pthread_cond_signal");
> atomic_set(CHILD_QUIT, &step);
> break;
> }
> + pthread_mutex_unlock(&mutex);
>
> /* wait for the event handler to schedule */
> while (atomic_get(&step) != CHILD_HANDLED)
> usleep(10);
> - pthread_mutex_lock(&mutex);
> delta = (long)(tsc_period * (end - start) / 1000000);
> if (delta > 30) {
> over_30++;
> @@ -215,7 +214,6 @@ void *handler_thread(void *arg)
> max = MAX(max, delta);
> }
> atomic_set((i == ITERATIONS-1) ? CHILD_QUIT : CHILD_START,
> &step);
> - pthread_mutex_unlock(&mutex);
> }
> printf("recording statistics...\n");
> printf("Minimum: %ld\n", min);
--
Darren Hart
IBM Linux Technology Center
Real-Time Linux Team
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list