This is what you need to do in order to replace the per-thread
"remain" counter with a shared counter.

File scope:
+/** @private Number of timeouts to receive */
+static odp_atomic_u32_t remain;

In test_abs_timeouts():
-       int remain = args->tmo_count;

-       while (remain != 0) {
+       while ((int)odp_atomic_load_u32(&remain) > 0) {

-                       remain--;
+               odp_atomic_dec_u32(&remain);

In main() before creating the worker threads:
+       /* Initialize number of timeouts to receive */
+       odp_atomic_init_u32(&remain, args.tmo_count * num_workers);

Seems to work fine with odp_schedule() in my code (which uses the new
timer API, that's why I can't give you a proper patch). You can see
that timeout buffers are very unevenly scheduled to the different
threads.





On 19 December 2014 at 22:16, Ola Liljedahl <[email protected]> wrote:
> I have found a problem with this patch (sorry Mike). The
> odp_timer_test example needs some more changes for the removal of
> odp_schedule_one() not to potentially hang the program. I have
> outlined this in a mail to Mike, hopefully he can provide an updated
> patch.
>
> On 19 December 2014 at 21:34, Mike Holmes <[email protected]> wrote:
>> Signed-off-by: Mike Holmes <[email protected]>
>> ---
>>  example/timer/odp_timer_test.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/example/timer/odp_timer_test.c b/example/timer/odp_timer_test.c
>> index 0d6e31a..6d2609a 100644
>> --- a/example/timer/odp_timer_test.c
>> +++ b/example/timer/odp_timer_test.c
>> @@ -84,7 +84,7 @@ static void test_abs_timeouts(int thr, test_args_t *args)
>>         while (1) {
>>                 odp_timeout_t tmo;
>>
>> -               buf = odp_schedule_one(&queue, ODP_SCHED_WAIT);
>> +               buf = odp_schedule(&queue, ODP_SCHED_WAIT);
>>
>>                 tmo  = odp_timeout_from_buffer(buf);
>>                 tick = odp_timeout_tick(tmo);
>> --
>> 2.1.0
>>
>>
>> _______________________________________________
>> lng-odp mailing list
>> [email protected]
>> http://lists.linaro.org/mailman/listinfo/lng-odp

_______________________________________________
lng-odp mailing list
[email protected]
http://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to