Wanting the best of both worlds...
Posted: Sat Jan 06, 2007 3:51 am
Hello All,
As you probably know (and are fed up with), I have recently implemented the multitasking part of my kernel.
Originally, I had it set up (with stack-switching), so that at the very base of the stack, I added an address and CS of a 'clearing up' function. This way, if a process returned from its main function, the task was automatically terminated.
However, I have just implemented support for the argc and argv parameters to the main function. This means that these are now pushed to the new task's stack above the terminating function and so the processor will actually try to ' ret ' using argc and argv instead of the true return address.
How do people cope with this situation in their os's? Do I simply have to hope that I can catch this with a gpf or pf, or does every user-space process have to be 'good' and use exit()? I was really hoping to elegantly cope with poorly written user-space code.
Any suggestions appreciated,
Adam
As you probably know (and are fed up with), I have recently implemented the multitasking part of my kernel.
Originally, I had it set up (with stack-switching), so that at the very base of the stack, I added an address and CS of a 'clearing up' function. This way, if a process returned from its main function, the task was automatically terminated.
However, I have just implemented support for the argc and argv parameters to the main function. This means that these are now pushed to the new task's stack above the terminating function and so the processor will actually try to ' ret ' using argc and argv instead of the true return address.
How do people cope with this situation in their os's? Do I simply have to hope that I can catch this with a gpf or pf, or does every user-space process have to be 'good' and use exit()? I was really hoping to elegantly cope with poorly written user-space code.
Any suggestions appreciated,
Adam