karter16 wrote:
Hi All,
I've been refering to osdev for a while now - it's an awesome resource.
I just have a bit of a question regarding software multitasking.
I have software multitasking working (very basic) on my os and can execute tasks in a round-robbin fashion. My question is: what happens when a task finishes (ie returns)??? what should happen? how should the scheduler know that the task has finished?
or is it necessary to put the task in an infinite loop and somehow send a signal to the scheduler that it has finished? - that doesn't sound very user friendly.
Sorry if this is really obvious or has already been discussed elsewhere but I couldn't find anything about it anywhere.
Cheers,
Matt
Standard operating procedure suggests that your provide a form of exit() in the API.
To cover those programs that just tend to "return", your program loader should make a CALL to the program's entry-point so that the final program RET returns back to that same loader (assuming no stack corruption) and follow-up with whatever clean-up code you have.
Generic Example...
Code:
;Loader Code
call APP_ENTRY_POINT
;APP Returned back here... obviously... so perform cleanup...