[En-Nut-Discussion] MultiThreading
Ole Reinhardt
ole.reinhardt at kernelconcepts.de
Thu Mar 29 10:44:22 CEST 2007
Hi,
> I know about these things but i am confused about the things what to do and what not to.
> I am confused what should i use, which is the best approach
>
> 1) Should i define priorities.
In most applications giving the same priorities to all threads works
quite well. If you give a thread a higher priority it other threads will
only gain the cpu if the higher priorised thread has to sleep and
another lower priorised one is runnable.
in other words: calling NutThreadYield will not give up cpu as the same
thread is still runable and will regain the cpu again. In these cases
you have to wait with NutEventWait() or call a NutSleep().
> 2) Shouldi use nutsleep().
Only use it if you realy want to sleep or if you don't have any further
thread switching point in your thread. Instead better use NutThreadYield
if your threads have all the same priority.
> 3) shoul i use nutthreadswitch()
No, as I just said, it's only an internal function of NutOS. See the API
documentation:
/*!
* \brief Switch to another thread.
*
* Stop the current thread, saving its context. Then start the
* one with the highest priority, which is ready to run.
*
* Application programs typically do not call this function.
*
* \note CPU interrupts must be disabled before calling this function.
*
*/
Bye,
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
More information about the En-Nut-Discussion
mailing list