On 02/01/2012 03:49 PM, Daniel Lezcano wrote:

IMO, you have a race condition with nrunning. What guarantee do you
have atomic_dec_and_test is called after atomic_inc ?

Nothing (but I believe ~1s is pretty enough for the kernel thread to get
woken up). I also tried to to atomic_inc() at the beginning of test(), like:

...
static int test(void *unused)
{
        int i;
        ktime_t expires = ktime_set(0, NSEC_PER_MSEC);

        atomic_inc(&nrunning);

        for (i = 0; !kthread_should_stop() && i < loopcount; i++)
                schedule_hrtimeout_range(&expires, 50000, HRTIMER_MODE_REL);

        if (atomic_dec_and_test(&nrunning))
                complete(&done);
        return 0;
}
...

Results are the same.

Dmitry

_______________________________________________
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev

Reply via email to