diff options
| author | Miguel <m.i@gmx.at> | 2018-09-20 20:51:57 +0200 |
|---|---|---|
| committer | Miguel <m.i@gmx.at> | 2018-09-20 20:51:57 +0200 |
| commit | aeefdb37d1fc1c0eb7953b9c196cab09460bc167 (patch) | |
| tree | 513789d7fd28b65afb594e9605975bd10ea06f74 /kernel/scheduler.c | |
| parent | 763f85c55fdb5a2c4f5bf98e4989a69d27da6e4f (diff) | |
we are now prepared for piping with _pipe and _dup2
Diffstat (limited to 'kernel/scheduler.c')
| -rw-r--r-- | kernel/scheduler.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/kernel/scheduler.c b/kernel/scheduler.c index e834afc..56f6bbc 100644 --- a/kernel/scheduler.c +++ b/kernel/scheduler.c @@ -23,13 +23,13 @@ //TODO: ugly! extern ringbuffer kb_in; -static volatile uint32_t pid=1000; +static volatile uint32_t pid=0; static uint32_t nextPID() { spinlock_spin(SPINLOCK_PID); - pid++; uint32_t ret=pid; + pid++; spinlock_release(SPINLOCK_PID); return ret; } @@ -40,19 +40,19 @@ static volatile uint32_t current_task[SMP_MAX_PROC]; // we hold this stuff per cpu static volatile struct task_list_struct { - volatile bool active; // is this slot used (Y/N) + volatile bool active; // is this slot used (Y/N) volatile uint32_t pid; // process id volatile uint32_t parent; // parent process id volatile uint32_t esp; // stack pointer of the task volatile uint32_t esp0; // tss.esp0 - volatile struct pdirectory *vmem; // number of virtual memory table + volatile struct pdirectory *vmem; // number of virtual memory table volatile uint32_t brk; // memory brk pos - volatile bool try; // waiting coz syscall not processed yet - volatile bool syscall; // syscall in progress - volatile uint32_t eax; + volatile bool try; // try to process syscall + volatile bool syscall; // syscall not processed yet + volatile uint32_t eax; // syscall details volatile uint32_t ebx; volatile uint32_t ecx; volatile uint32_t edx; @@ -78,10 +78,12 @@ volatile void scheduler_init(uint32_t cpu, void *dir) task_list[cpu][0].pid=nextPID(); task_list[cpu][0].active=true; task_list[cpu][0].syscall=false; - task_list[cpu][1].thread=false; + task_list[cpu][0].thread=false; task_list[cpu][0].vmem=dir; task_list[cpu][0].esp = VMEM_CPU_STACK_TOP-0x200; task_list[cpu][0].esp0 = 0; // esp0 not needed by kernel space tasks + fd_init_std_streams(task_list[cpu][0].pid); + // this will go to userspace task_list[cpu][1].parent=0; @@ -92,6 +94,7 @@ volatile void scheduler_init(uint32_t cpu, void *dir) task_list[cpu][1].vmem=dir; task_list[cpu][1].esp = kballoc(4)+4*4096-0x200; // 4 pages stack task_list[cpu][1].esp0 =kballoc(4)+4*4096; // esp0 not needed by kernel space tasks + fd_init_std_streams(task_list[cpu][1].pid); // sleeper @@ -103,6 +106,7 @@ volatile void scheduler_init(uint32_t cpu, void *dir) task_list[cpu][2].vmem=dir; task_list[cpu][2].esp = kballoc(4)+4*4096-0x200; // 4 pages stack task_list[cpu][2].esp0 =kballoc(4)+4*4096; // esp0 not needed by kernel space tasks + fd_init_std_streams(task_list[cpu][2].pid); // stacks task_pusha(task_list[cpu][0].esp); |
