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.
/* Following is a piece of program that I want the two tasks call the same function 'CommonTask'. But either running on Keil UV2 or other simulators it always runs incorrectly to an unexpected code address. What's wrong with it? */ #include <reg52.h> #include <rtx51tny.h> void Init(void) _task_ 0 { os_create_task(1); os_create_task(2); os_delete_task(0); } /* Common works that I wish the two tasks do. Delete the 'reentrant' declaration of CommonWork, then the program would run normally else it will go wrong. */ void CommonWork(unsigned char ch) reentrant { P3=ch; } void Task1(void) _task_ 1 { for(;;) { EA=0; // Whether the EA is enabled or not is useless to avoid the crash CommonWork('1'); EA=1; } } void Task2(void) _task_ 2 { for(;;) { EA=0; CommonWork('2'); EA=1; } }
RTX51 Tiny uses all the memory on the on-chip up till RAMTOP. If you are using reentrant functions in the small memory model this will overwrite by default the RTX51 Tiny stack. You need to specify a different RAMTOP for RTX51 Tiny in this case to have some reentrant stack available.