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

Yuji Mano Yuji.Mano at am.sony.com
Fri Aug 29 10:24:16 EST 2008


Kazunori Asayama wrote:
> 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.

Yes you are right.
Which means that the barrier must be reset when all tasks have called
mars_task_barrier_wait().

So I guess it will be a requirement for all tasks in the barrier to call both
notify and wait in a pair? That is...you cannot have a single notifier task
with multiple other tasks waiting?

Regards,
Yuji




More information about the cbe-oss-dev mailing list