You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nuttx.apache.org by fft <ff...@feedforward.com.cn> on 2022/03/27 04:57:59 UTC

usleep can't wake up incidentally in tickless mode

Hi team,


I've been puzzled by a strange problem for a long time, when i use tickless OS mode on stm32f405, usleep can't wake up incidentally.

My config about tickless OS mode as shown below:


CONFIG_ARCH_HAVE_TICKLESS=y
CONFIG_SCHED_TICKLESS=y
# CONFIG_SCHED_TICKLESS_ALARM is not set
# CONFIG_SCHED_TICKLESS_LIMIT_MAX_SLEEP is not set
CONFIG_USEC_PER_TICK=10

# CONFIG_STM32_TICKLESS_SYSTICK is not set

CONFIG_STM32_TICKLESS_TIMER=2
CONFIG_STM32_TICKLESS_CHANNEL=1


When use usleep(1000) in a pthread A, then thread A maybe sporadic sleep dead and can't be wake up, the probability is about 1/100000.
Moreover, when the problem happened, if i execute usleep 10000 in NSH terminus, then thread A will wakeup. Is my configuration incorrect?

Does anyone else have the same problem?


Best regard
Zou

Re: usleep can't wake up incidentally in tickless mode

Posted by fft <ff...@feedforward.com.cn>.
Hi Alan,


I'm tried enable the CONFIG_PRIORITY_INHERITANCE and the problem remains, thanks for your reply


Best regard
Zou&nbsp;
&nbsp;
------------------&nbsp;Original&nbsp;------------------
From: &nbsp;"Alan&nbsp;Carvalho&nbsp;de&nbsp;Assis"<acassis@gmail.com&gt;;
Date: &nbsp;Sun, Mar 27, 2022 10:11 PM
To: &nbsp;"dev"<dev@nuttx.apache.org&gt;; 

Subject: &nbsp;Re: usleep can't wake up incidentally in tickless mode

&nbsp;

Zou,

just a think that passed on my mind:

try to enable the CONFIG_PRIORITY_INHERITANCE and let us know if the
issue will happen again in this case.

BR,

Alan

On 3/27/22, Alan Carvalho de Assis <acassis@gmail.com&gt; wrote:
&gt; Hi Zou,
&gt;
&gt; Is there some way to identify that thread A didn't wake up and create
&gt; some unity test to report and to analyze it?
&gt;
&gt; Maybe there is some very specific race condition that we never saw before.
&gt;
&gt; BR,
&gt;
&gt; Alan
&gt;
&gt; On 3/27/22, fft <fft@feedforward.com.cn&gt; wrote:
&gt;&gt; Hi team,
&gt;&gt;
&gt;&gt;
&gt;&gt; I've been puzzled by a strange problem for a long time, when i use
&gt;&gt; tickless
&gt;&gt; OS mode on stm32f405, usleep can't wake up incidentally.
&gt;&gt;
&gt;&gt; My config about tickless OS mode as shown below:
&gt;&gt;
&gt;&gt;
&gt;&gt; CONFIG_ARCH_HAVE_TICKLESS=y
&gt;&gt; CONFIG_SCHED_TICKLESS=y
&gt;&gt; # CONFIG_SCHED_TICKLESS_ALARM is not set
&gt;&gt; # CONFIG_SCHED_TICKLESS_LIMIT_MAX_SLEEP is not set
&gt;&gt; CONFIG_USEC_PER_TICK=10
&gt;&gt;
&gt;&gt; # CONFIG_STM32_TICKLESS_SYSTICK is not set
&gt;&gt;
&gt;&gt; CONFIG_STM32_TICKLESS_TIMER=2
&gt;&gt; CONFIG_STM32_TICKLESS_CHANNEL=1
&gt;&gt;
&gt;&gt;
&gt;&gt; When use usleep(1000) in a pthread A, then thread A maybe sporadic sleep
&gt;&gt; dead and can't be wake up, the probability is about 1/100000.
&gt;&gt; Moreover, when the problem happened, if i execute usleep 10000 in NSH
&gt;&gt; terminus, then thread A will wakeup. Is my configuration incorrect?
&gt;&gt;
&gt;&gt; Does anyone else have the same problem?
&gt;&gt;
&gt;&gt;
&gt;&gt; Best regard
&gt;&gt; Zou
&gt;

Re: usleep can't wake up incidentally in tickless mode

Posted by Alan Carvalho de Assis <ac...@gmail.com>.
Zou,

just a think that passed on my mind:

try to enable the CONFIG_PRIORITY_INHERITANCE and let us know if the
issue will happen again in this case.

BR,

Alan

On 3/27/22, Alan Carvalho de Assis <ac...@gmail.com> wrote:
> Hi Zou,
>
> Is there some way to identify that thread A didn't wake up and create
> some unity test to report and to analyze it?
>
> Maybe there is some very specific race condition that we never saw before.
>
> BR,
>
> Alan
>
> On 3/27/22, fft <ff...@feedforward.com.cn> wrote:
>> Hi team,
>>
>>
>> I've been puzzled by a strange problem for a long time, when i use
>> tickless
>> OS mode on stm32f405, usleep can't wake up incidentally.
>>
>> My config about tickless OS mode as shown below:
>>
>>
>> CONFIG_ARCH_HAVE_TICKLESS=y
>> CONFIG_SCHED_TICKLESS=y
>> # CONFIG_SCHED_TICKLESS_ALARM is not set
>> # CONFIG_SCHED_TICKLESS_LIMIT_MAX_SLEEP is not set
>> CONFIG_USEC_PER_TICK=10
>>
>> # CONFIG_STM32_TICKLESS_SYSTICK is not set
>>
>> CONFIG_STM32_TICKLESS_TIMER=2
>> CONFIG_STM32_TICKLESS_CHANNEL=1
>>
>>
>> When use usleep(1000) in a pthread A, then thread A maybe sporadic sleep
>> dead and can't be wake up, the probability is about 1/100000.
>> Moreover, when the problem happened, if i execute usleep 10000 in NSH
>> terminus, then thread A will wakeup. Is my configuration incorrect?
>>
>> Does anyone else have the same problem?
>>
>>
>> Best regard
>> Zou
>

Re: usleep can't wake up incidentally in tickless mode

Posted by Alan Carvalho de Assis <ac...@gmail.com>.
Hi Zou,

Is there some way to identify that thread A didn't wake up and create
some unity test to report and to analyze it?

Maybe there is some very specific race condition that we never saw before.

BR,

Alan

On 3/27/22, fft <ff...@feedforward.com.cn> wrote:
> Hi team,
>
>
> I've been puzzled by a strange problem for a long time, when i use tickless
> OS mode on stm32f405, usleep can't wake up incidentally.
>
> My config about tickless OS mode as shown below:
>
>
> CONFIG_ARCH_HAVE_TICKLESS=y
> CONFIG_SCHED_TICKLESS=y
> # CONFIG_SCHED_TICKLESS_ALARM is not set
> # CONFIG_SCHED_TICKLESS_LIMIT_MAX_SLEEP is not set
> CONFIG_USEC_PER_TICK=10
>
> # CONFIG_STM32_TICKLESS_SYSTICK is not set
>
> CONFIG_STM32_TICKLESS_TIMER=2
> CONFIG_STM32_TICKLESS_CHANNEL=1
>
>
> When use usleep(1000) in a pthread A, then thread A maybe sporadic sleep
> dead and can't be wake up, the probability is about 1/100000.
> Moreover, when the problem happened, if i execute usleep 10000 in NSH
> terminus, then thread A will wakeup. Is my configuration incorrect?
>
> Does anyone else have the same problem?
>
>
> Best regard
> Zou