-extern void reboot();
-extern void poweroff();
-extern void ide_debug();
-extern void ide_status();
+void reboot();
+void poweroff();
+void ide_debug();
+void ide_status();
+void debug_sched();
void kbd_handler(unsigned int irq, pt_regs_t * regs, void *dev_id)
{
unsigned char scan_code;
if(scan_code == 0x13) // r
ide_debug();
- if(scan_code == 0x1F)
+ if(scan_code == 0x1F) // s
ide_status();
+ if(scan_code == 0x14) // t
+ debug_sched();
+
+// if(scan_code
+
if(count < KBD_BUF_SIZE)
{
count++;
*--------------------------------------------------------------------------
*/
-#ifndef _WAIT_H
-#define _WAIT_H
+#pragma once
#include <list.h>
-typedef struct
+typedef struct
{
- ListHead wait;
-} WaitQueueHead, *pWaitQueueHead;
+ list_head_t wait;
-typedef ListHead WaitQueue, *pWaitQueue;
+} wait_queue_head_t;
-void init_wait_queue(pWaitQueueHead wqh);
+typedef list_head_t wait_queue_t;
-
-#endif //_WAIT_H
+void init_wait_queue(wait_queue_head_t * wqh);
{
static pid_t g_pid = ROOT_TSK_PID;
-
pid_t pid = g_pid;
- g_pid += 123;
-
return pid;
}
-inline void load_cr3(task_union * tsk)
+inline void load_cr3(task_union *tsk)
{
LOAD_CR3(tsk->cr3);
}
root_task.preempt_cnt = 0;
root_task.pid = get_next_pid();
- root_task.ppid = 0;
+ root_task.ppid = 0;
+ root_task.state = TASK_RUNNING;
INIT_LIST_HEAD(&root_task.list);
for(i=0; i<NR_OPENS; i++)
}
}
-inline task_union * get_next_tsk()
+inline task_union *get_next_tsk()
{
return 0;
}
tss.esp0 = tsk->esp0;
}
-inline void switch_to()
+inline void switch_to()
{
load_cr3(current);
set_esp0(current);
);
}
-unsigned long schedule()
+unsigned long schedule()
{
- static task_union *p = &root_task;
+ static task_union *last_sel = &root_task;
+ task_union *sel = &root_task;
+ task_union *p = 0;
+ list_head_t *pos = 0;
- if(p == &root_task)
- p = list_entry(root_task.list.next, task_union, list);
- else
- p = &root_task;
+ list_for_each(pos, &(last_sel->list))
+ {
+ p = list_entry(pos, task_union, list);
+
+ if(p->state == TASK_RUNNING)
+ {
+ sel = p;
+ last_sel = sel;
+ break;
+ }
+ }
- task_union *prev, *next;
- prev = current;
- next = p;
+ task_union *prev = current;
+ task_union *next = sel;
context_switch(prev, next);
}
+void debug_sched()
+{
+ task_union *p = list_entry(root_task.list.next, task_union, list);
+ p->state = (p->state == TASK_RUNNING) ? TASK_INTERRUPTIBLE : TASK_RUNNING;
+}
+
-inline void wake_up(pWaitQueue wq)
+inline void wake_up(wait_queue_t * wq)
{
}
-inline void sleep_on(pWaitQueue wq)
+inline void sleep_on(wait_queue_t * wq)
{
}
*/
#include <wait.h>
-void init_wait_queue(pWaitQueueHead wqh)
+void init_wait_queue(wait_queue_head_t * wqh)
{
INIT_LIST_HEAD(&wqh->wait);
}
-void add_wait_queue(pWaitQueueHead wqh, pWaitQueue wq)
+void add_wait_queue(wait_queue_head_t * wqh, wait_queue_t * wq)
{
list_add_tail(wq, &wqh->wait);
}
-void del_wait_queue(pWaitQueueHead wqh, pWaitQueue old)
+void del_wait_queue(wait_queue_head_t * wqh, wait_queue_t * old)
{
//list_del_init();
}