[En-Nut-Discussion] THREAD's
Matthias Ringwald
mringwal at inf.ethz.ch
Wed Sep 1 21:44:13 CEST 2004
Hi Harald, Daniel,
sorry to intervene, but I fixed the bug that "NutEventPost" didn't
yield to another thread
with the same priority. NutThreadYield is AFAIK correct.
Thinging.... Ah, I've got it...
The first thread gets created and starts. After that its priority is
set to 16 which is higher than
the priority of the main thread. Now, the NutThreadYield is called and
finds the main thread with
priority 64 and the current thread with priority 16. So, clearly, no
reason to continue the main
thread and go back to thread1.
In general, as ethernut is cooperative anyway, I wouldn't use
priorities until I definitely need them,
they might crate more confusion than they prevent..
Matthias
On 01.09.2004, at 20:28, Harald Kipp wrote:
> Daniel,
>
> this "bug" (or wrong API doc) had been detected and fixed lately
> by Matthias Ringwald.
> http://cvs.sourceforge.net/viewcvs.py/ethernut/nut/os/event.c?
> r1=text&tr1=1.5&r2=text&tr2=1.6&diff_format=h
>
> Harald
>
>
> At 20:12 01.09.2004 +0200, you wrote:
>> 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);
>> }
>> }
>>
>> _______________________________________________
>> En-Nut-Discussion mailing list
>> En-Nut-Discussion at egnite.de
>> http://www.egnite.de/mailman/listinfo.cgi/en-nut-discussion
>
> _______________________________________________
> En-Nut-Discussion mailing list
> En-Nut-Discussion at egnite.de
> http://www.egnite.de/mailman/listinfo.cgi/en-nut-discussion
More information about the En-Nut-Discussion
mailing list