[En-Nut-Discussion] MultiThreading

MUHAMMAD AZEEM AZAM muhammadazeemazam786 at yahoo.com
Thu Mar 1 13:11:16 CET 2007


Please explain the marked paragraph.
  The Thread 1 has NutSleep(?) of how many mseconds and 
  The Thread 2 has NutSleep(?) of how many mseconds?
  

Gervasio Varela <gervarela at picandocodigo.com> wrote:
    Hi Muhammad,

Nut/OS has cooperative multithreading, so, differently to Linux and other
tipical OSes, it can't take out of the CPU any thread to put another. Is the
executing thread the responsible of leaving the CPU in order that the OS
could place other threads "on it".

NutSleep() is used to accomplish this (leave the CPU), if you do a
NutSleep(125) the thread is stopped AT LEAST 125 ms. 
  -----------------------------------------------------------------------------------
  PLEASE EXPLAIN THIS A BIT. I HAVE CONFUSION IN THE LAST THREE LINES
   
  But, at the moment you
executed NutSleep(), other thread has taken over the CPU. The first thread
doens't get back the CPU until the new (thread) do a NutSleep(), so it(which thread ?) can
take the CPU after 125ms or after 1000ms, if you have real time constraints,
is your responsibility to asure that the other threads do a NutSleep()
before 125ms.
------------------------------------------------------------------------------------
If you want that a computing thread separated from the networking code gets
all the "idle" time, I think that you should use short NutSleep() times in
all two threads. The computing thread should leave the CPU regularly (the
code between NutSleep() should be little engough) to gurantee that the
networking code process all the received request as early as posible, and
the networking code should leave the CPU as soon as it checked if there are
some request available.

If you have litle network load, the networking thread should realease the
CPU in few ms (the check of new request should be fast) and the computing
thread should be using the majority of CPU time (but it should leave the CPU
frequently to let the networking code test if there was new request...)

I hope that this help you, and I'm open to suggestions, because I'm working
in a projet with similar requisites :D.

See you.

PDT: Sorry for my english.

On 01/03/07, MUHAMMAD AZEEM AZAM wrote:
>
> I have a TCP Server for Microcontroller. i want that my micro controller
> should be able to fullfil another task. Not only networking.
> This means that i should create anther task (or thread) on the controller.
> I want that this thread should have as much computing time of the
> controller as
> possible.
> How to achieve this.
> ---------------------------------------
> I am confused in this concept, please clear it to me
> Let suppose that
> I have only 2 threads (other than main and idle).
> Thread 1
> Thread 2
> in thread 1 i have a NutSleep(125), this means my thread has been slept
> for 125ms and then the control will be transferred to Second thread. If
> second thread has a NutSleep(500)
> ,means thread 2 has been slept for 500ms .
> But what after 125ms contol is transferred back to thred1 or what ?
>
> Thanks for ur help
> Bye
>
>
>
> ---------------------------------
> Be a PS3 game guru.
> Get your game face on with the latest PS3 news and previews at Yahoo!
> Games.
> _______________________________________________
> http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>



-- 
###################################
# Gervasio Varela #
# gervarela at picandocodigo.com #
# http://www.picandocodigo.com #
###################################
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion



 
---------------------------------
Need Mail bonding?
Go to the Yahoo! Mail Q&A for great tips from Yahoo! Answers users.


More information about the En-Nut-Discussion mailing list