[En-Nut-Discussion] Multi Threading
MUHAMMAD AZEEM AZAM
muhammadazeemazam786 at yahoo.com
Thu Mar 22 17:49:20 CET 2007
Hi
I have a TCP Server on my Charon 2 Board.
I have 2 threads (along with main application thread and idle thread , total =4).
During system initialization, the idle thread is created first, which in turn creates the main application thread.
This main application thread will then create My first thread which is a tcp server. This tcp serevr has an "accept" statement, means when it is not executed it is blockdt and my thread will be sent to event queue.
then controll is transverred to main application thread which will create the second thread.
when i send request from my client to the server then my thread 1 will be moved from event queue to run queue. there is no eventwait and event post statement.
Please clear this to me.
------------------------------
2)
THREAD(Thread1, arg)
{
for (;;)
{
NutSleep(125);
}
}
int main(void)
{
NutThreadCreate("t1", Thread1, 0, 512);
for (;;)
{
NutSleep(125);
}
}
when main application thread creates thread-1, CPU control is transferred to Thread-1 but it sleeps for 125ms. During sleep of Thread-1 main application thread is in run queue and control is transferred back to main application thread.
main application thread now also sleeps for 125 ms.Now the control is transferred to idle thread(am i right). after 125 ms whats going to happen, which thread will have the control of CPU.
Thanks
Bye
------------
---------------------------------
Get your own web address.
Have a HUGE year through Yahoo! Small Business.
More information about the En-Nut-Discussion
mailing list