[En-Nut-Discussion] Thread priority

Alexander Baranov baranov at intech21.com
Wed May 16 20:19:52 CEST 2007


Really I don't rely upon threads and use timer interrupt for that.
Alexnder.
----- Original Message ----- 
From: "Michel Hendriks" <michel at streamit.eu>
To: "'Ethernut User Chat (English)'" <en-nut-discussion at egnite.de>
Sent: Wednesday, May 16, 2007 11:11 AM
Subject: Re: [En-Nut-Discussion] Thread priority


> Yes, I see what you are saying. That is why we sleep 100ms in that thread:
>
>    NutThreadSetPriority(1);
>    for (;;)
>    {
>        NutSleep(100);
>        WatchDogRestart();
>    }
>
> Our watchdog is set to 2 seconds, so there should be enough time
> even if a thread would use 1,89999 seconds before releasing the CPU.
>
>
> The reason I want to give this watchdog thread the highest priority
> is because I found that, if I am busy in another thread, that thread
> will not give back the CPU if it uses a higher priority. Even when using
> the same priority, NutOS will not give time to the watchdog thread.
>
> So if I would have a thread doing this:
>    NutThreadSetPriority(1);
>    for (;;)
>    {
>        DoSomethingFor1.8seconds();
>        NutThreadYield();
>    }
>
> I would get watchdog resets. If I lower the prio of the other thread,
> the watchdog thread always gets its turn.
>
> Greets,
> Michel Hendriks
>
>
>> -----Oorspronkelijk bericht-----
>> Van: en-nut-discussion-bounces at egnite.de
>> [mailto:en-nut-discussion-bounces at egnite.de] Namens Ole Reinhardt
>> Verzonden: woensdag 16 mei 2007 11:34
>> Aan: Ethernut User Chat (English)
>> Onderwerp: Re: [En-Nut-Discussion] Thread priority
>>
>> Hi,
>>
>> > Maybe, but I want to check if my threads are still running.
>> > The easiest way to do that is using a high prio thread :-)
>>
>> You might do so. But be aware that if your thread has the
>> highest priority it will always run if you don't use NutSleep
>> to explecitly wait some time. Of course you could also wait
>> on events etc.
>>
>> In other words: Your watchdog threads _needs_ to give back
>> the cpu and you may not do this by using NutThreadYield() as
>> you would directly gain back cpu time.
>>
>> Normaly it should be fine to run the watchdog with lower
>> expiration time and use a normal priorised thread.
>>
>> Best regards,
>>
>> Ole Reinhardt
>>
>>
>> -- 
>> kernel concepts GbR             Tel:   +49-271-771091-14
>> Inh. Faerber & Kirchner         Fax:   +49-271-771091-19
>> Sieghütter Hauptweg 48          Mobil: +49-177-7420433
>> D-57072 Siegen                  UstID: DE 205 648 898
>>
>> _______________________________________________
>> http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>>
>>
>
> _______________________________________________
> http://lists.egnite.de/mailman/listinfo/en-nut-discussion
> 




More information about the En-Nut-Discussion mailing list