Two Coding Problems

Sun Shine pengsens at hotmail.com
Thu Jan 12 07:33:13 UTC 2006


>Hi Sun Shine,
>
>In answer to your second question, I would say it is because your 
>init task is running off the end of the task and so the init task is 
>deleted.  Then by the time your second task gets to run, it will 
>find the first available ID and use it, and this would have been the 
>one that the Init task was using.
>
>To stop this effect, at the end of your init task, put an endless 
>loop, such as:
>
>while(1)
>{
>    rtems_task_wake_after(100);
>}
>
>or you could just suspend the task instead of deleting it (by 
>running off the end, such as:
>
>    rtems_task_suspend(0);
>
>I hope this helps.
>
>regards,
>
>Ian Caddy
>
>
I don't think this can handle the problem.
Use my code again, for example , T0 create T1 and T2,and T1 create T3 , T2 
create T4
then the IDs are:
   T0: a010001 (Init Task)
   T1: a010002 (Created by T0)
   T2: a010003 (Created by T0)
   T3: a010004 (Created by T1)
   T4: a010001 (Created by T2)
If just like you said , the ID of T3 should be a010001 and the ID of T4 
should be a010002, because T1 and T2 are non-existent.

And I also tried your method: use rtems_task_suspend(0) instead of 
rtems_task_delete(0), in Init(), the result is:
   T0: a010001
   T1: a010002
   T2: a010003
   T3: a010004
   T4: a010002

Then I use rtems_task_suspend(0) to replace rtems_task_delete(0) in all the 
methods --- Init(),get_task_info() and create_task(),there comes the 
problem: T4's creation will fail.

_________________________________________________________________
与联机的朋友进行交流,请使用 MSN Messenger:  http://messenger.msn.com/cn  




More information about the users mailing list