OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Apr 16, 2024 4:12 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Switching task
PostPosted: Tue Dec 23, 2003 10:49 am 
Here is my taskmanager initialization code:
Code:
void InitTaskManager(void)
{
    lldt(0);

    AddTask(Idle, "Idle task");        //->Sel = 0x18

    ltr(0x18);
    IsScheduleActive = FALSE;
    __asm__ __volatile__ ("ljmp $0x18,$0x0");
}

(to simplify code I just wrote the selector number)
and here is what bochs says:
Code:
[CPU  ] jump_protected: JUMP to busy 386 TSS unsupported.


I just want to jump to my idle task... What am I doing so wrong??


Top
  
 
 Post subject: Re:Switching task
PostPosted: Tue Dec 23, 2003 10:55 am 
Offline
Member
Member
User avatar

Joined: Tue Oct 17, 2006 11:33 pm
Posts: 3882
Location: Eindhoven
Quote:
Code:
    ltr(0x18);

    __asm__ __volatile__ ("ljmp $0x18,$0x0");


Code:
[CPU  ] jump_protected: JUMP to busy 386 TSS unsupported.


I just want to jump to my idle task... What am I doing so wrong??


Well, if you want to jump to your new task, you need to give the new task a TSS. You did.

You also need a TSS for the CURRENT task. You don't have one (you load only the current tasks TSS with ltr). So, when the CPU wants to switch from your current task to your new task, it found out that your new task was already running (you selected it as store for the current data too, so it was active). Solution: make 2 TSSes and load one for the current data, one for the new thread.

PS, why do you want to kickstart the idle thread?


Top
 Profile  
 
 Post subject: Re:Switching task
PostPosted: Tue Dec 23, 2003 3:07 pm 
I load current task with ltr but dont make a far jump to it. Neednt I make a far jump?

Quote:
PS, why do you want to kickstart the idle thread?

This is just a try..


Top
  
 
 Post subject: Re:Switching task
PostPosted: Tue Dec 23, 2003 3:27 pm 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 2:31 am
Posts: 5964
Location: In a galaxy, far, far away
you may never call/jump to the current TSS. period.

If you want to try to switch to another TSS, you need to have set up a current TSS first. If you're not interrested in conserving the current CPU state in any TSS, just load TR register with a selector to a "trash" TSS that you never jump to, but often jump from (that's a trick i learned from TRAN =).

If you just want to tell the CPU which is the "current" TSS, just use the LTR instruction, but do not jump.

_________________
Image May the source be with you.


Top
 Profile  
 
 Post subject: Re:Switching task
PostPosted: Tue Dec 23, 2003 3:29 pm 
Offline
Member
Member
User avatar

Joined: Tue Oct 17, 2006 11:33 pm
Posts: 3882
Location: Eindhoven
Fukuda wrote:
I load current task with ltr but dont make a far jump to it. Neednt I make a far jump?


Well, on a jump to a TSS the current state is stored in the current TSS, and the new state is loaded from the new TSS.

So, you need a TSS to store the current state to, and a TSS to load the new state from. You cannot make them the same, so you have to have some place to dump the current context, even if you never use it again.


Top
 Profile  
 
 Post subject: Re:Switching task
PostPosted: Tue Dec 23, 2003 3:55 pm 
I load ltr with 0x20 and jump to 0x18.
Code:
    lldt(0);

    AddTask(Idle, "Idle task");
    AddTask(taskA, "task A");
    AddTask(taskB, "task B");

    ltr(0x18);
    IsScheduleActive = FALSE;
    __asm__ __volatile__ ("ljmp $0x20,$0x0");

This time bochs gave no error but jmping is not successfull. Because it resets and restarts again continuously. (No scheduler activated yet) What may be wrong?


Top
  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], DotBot [Bot] and 60 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group