void ide_status();
void debug_sched();
void vga_toggle();
-
+int debug_wait_queue_put(unsigned int v);
void kbd_handler(unsigned int irq, pt_regs_t * regs, void *dev_id)
{
unsigned char scan_code;
if(scan_code == 0x3B) // F1
vga_toggle();
+ if(scan_code == 0x3C) // F2
+ debug_wait_queue_put(0);
+ if(scan_code == 0x3D) // F3
+ debug_wait_queue_put(1);
+ if(scan_code == 0x3E) // F4
+ debug_wait_queue_put(2);
+
if((cnsl_rd_q.head+1) == cnsl_rd_q.tail)
goto end;
#define current get_current()
-#define ROOT_TSK_PID (7)
+static inline pid_t sysc_getpid()
+{
+ return current->pid;
+}
+
+
+#define ROOT_TSK_PID (0)
#define TASK_INIT_WEIGHT 10
char __initdata kernel_init_stack[KRNL_INIT_STACK_SIZE] __attribute__ ((__aligned__(PAGE_SIZE)));
-static unsigned int eid = 2;
+static unsigned int eid = 1;
void debug_sem();
+int debug_wait_queue_get();
void init_task_entry()
{
printk("hahahha %s\n", __func__);
debug_sem();
printk("---END----%d\n", id);
}
- printd(id, "task:%d cnt:%d", id, i);
+ printd(id+1, "task:%d cnt:%d", id, i);
+ int v = debug_wait_queue_get();
+ printk("task:%d wait queue get %d\n", id, v);
//asm("sti;");
}
}
void add_wait_queue(wait_queue_head_t *wqh, wait_queue_t *wq)
{
- unsigned long iflags;
- irq_save(iflags);
+ unsigned long flags;
+ irq_save(flags);
list_add_tail(&wq->task_list, &wqh->task_list);
- irq_restore(iflags);
+ irq_restore(flags);
}
void del_wait_queue(wait_queue_head_t *wqh, wait_queue_t *wq)
{
- unsigned long iflags;
- irq_save(iflags);
+ unsigned long flags;
+ irq_save(flags);
list_del(&wq->task_list);
- irq_restore(iflags);
+ irq_restore(flags);
}
void wake_up(wait_queue_head_t *wqh)
// no schedule() here.
}
+
+
+#include<irq.h>
+DECLARE_WAIT_QUEUE_HEAD(debug_wq);
+unsigned int debug_global_var = 0;
+int debug_wait_queue_get()
+{
+ unsigned int v = 0;
+ task_union * task = current;
+ DECLARE_WAIT_QUEUE(wait, task);
+ add_wait_queue(&debug_wq, &wait);
+
+ while(1)
+ {
+ printk("pid %d is going to wait\n", sysc_getpid());
+ task->state = TASK_WAIT;
+
+ disable_irq();
+ v = debug_global_var;
+ if(debug_global_var != 0)
+ debug_global_var--;
+ enable_irq();
+
+ if(v != 0)
+ break;
+
+ schedule();
+ printk("pid %d is running\n", sysc_getpid());
+ }
+
+ printk("pid %d is really running\n", sysc_getpid());
+ task->state = TASK_RUNNING;
+ del_wait_queue(&debug_wq, &wait);
+
+ return v;
+}
+
+int debug_wait_queue_put(unsigned int v)
+{
+ debug_global_var = v;
+ wake_up(&debug_wq);
+}