This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problem with os_dly_wait() and printf()

Hello,

I'm using LPC2119 microcontroller and RV30 with RTX and ran into several problems.

1) If I use printf(...) inside tasks and use os_dly_wait(...) then as soon as context switching occurs then os_stack_overflow() is called. I tried to set up different stack sizes inside startup.s file but it didn't help a bit. I tried to run the same code inside simulator and it works OK without any stack overflow (which I was getting if I didn't include tsk_lock() and tsk_unlock() around printf(...))

2) If I get rid of os_dly_wait(...) calls and have two tasks running, then if I use printf with this kind of code:

int test = 10;
tsk_lock();
printf("test value: %u\n", test);
tsk_unlock();

Then the task, which ran that line of code, will get stuck including not context switching. I didn't get any stack overflows that time but it looks like it gets stuck when it tried to do a context switching. If, on the other hand, I put code like that:

tsk_lock();
printf("test value: %s\n", "just some test");
tsk_unlock();

Then it switches just fine. Thanks in advance with any suggestions or explanations, Alexei

  • I certainly does sound like a stack issue. None of the stacks defined in "startup.s" are what the task that RL-ARM (the RTX-Kernel) will use for your tasks. You specify what stack you want to use when you create the task. It can be a "default" stack, which will do an alloc_box from a box created in RTX_CONFIG.c The alloc box can fail and give a null pointer for your stack. You may also pass the stack in to os_task_create_user_ex. Since the stack overflow check is only done on a contex switch, I would guess you have a stack size of 0.

  • Thank you! It really helped. That was the root of the problem.

    Once again thank you :-)

    Alexei