task switching

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
ashokvarma2
Posts: 2
Joined: Wed Sep 26, 2007 12:25 pm
Location: India

task switching

Post by ashokvarma2 »

Can anyone suggest a good tutorial to study about task switching.
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

Post by piranha »

Study the Linux task scheduler.

Check osdever.net

STFW

-JL
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
User avatar
ashokvarma2
Posts: 2
Joined: Wed Sep 26, 2007 12:25 pm
Location: India

Post by ashokvarma2 »

i checked osdever, that was the first thing i did.I even found this tutorial based on skelixos

http://en.skelix.org/skelixos/tutorial06.php

but a much more precise tutorial can help

but thanx neway
jnc100
Member
Member
Posts: 775
Joined: Mon Apr 09, 2007 12:10 pm
Location: London, UK
Contact:

Post by jnc100 »

Once you realise that task switching and scheduling are two different things, it becomes easier to find what you are looking for. Task switching is an entirely processor-dependent way of, well, switching from one task to another. The basic method is to simply store the cpu state from one process, and load a saved one for another process. For the i386, this translates to the general purpose registers, possibly the segment selectors if you freely mix kernel- and process-level threads, cr3 if you use paging., and the fpu state if necessary. As regards to the tutorial you found, I would personally steer clear of hardware-based task switching. Context Switching contains some introductory information.

A scheduler, on the other hand, is simply a method of choosing which task to switch to next, and its implementation should not be tied to any one processor. There are many different algorithms available (I think recent Linux allows you to choose a different algorithm at compile time), each suited for a different purpose. For example, a server would probably be more efficient with a different algorithm than a workstation, and a real-time system needs something different. Using multiple processors complicates things further. The wiki contains some articles to start from, including Scheduling Algorithms. It isn't paricularly difficult to implement a priority-based round-robin scheduler, which can serve as a base. Adding support for sleeping and blocking tasks isn't that much more difficult. I would suggest looking at Blocking Process for information about delta queues.

Regards,
John.
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post by Dex »

This is not a tut, but its a demo of doing multi-tasking in the boot sector of a floppy.
So is small and easy to follow.
It may help.
Attachments
nanoos2.asm
(9.82 KiB) Downloaded 67 times
readme.txt
(1.58 KiB) Downloaded 34 times
Post Reply