stack corruption
I have added proper linking with the mock-up C library, and the L4 library. I can also pass up to 7 arguments over the stack into kernel, so it's not fast no-copy but since it works it is ok for now. I am now calling functions from the L4 library rather than hand-made system call jumps. This revealed various problems. It turns out that I must save the userspace stack pointer even if the context switch occurs in kernel space. For example I wasnt saving it for kernel calls, and a preempting process would overwrite the user stack pointer. I fixed that, than voluntary context switching showed up with the same problem. I should really save it upon context switches, rather than at other points (like the syscall entry). The assembler for preemption/irq/context switching is fairly clean and compact so far, I will be cautious not to add much complexity.
The other thing is for example this problem has revealed itself by static reasoning rather than examining the code at run-time. For example if I had a trace tool, that might have also helped, but for this kind of bug, it seems you can only think about the logic in your code and decide what's wrong.
Another thing is it is a quite nice thing to do this project. If I didn't do it how could I learn about virtual memory, caching, managing address spaces etc. there was no way to go any further. Learning by practice is quite good. I think my git repository is quite neat as well. Normally you get educational os'es (like minix) as a whole, and even though they are simple, one wouldnt easily know where to start to write another one. In my case though, the git commits are really good examples of how to develop it step by step. So I think in the future I may at least publish it as an educational practical approach to getting started with an os.
The other thing is for example this problem has revealed itself by static reasoning rather than examining the code at run-time. For example if I had a trace tool, that might have also helped, but for this kind of bug, it seems you can only think about the logic in your code and decide what's wrong.
Another thing is it is a quite nice thing to do this project. If I didn't do it how could I learn about virtual memory, caching, managing address spaces etc. there was no way to go any further. Learning by practice is quite good. I think my git repository is quite neat as well. Normally you get educational os'es (like minix) as a whole, and even though they are simple, one wouldnt easily know where to start to write another one. In my case though, the git commits are really good examples of how to develop it step by step. So I think in the future I may at least publish it as an educational practical approach to getting started with an os.