[tt]00009755199p[CPU0 ] >>PANIC<< fetch_raw_descriptor: LDTR.valid=0[/tt]
The funny thing is, the error I get is random. From tests I've done, I'm guessing that the problem might be due to incorrectly setting up the stack for a new function/program.
Below is the source code....
[tt]
_irq0:
???cli
???push gs
???push fs
???push es
???push ds
???pusha
???mov eax, esp?????????; this way the _scheduler routine can get the old esp
???mov [_old_esp], eax
???mov eax, _LINEAR_DATA_SEL???; setup segment registers
???mov ds, eax
???mov es, eax
???mov eax, 0
???mov fs, eax
???mov gs, eax
???mov eax, _scheduler
???call eax????????????; call the scheduler(it's coded in C)
???mov al, 0x20
???out 0x20, al
???mov esp, [_new_esp]
???popa
???pop ds
???pop es
???pop fs
???pop gs
???sti
???iretd
[/tt]
[tt]
u_char first_time=1;
thread_struct My_Threads[1];
u_long new_esp;
u_long old_esp;
void scheduler()
{
???if(first_time == 0)
???{
??????My_Threads[ 0].esp = old_esp;
???} else
???{
??????first_time = 0;
???};
???new_esp = My_Threads[ 0].esp;
};
[/tt]
[tt]
u_short __total_num_threads=0;
void create_thread(thread_struct *new_thread, u_short process_id, u_long eip, u_long ds, u_long cs, u_long ss)
{
???u_char i;
???new_thread->id = __total_num_threads;
???__total_num_threads++;
???new_thread->process_id = process_id;
???new_thread->executing = 0;
???new_thread->sleeping = 0;
???// "push" 8 GP registers
???for(i = 0; i < 7; i++)
???{
??????new_thread->stack = 0xFFFFFFFF;
???};
???new_thread->stack[8] = ds;?????????// ds
???new_thread->stack[9] = 0x8;?????????// es
???new_thread->stack[10] = 0;?????????// fs
???new_thread->stack[11] = 0;?????????// gs
???new_thread->stack[12] = eip;?????????// eip
???new_thread->stack[13] = cs;?????????// cs
???new_thread->stack[14] = 0x200;?????????// eflags
???new_thread->stack[15] = &new_thread->stack[254];???// "old" esp
???new_thread->stack[16] = ss;?????????// ss
???new_thread->esp = &new_thread->stack[ 0];
};
[/tt]
[tt]
typedef struct {
???u_short id;??????// thread's "personal" id, assigned to it by the kernel
???u_short process_id;???// the id of the process that owns the thread
???u_long stack[255];??????// stack for this thread(1024 bytes long)
???u_long esp;??????// esp to this task's stack
} thread_struct;
[/tt]
[tt]
void task_1()
{
???for(;;)
???{
??????putc('a');
??????putc('b');
??????putc('c');
???};
};
[/tt]
The thread is created with:
[tt]create_thread(&My_Threads[ 0], 0, (u_long)&task_1, 0x08, 0x10, 0x08);[/tt]
Hopefully all that code doesn't scare off everyone.

Basically, irq0 is 'installed', a thread is made, and then interrupts are enabled. The first time throught irq0, the thread is started. After that, it should just keep going. The thread does get started and works fine until another task switch though. Then one of the above mentioned errors happen.
Any help at all is appreciated,
K.J.
*hmm... I need a new avatar, everyone seems to be using yoda*