Adding Tasks

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
Paeron

Adding Tasks

Post by Paeron »

What is the common way to add a new tast to a system. I figured it was to add an entry in the GDT. If it is so I would like to know how that is done or if there is a good page where this is brought up... ???
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Adding Tasks

Post by Pype.Clicker »

checked the "multitasking tutorial" on BlueIllusion already ? It sounds from your question that you're expecting the CPU to magically switch among TSSes as soon as there are multiple task state segments in the GDT. No such thing occurs, of course

It's up to you to change from one TSS to another using the proper "jmp <tss>:0" at the right moment ...
BI lazy

Re:Adding Tasks

Post by BI lazy »

Here's the web: www.distantvoices.org. The link to the text is on the first page. Just search for "multitasking" and click on it. *gg*
Paeron

Re:Adding Tasks

Post by Paeron »

Pype.Clicker wrote: checked the "multitasking tutorial" on BlueIllusion already ? It sounds from your question that you're expecting the CPU to magically switch among TSSes as soon as there are multiple task state segments in the GDT. No such thing occurs, of course

It's up to you to change from one TSS to another using the proper "jmp <tss>:0" at the right moment ...
I am sorry if I was unclear but I ment no such thing. I am aware on how to switch tasks and all that. I've spent the last months reading that darn Intel Architecture manual. But that only said how to create tasks from the beginning of the run not how that would be done during Run-time..
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Adding Tasks

Post by Pype.Clicker »

well, basically it is the same work, except that you first must identify free selectors for your new TSS (and stack segment ?) ... then you just initialize the TSS as if it was present from the system boottime and insert them in some kind of dynamic list that says they are ready for running ...
Paeron

Re:Adding Tasks

Post by Paeron »

so you mean that you have a gdt full of empty tss refferences that point to null and then when you nead one you change the values to point to the newly loaded prg?
BI lazy

Re:Adding Tasks

Post by BI lazy »

oh sweet gosh a'mighty in the trashbin...

paeron, read my text carefully. You'll find it there: how to setup a task control block, the most basic structure in an Operating System. It is an example, but one taken from an existing and functional OS.

But take into consideration, that it is not only done with this to setup a full fledged process: you 1. need the task control block, 2. Process Memory Space Control Block (in the memory management subsystem, if you do a micro kernel), 3. Process File management block (in the file service, if you do a micro kernel). In a Monolithic kernel these three are usually merged to one big beast.

You need to set up either a local descriptor table for the process or a pagediretory (which is far simpler to handle), you need to assign memory regions to the process and you need to setup a method to init the process upon first scheduling it for running. (0xdeadbeef is a helpful thing)

Well ... I talk from the viewpoint of one who's got this stuff up and running already. Except of some nasty bug that slipped in recently (aw damn, two days spent debugging and still only a faint hint on what might go wrong ... *gnarfl* ... basically it is setting the wrong message_from parameter upon receiving... on more night doing the debug thing is due)
BI lazy

Re:Adding Tasks

Post by BI lazy »

and for the startup ... dunno, it is as Pye has said, nearby the same grunt work. You have of course to do some extra work ere all the helper subsystems can bite in.
Paeron

Re:Adding Tasks

Post by Paeron »

OKOK. No nead to blow your fuses! I did read your post but I was going to save that page for later reading. So I thought I could get some leading answers to get my mind rolling... But I will read the thing and ask no further questions.

Thanx for the Help!
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Adding Tasks

Post by Pype.Clicker »

Paeron wrote: so you mean that you have a gdt full of empty tss refferences that point to null and then when you nead one you change the values to point to the newly loaded prg?
they do not need to be 'empty TSS references'. They can simply be non-present descriptors that you tag somehow to inform the system they're free. In Clicker i used a 'reserved' type to do so and used a part of the descriptor as a 'link to next free descriptor" in the table.

But indeed, everytime a new program is loaded, a free descriptor will become a TSS descriptor and the content of that task segment will be loaded with values that describes your initial program state.
aladdin

Re:Adding Tasks

Post by aladdin »

after ading a first tss(for the kernel) desc to my gdt I did this instruction :

Code: Select all

asm ("ltr %%ax" :: "a"(kerneltss);
this seems to work well but the when I set the busy bit to 1 it hang.

question : to make kernel as a first task we must set busy bit to 0 or one ? it is necessery to associate an ldt to the kernel before doing the ltr ?
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Adding Tasks

Post by Pype.Clicker »

The software shouldn't be playing with the BUSY bit. It will be set/cleared/checked by the CPU when needed. Check the Intel Manual (table with jmp / call / ret to a task effects) for details.
aladdin

Re:Adding Tasks

Post by aladdin »

thank's, I've allready read the intel manual, but i have not paid attention to that part ::)
Post Reply