#128272 - Sarev0k - Thu May 10, 2007 6:09 am
Hello,
I'm new to the ARM platform and I've implemented a very simple context switcher, but I when I spin off my first thread the execution of my application becomes very sporadic.
Here's the code I'm using to switch out the current stack pointer and spin off my new thread.
Where thdCurrent is a global instance of a thread structure that I have pointing to the thread I wish to spin off. In this structure I've dynamically allocated memory for the stack and positioned the address and the stack pointer such that once those items were all popped off the stack, that thread's entry function would be placed into my program counter and I would start executing my thread.
I'm able to get to that function just fine, however when I start using printf, the ANSI escape sequences (that allow me to position my console output) completely stop working.
Is there something fundamentally wrong with the way I'm trying to spin off my first thread?
Thanks in advance for your help.
I'm new to the ARM platform and I've implemented a very simple context switcher, but I when I spin off my first thread the execution of my application becomes very sporadic.
Here's the code I'm using to switch out the current stack pointer and spin off my new thread.
Code: |
asm
( // changing the stack pointer to point to the new thread "ldr sp, =thdCurrent\n" "ldr sp, [sp]\n" "ldr sp, [sp, #8]\n" // popping the current thread's context off the stack "ldmfd sp!, {r0-r12, pc}\n" ); |
Where thdCurrent is a global instance of a thread structure that I have pointing to the thread I wish to spin off. In this structure I've dynamically allocated memory for the stack and positioned the address and the stack pointer such that once those items were all popped off the stack, that thread's entry function would be placed into my program counter and I would start executing my thread.
I'm able to get to that function just fine, however when I start using printf, the ANSI escape sequences (that allow me to position my console output) completely stop working.
Is there something fundamentally wrong with the way I'm trying to spin off my first thread?
Thanks in advance for your help.