[Cbe-oss-dev] [PATCH 4/10] MARS: task barrier fix notify

Kazunori Asayama asayama at sm.sony.co.jp
Thu Aug 28 15:28:35 EST 2008


Yuji Mano wrote:
> This fixes a bug in task barrier's notify function so it only sends a signal to
> workload id's that are in the wait list.
> 
> This also fixes a bug where the barrier count was not being properly reset once
> the barrier is released.
> 
> Signed-off-by: Yuji Mano <yuji.mano at am.sony.com>
> 
> ---
>  src/mpu/lib/mars_task_barrier.c |    5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> --- a/src/mpu/lib/mars_task_barrier.c
> +++ b/src/mpu/lib/mars_task_barrier.c
> @@ -80,11 +80,14 @@ int mars_task_barrier_notify(uint64_t ba
>  	/* barrier count reached total so release barrier */
>  	if (barrier.count == barrier.total) {
>  		/* signal all task ids in wait list */
> -		for (i = 0; i < barrier.total; i++)
> +		for (i = 0; i < barrier.wait_count; i++)
>  			mars_signal_send(barrier.wait_id[i]);
>  
>  		/* flush wait list */
>  		barrier.wait_count = 0;
> +
> +		/* reset barrier count */
> +		barrier.count = 0;

If you reset the barrier count here, mars_task_barrier_wait after
barrier.count becomes equal to barrier.total, will cause deadlock.

For example:

  mars_task_barrier_initialize(barrier, 1);
  mars_task_barrier_notify(barrier); // this call increments the barrier
                                     // count, then resets it.
  mars_task_barrier_wait(barrier); // this call will block forever.


>  	}
>  
>  	mars_mutex_unlock_put(barrier_ea, (struct mars_mutex *)&barrier);
> 
> 
> 

-- 
(ASAYAMA Kazunori
  (asayama at sm.sony.co.jp))
t



More information about the cbe-oss-dev mailing list