aboutsummaryrefslogtreecommitdiff
path: root/kernel/features
diff options
context:
space:
mode:
authorMarvin Borner2021-01-15 16:34:19 +0100
committerMarvin Borner2021-01-15 16:34:19 +0100
commit41cba1de51b328979ff2d0261b4141bb4e128fe6 (patch)
tree88ea7bda9e7a675ed0e043ea8662ea9cf3767ce3 /kernel/features
parentd3924f541f36bc08fed87f25ec7fc6e64b86e511 (diff)
Implemented basic dev ready-state waiting
Diffstat (limited to 'kernel/features')
-rw-r--r--kernel/features/proc.c17
-rw-r--r--kernel/features/syscall.c7
2 files changed, 22 insertions, 2 deletions
diff --git a/kernel/features/proc.c b/kernel/features/proc.c
index f792824..af6a307 100644
--- a/kernel/features/proc.c
+++ b/kernel/features/proc.c
@@ -105,7 +105,7 @@ void proc_exit(struct proc *proc, int status)
int res = 0;
struct node *iterator = proc_list->head;
- while (iterator != NULL) {
+ while (iterator) {
if (iterator->data == proc) {
res = 1;
list_remove(proc_list, iterator);
@@ -131,6 +131,21 @@ void proc_yield(struct regs *r)
scheduler(r);
}
+void proc_enable_waiting(u32 dev_id)
+{
+ printf("ENABLING %d\n", dev_id);
+ struct node *iterator = proc_list->head;
+ while (iterator) {
+ struct proc *p = iterator->data;
+ printf("\t-> %s: %d\n", p->name, p->waits_for);
+ if (p && p->waits_for && p->waits_for == dev_id) {
+ //printf("WAKING %s\n", p->name);
+ p->state = PROC_RUNNING;
+ }
+ iterator = iterator->next;
+ }
+}
+
struct proc *proc_make(void)
{
struct proc *proc = malloc(sizeof(*proc));
diff --git a/kernel/features/syscall.c b/kernel/features/syscall.c
index c5570c3..59965a5 100644
--- a/kernel/features/syscall.c
+++ b/kernel/features/syscall.c
@@ -40,8 +40,13 @@ void syscall_handler(struct regs *r)
if (vfs_ready((char *)r->ebx)) {
r->eax = (u32)vfs_read((char *)r->ebx, (void *)r->ecx, r->edx, r->esi);
} else {
- proc_current()->state = PROC_SLEEPING;
+ struct proc *p = proc_current();
+ p->state = PROC_SLEEPING;
+ p->waits_for = vfs_find_dev((char *)r->ebx)->id;
scheduler(r);
+ sti();
+ while (1)
+ hlt();
}
break;
}