[En-Nut-Discussion] MultiThreading

MUHAMMAD AZEEM AZAM muhammadazeemazam786 at yahoo.com
Thu Mar 29 14:23:26 CEST 2007


Hi
  If i am using nutsleep() 2 or three times in my computing thread, when my this thread goes from ready to running state the code after the nutsleep() will be executed or it will execute the wholw thread from skratch.
  According to me it will execute after first nutsleep() then secon nutsleep().
  Thanks
  Bye

Ole Reinhardt <ole.reinhardt at kernelconcepts.de> wrote:
  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

_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion


 
---------------------------------
TV dinner still cooling?
Check out "Tonight's Picks" on Yahoo! TV.


More information about the En-Nut-Discussion mailing list