doubt in mulitasking..

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
octa
Member
Member
Posts: 50
Joined: Sat Jun 28, 2008 9:15 am

doubt in mulitasking..

Post 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.
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

Re: doubt in mulitasking..

Post 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
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
User avatar
octa
Member
Member
Posts: 50
Joined: Sat Jun 28, 2008 9:15 am

Re: doubt in mulitasking..

Post by octa »

cool.. i too had the same thought.... and one more thing does any of the hobby os use cooperative multitasking ???
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

Re: doubt in mulitasking..

Post 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
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
Post Reply