summaryrefslogtreecommitdiff
path: root/kernel/scheduler.c
diff options
context:
space:
mode:
authorMiguel <m.i@gmx.at>2018-10-04 02:17:13 +0200
committerMiguel <m.i@gmx.at>2018-10-04 02:17:13 +0200
commit81a8252db679351f5ba388b420519724c9c2c2be (patch)
treed21bb88fb36f9492c0daf14d67c46f0b22b66def /kernel/scheduler.c
parentce16fe524c14ccaae67fb634105da5aef08ead48 (diff)
reverting userspace idea
Diffstat (limited to 'kernel/scheduler.c')
-rw-r--r--kernel/scheduler.c33
1 files changed, 14 insertions, 19 deletions
diff --git a/kernel/scheduler.c b/kernel/scheduler.c
index 9fdff7d..8d7b025 100644
--- a/kernel/scheduler.c
+++ b/kernel/scheduler.c
@@ -174,11 +174,10 @@ volatile uint32_t scheduler_run(uint32_t oldesp,uint32_t preference)
for(int i=0;i<MAX_TASKS;i++)
{
int idx=(current_task[cpu]+1+i)%MAX_TASKS; // schedule round robin style
-// if(idx==2)continue;// skip sleeper here
+ if(idx==2)continue;// skip sleeper here
uint32_t esp=scheduler_schedule(idx);
if(esp)return esp;
}
- kpanic("nothing left to schedule");
// force the sleeper task here ...
return scheduler_schedule(2);
@@ -190,13 +189,13 @@ void scheduler_func()
// we need enable here again (since the pushed eflags have it disabled)? TODO: why they disabled it!???
x86_sti();
-
uint32_t cpu=smp_get(SMP_APIC_ID);
fixme("this will dadlock on context switch during log if never switched back before finish");
if(current_task[cpu]==0)
{
+ /*
while(1)
{
uint64_t t0=x86_rdtscp();
@@ -204,8 +203,12 @@ void scheduler_func()
uint64_t t1=x86_rdtscp();
klog("task 0 / slept cycles: l:%d h:%d",(t1-t0));
}
+ */
-// task_syscall_worker();
+ while(1)
+ {
+ task_syscall_worker();
+ }
//task_list[cpu][0].syscall=true; // sleep
//__asm__("int $0x81"); // wake scheduler! with IPI
@@ -248,8 +251,6 @@ void scheduler_func()
volatile int add_task(uint32_t parent_pid,uint32_t vmem, bool thread, char *name)
{
- static bool first=true;
-
uint32_t parent=task_runs(parent_pid);
uint32_t cpu=smp_get(SMP_APIC_ID);
@@ -286,12 +287,6 @@ volatile int add_task(uint32_t parent_pid,uint32_t vmem, bool thread, char *name
stack[12]=0x1;
stack[13]=0; // this task returns pid=0 to the caller
- if(!thread&&first)
- {
- compositor_add_window(vmem);
- first=false;
- }
-
strcpy(task_list[cpu][i].name,name);
return task_list[cpu][i].pid;
@@ -327,23 +322,22 @@ void scheduler_wake_all()
void task_syscall_worker()
{
uint32_t cpu=smp_get(SMP_APIC_ID);
- task_list[cpu][0].syscall=true; // sleep (syscall misused)
- return;
+ //task_list[cpu][0].syscall=true; // sleep (syscall misused)
+ //return;
/// TODO: cross check all cpus!
while(1)
{
bool wake=false;
bool wake_mouse=false;
-
//TODO: would be enough only to lock during ringbuffer acces!?
//x86_cli(); // disable temporarily mouse/kb/timer interrupts.
//wake|=keyboard_worker();
- //wake_mouse|=mouse_worker();
+ wake_mouse|=mouse_worker();
//x86_sti();
- //if(wake_mouse)compositor_swap_buffers();
+ if(wake_mouse)compositor_swap_buffers();
//if(wake)scheduler_wake_all();
@@ -355,7 +349,7 @@ void task_syscall_worker()
{
uint32_t syscall=task_list[cpu][i].eax;
-// klog("task pid=%d waiting on syscall %d/%s on cpu %d slot %d.",task_list[cpu][i].pid,syscall,syscall_get_name(syscall),cpu,i);
+ //klog("task pid=%d waiting on syscall %d/%s on cpu %d slot %d.",task_list[cpu][i].pid,syscall,syscall_get_name(syscall),cpu,i);
task_list[cpu][0].vmem=task_list[cpu][i].vmem; // switch syscall worker to pagedir of calling userprog
x86_set_page_directory(task_list[cpu][0].vmem);
@@ -486,8 +480,9 @@ volatile int task_add_win(uint32_t pid)
uint32_t cpu=smp_get(SMP_APIC_ID);
uint32_t idx=task_idx(pid);
- struct pdirectory *vmem=task_list[cpu][idx].vmem;
+ struct pdirectory *vmem=x86_get_page_directory();//task_list[cpu][idx].vmem;
vmem_add_framebuffer(vmem);
+ klog("add win to compositor");
compositor_add_window(vmem);
return 0;
}