Repos / kernel.git / commitdiff
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9878693)
raw | patch | inline | side by side (parent: 9878693)
| author | zhaoyanbai <zhaoyanbai@126.com> | |
| Tue, 24 Jun 2014 00:38:45 +0000 (08:38 +0800) | ||
| committer | zhaoyanbai <zhaoyanbai@126.com> | |
| Wed, 3 Nov 2021 02:42:42 +0000 (10:42 +0800) |
| drivers/keyboard.c | patch | blob | history | |
| include/task.h | patch | blob | history | |
| kernel/init.c | patch | blob | history | |
| kernel/wait.c | patch | blob | history |
diff --git a/drivers/keyboard.c b/drivers/keyboard.c
--- a/drivers/keyboard.c
+++ b/drivers/keyboard.c
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;
diff --git a/include/task.h b/include/task.h
--- a/include/task.h
+++ b/include/task.h
#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
diff --git a/kernel/init.c b/kernel/init.c
--- a/kernel/init.c
+++ b/kernel/init.c
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;");
}
}
diff --git a/kernel/wait.c b/kernel/wait.c
--- a/kernel/wait.c
+++ b/kernel/wait.c
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);
+}