i am writing my own OS and i have a question about multitasking.
I made a simple routine that gives the execution to the same task, just to see if the mechanism is written correct. Unfortunately (at VMWare) a take a kernel stack fault.
I use the same TSS for all tasks, overwriting the address in GDT.
What flags i must put in the TSS selector (in GDT byte 6) ?
Same as code selector (9Ah) or 50h ?
gdt4 is the TSS_Selector (in GDT)
init:
Code: Select all
mov eax, MAX_PROCESSES
shl eax, 8 ;*256
push eax
call MemAlloc
mov dword [ProcessArray], eax
mov edi, eax
mov al, 0
mov [edi+tss.cr3], eax
mov [edi+tss.ss], ss
mov dword [edi+tss.esp], esp
mov [edi+tss.ds], ds
mov [edi+tss.es], ds
mov [edi+tss.cs], cs
mov dword [edi+tss.eip], OS_Main_Loop ;Code to execute
mov byte [edi+tss.eflags+1], 2 ;Enable its interrupts
mov ax, TSS_SEL
ltr ax
mov eax, edi
shr eax, 8 ;Just the interesting bits
mov [gdt4+3], ax ;Change tss descriptor in gdt
mov byte [gdt4+5], 8900h>>8 ;Pretend it isn't busy
Code: Select all
mov eax, dword [ProcessArray]
shr eax, 8 ;Just the interesting bits
mov [gdt4+3], ax ;Change tss descriptor in gdt
mov byte [gdt4+5], 8900h>>8 ;Pretend it isn't busy
jmp TSS_SEL:0 ;Switch tasks
Any help acceptable