wierd scheduler linked-list stuff [solved]
Posted: Sat Apr 08, 2006 10:47 am
hi all!, ok, my problem is I have switched my scheduler from an array with tasks on it to a linked-list with tasks on it, this doesn't work, the first time the swither gets called and pushes all regs(the first time is switches these should be kernel regs) it stores them in the first task(kernel task)and switches, but it doesn't find the next task(select(); finds the next task with a READY state and sets it as RUNNING_PROCESS) but this fails, it looks like it got intrupted(becouse different emulators get more or less far?)even though i do CLI();? with is another ? i have: when i do get it to crash i get a error with should print the regs then stop the system, but the reg ESP moves!!!!!!!!!! the ONLY way this could happen is if it is being intrupted then crashing with a different ESP over and over so it looks like continueus movement(ESP gest smaller each time), bit i locked the system????how is that possible????
heres the code for the scheduler and process creator: "process.c":
"process.h":
the rest is too long to post so i'll attach it
heres the code for the scheduler and process creator: "process.c":
Code: Select all
#include <los/process.h>
#include <los/memory.h>
#include <los/scheduler.h>
extern int get_pri_time(int pri);
unsigned int PID_count = 0;
struct task_data *make_task(char *name, void (*entry)(), int ring)
{
struct task_data *new_process;
void *stack_mem;
struct stack_data *stack;
new_process = (struct task_data *)malloc(sizeof(struct task_data));
if(new_process == NULL)
return NULL;
new_process->PID = PID_count++;
new_process->P_PID = NULL;
new_process->time = get_pri_time(1);
new_process->priority = 1;
stack_mem = (unsigned int *)malloc(STACK_SIZE);
stack_mem += STACK_SIZE - sizeof(struct stack_data);
stack = stack_mem;
if(ring == 0)
{
stack->gs = KERNEL_DATA_SEG;
stack->fs = KERNEL_DATA_SEG;
stack->es = KERNEL_DATA_SEG;
stack->ds = KERNEL_DATA_SEG;
stack->cs = KERNEL_CODE_SEG;
}
else
{
stack->gs = USER_DATA_SEG;
stack->fs = USER_DATA_SEG;
stack->es = USER_DATA_SEG;
stack->ds = USER_DATA_SEG;
stack->cs = USER_CODE_SEG;
}
stack->edi = 0;
stack->esi = 0;
stack->esp = (unsigned int)stack;
stack->ebp = stack->esp;
stack->ebx = 0;
stack->edx = 0;
stack->ecx = 0;
stack->eax = 0;
stack->eip = (unsigned int)entry;
stack->eflags = 0x00000202;
strncpy(new_process->name, name, 32);
new_process->stack = stack;
new_process->ss = KERNEL_STACK_SEG;
new_process->state = CREATED;
return new_process;
}
Code: Select all
#ifndef __SCHEDULER_H
#define __SCHEDULER_H
#include <los/syslib.h>
#include <los/text.h>
#include <los/scheduler.h>
#include <los/memory.h>
#define STACK_SIZE 64*4
#define KERNEL_CODE_SEG 0x0008
#define KERNEL_STACK_SEG 0x0010
#define KERNEL_DATA_SEG 0x0010
#define USER_CODE_SEG 0x0018
#define USER_STACK_SEG 0x0020
#define USER_DATA_SEG 0x0020
#endif