Executing a task
Executing a task
I'm developing my os for the x86 architecture. I set up the TSS and the task gate descriptor in the GDT. I use the LTR istruction to set up the Task Register. But now i have to do the context switch. In the intel manual, it is written that i can do this in some different mode, for example "using an explicit call to a task with the CALL instruction". Ok, it is clear but.. what is the assembly code to do this?? thanks for reply at this noob question..
Re: Executing a task
1) load the Task Gate Descriptor of the task with the LTR istruction.
2) do a far call to this Task Gate Descriptor.
Example:
More info here: http://www.acm.uiuc.edu/sigops/roll_your_own/5.a.html.
2) do a far call to this Task Gate Descriptor.
Example:
Code: Select all
mov ax, 0x0028 ; 0x28 is the task gate selector
ltr ax
call far 0x0028:0x00000000
"Open source seems to embrace the dark side of human nature." - Ville Turjanmaa
Re: Executing a task
i use this code:
but while i try the lcall it give me a general protection fault..
Code: Select all
asm volatile("movw $0x28, %ax");
asm volatile("ltr %ax");
asm volatile("lcall $0x0,$0x28");
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Executing a task
That's guaranteed to cause an GPF. (call to busy task)1) load the Task Gate Descriptor of the task with the LTR istruction.
2) do a far call to this Task Gate Descriptor.
to change hardware tasks (its slow, most people use software task switching), you can either ljmp, lcall, or iret to it. In any case, the jump only makes sense when the task is not the same as the one pointed to by TR. Both the ljmp and lcall will require an non-busy task, the difference is that with ljmp the original is set to non-busy, while lcall leaves it in the busy state.
Re: Executing a task
So it's better to do a software context switch.. ok... thanks a lot!