We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi all, I am porting RTX on LH7A404. Now SWI and Clock interrupt worked well. I used the example1 as test program. The code is below.
As you can see in the code, there are two tasks for testing basic function of the OS. I use counter to check the state of the task. "task1cnt" is used to check task1 state and "task2cnt" to task2. When I run the program. I always get the result, task1cnt=0 task2cnt=1. Os is always in the idle task.
I tried to trace the condition more deeply. I found that context_switch always select task2 as next run task. But when task2 occupies the OS, it resumes the previous session and executed the os_block. At this time, os did the next context-switch immediately and task2 almost did nothing. So I think this is why my test program is blocked.
Is there anyone help me? how can I do? Give me some hints about this problem.
#include "RTL.h" OS_TID id1, id2; void task1 (void) __task; void task2 (void) __task; void task1 (void) __task { // EnableARMIRQ(); /* Obtain own system task identification number */ static int task1cnt=0; id1 = os_tsk_self (); /* Assign system identification number of task2 to id2 */ id2 = os_tsk_create (task2, 1); for (;;) { /* do-this */ /* Indicate to task2 completion of do-this */ os_evt_set (0x0004, id2); /* Wait for completion of do-that (0xffff means no time-out)*/ os_evt_wait_or (0x0004, 0xffff); task1cnt++; /* Wait now for 50 ms */ os_dly_wait (5); } } void task2 (void) __task { static int task2cnt=0; for (;;) { /* Wait for completion of do-this (0xffff means no time-out) */ os_evt_wait_or (0x0004, 0xffff); /* do-that */ task2cnt++; /* Pause for 20 ms until signaling event to task1 */ os_dly_wait (2); /* Indicate to task1 completion of do-that */ os_evt_set (0x0004, id1); } } int main (void) { os_sys_init (task1); }