is Task Switch necessary?

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
AltCtrlDel
Member
Member
Posts: 25
Joined: Sat Jun 25, 2005 11:00 pm

is Task Switch necessary?

Post by AltCtrlDel »

is it possible to implement multitasking without task switching?
i really cant understand its ramifications, if it is really important i will be very thankful if somebody clarifies it
thnx in advance
User avatar
carbonBased
Member
Member
Posts: 382
Joined: Sat Nov 20, 2004 12:00 am
Location: Wellesley, Ontario, Canada
Contact:

Re: is Task Switch necessary?

Post by carbonBased »

If you can't switch tasks, then how can you have more then one task running?

Task switching is a requirement for multitasking in that it provides the mechanism to transfer control from one task to another.

That being said, the method of task switching can vary significantally. Pre-emptive task switching (methods typically based on a timer interrupt that pre-empt tasks in the middle of execution) is not required, if that's what you mean. One could use a co-operative multitasking approach (ala Win3.x).

I would suggest that pre-emptive is the way to go, though.

--Jeff
User avatar
smiddy
Member
Member
Posts: 127
Joined: Sun Oct 24, 2004 11:00 pm
Location: In my cube, like a good leming. ;-)

Re: is Task Switch necessary?

Post by smiddy »

There are two types of task switching too...Hardware and Software. Hardware is by far more programmer friendly. Software means that you have to do a considerable amount of coding to make it work.
-smiddy
rexlunae
Member
Member
Posts: 134
Joined: Sun Oct 24, 2004 11:00 pm
Location: North Dakota, where the buffalo roam

Re: is Task Switch necessary?

Post by rexlunae »

smiddy wrote:There are two types of task switching too...Hardware and Software. Hardware is by far more programmer friendly. Software means that you have to do a considerable amount of coding to make it work.
I completely disagree. My OS does as little messing with segmentation as possible, and consequentially much of what the processor's multitasking does was not useful for me. I found it was extremely simple to just manually switch tasks on an iterrupt.
User avatar
smiddy
Member
Member
Posts: 127
Joined: Sun Oct 24, 2004 11:00 pm
Location: In my cube, like a good leming. ;-)

Re: is Task Switch necessary?

Post by smiddy »

rexlunae wrote:I completely disagree. My OS does as little messing with segmentation as possible, and consequentially much of what the processor's multitasking does was not useful for me. I found it was extremely simple to just manually switch tasks on an iterrupt.
I'm sorry, I'm missing the part you disagree with. I didn't state anything about usefulness. Software task switching may be more useful, but that isn't the point I was making. Certainly anything you can do that doesn't limit your abilities can be more useful, I don't disagree. But the simple fact is hardware task switching is far more easier to implement since you already have everything setup in the hardware. The sheer lines of code difference between the two ways, hardware versus software, software requires more code.
-smiddy
Legend
Member
Member
Posts: 195
Joined: Tue Nov 02, 2004 12:00 am
Contact:

Re: is Task Switch necessary?

Post by Legend »

Well, but I have to disagree, for me at least it was easier to write down a stack layout for the stored state on the stack and code the few lines for a task switch then think about a concept too handle multiple TSS structures (whether I allocate them in the GDT or swap them in and out by hand), initiating a task switch etc.
In fact, I think that at least on Intel (don't know if there is even another platform with something similiar) is bloated.
*post*
rexlunae
Member
Member
Posts: 134
Joined: Sun Oct 24, 2004 11:00 pm
Location: North Dakota, where the buffalo roam

Re: is Task Switch necessary?

Post by rexlunae »

smiddy wrote:I'm sorry, I'm missing the part you disagree with. I didn't state anything about usefulness. Software task switching may be more useful, but that isn't the point I was making. Certainly anything you can do that doesn't limit your abilities can be more useful, I don't disagree. But the simple fact is hardware task switching is far more easier to implement since you already have everything setup in the hardware. The sheer lines of code difference between the two ways, hardware versus software, software requires more code.
I mentioned the usefullness because in an operating system which makes heavy use of segmentation, there would be much more code to do software task switching than I have in mine. I disagree with the statement that it takes more code to do a software task switch than a hardware task switch. I think the difference can be (depending on your OS's requirements) negligable. For my OS, the actual task switch is done in a function written partially in C which is about 10 lines long if I recall correctly, and the only code that ever deals specificly with a TSS is code that sets up the initial one at boot, so I don't have any code to manage TSSes.
Post Reply