Page 1 of 1

doubt in mulitasking..

Posted: Wed Jul 09, 2008 12:03 am
by octa
i add a c function as a thread which is executed along wit my shell...
after the function ends i get page fault..
but how to kill the thread as soon as function ends ??
is it possible by adding code in pagefault isr... to kill the thread.

Re: doubt in mulitasking..

Posted: Wed Jul 09, 2008 12:07 am
by piranha
Simply remove that task from the list of tasks. It's a simple exit function, cleaning up and then killing itself.
If you are using a linked list, just remove it (Change the 'next' value in the task before it to the task after it) and clear the memory.
Or, if an array, clear the array (or set a flag to zombie or something) and have the scheduler skip it.

Edit: If a process creates a pagefault, I kill it anyway. Write your exit() function and call it from the fault handler.

-JL

Re: doubt in mulitasking..

Posted: Wed Jul 09, 2008 12:13 am
by octa
cool.. i too had the same thought.... and one more thing does any of the hobby os use cooperative multitasking ???

Re: doubt in mulitasking..

Posted: Wed Jul 09, 2008 12:16 am
by piranha
My old kernel did.
My new kernel uses IO wait flags and task states. I might add a system call that switches tasks, but there really is no need.

Cooperative can make things more difficult, application wise.

-JL