[En-Nut-Discussion] MultiThreading
MUHAMMAD AZEEM AZAM
muhammadazeemazam786 at yahoo.com
Thu Mar 29 14:45:18 CEST 2007
Hi
if we have the same priority to all threads then all the threds in ready queue will be served in FIFO manner because all have the save priority.
if networking request arrives (thread - 1) arrives then thread - 1 will be moved from event queue to ready queue. Now we have to select the thread that has to run. main thread isalso there.Since priorities are same so FIFO manner.now main thread will get the CPU and after main thread, thread -1 (networking thread) will get CPU.
I don't want to give CPU to main and idle thread
How to overcome this.
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
---------------------------------
It's here! Your new message!
Get new email alerts with the free Yahoo! Toolbar.
More information about the En-Nut-Discussion
mailing list