[En-Nut-Discussion] THREAD's

Daniel Makus daniel.makus at fhtw-berlin.de
Wed Sep 1 20:12:28 CEST 2004


Hello,

we wanted to test the switching time of the threads, there are 2 threads 
to run.
The first one set's the output bit and the second one have to clear the 
same bit.
The Problem is: Only the first created thread will run and the second 
not. Both threads have the same priority.

What is wrong ?

Here is the code:

...

THREAD(Thread1, arg)
{
 NutThreadSetPriority(16);
    while(1)
    {
        sbi(PORTB,0);
        NutThreadYield();
       
    }
}
THREAD(Thread2, arg)
{
 NutThreadSetPriority(16);
   
     while(1)
    {
        cbi(PORTB,0);
        NutThreadYield();
    }
   
}

int main(void)
{
...
//create worker threads
NutThreadCreate("worker1", Thread1, 0, 192);
NutThreadCreate("worker2", Thread2, 0, 192);
for (;;)
{
    NutSleep(65000);
}
}




More information about the En-Nut-Discussion mailing list