[En-Nut-Discussion] Maybe obvious ...

Rob van Lieshout (PragmaLab) info at pragmalab.nl
Sun Nov 15 12:26:08 CET 2009

> Also, it's good to remind that Nut/OS uses cooperative threads,
> meaning one thread must relinquish it's hold on the CPU before the
> other runs. This happens when you call IO functions, NutSleep or
> NutThreadYield. So, if your hello world had something like this:
> main() {
>    fprintf( fp, "Hello World" );
>    while( true );
> }
> Then no context switching is ever happening, because of the inifinite
> loop in there. Unless of course, you had a NutThreadYield in the loop.

Hello Nathan,

Please be aware that in the end 'fprint' is using IO to print the message
(normally the UART will be used for that). So in other words, this fprintf
statement might end up in a NutThreadYield() as well... If there's enough
space in the IO-buffer (driver) to send the message in 1 piece, the thread
will not be yielded, if not, the thread is yielded and is set running again
by the driver as soon as its buffer has space available.....

Kind regards,

Rob van Lieshout

More information about the En-Nut-Discussion mailing list