I am currently using the code from JamesM's multitasking tutorial as a learning tool. Everything works fine until I try to return back into my main function in two scenarios.
The first is this: I call fork() in main, it fork's the kernel process and returns as the parent. The parent task runs fine for several milliseconds after which switch_task() gets called by my timer interrupt. Everything is saved and the new task (the child task) is loaded without problems. Then it page faults on the "return;" command when the child tries to go back to the main() function. Here is a screen shot of the output from this scenario:

The other scenario is this: I don't call fork() in main(), the kernel process then runs for several milliseconds after which switch_task() gets called by my timer interrupt (like before). This time though the kernel task (at this point the only task) also page faults trying to "return;" back into main(). Here is a screen shot of this one:

My first thought was that the stack was at fault because it would push or pop a bogus value on the return causing a page fault. But I am new at this an am probably wrong.
