sched: apply proper blocking mechanism for chardev

Signed-off-by: Michael Shaw <spencershawiscool@gmail.com>
This commit is contained in:
Michael Shaw 2024-06-17 14:09:53 -04:00
commit dfed938383
12 changed files with 183 additions and 24 deletions

View file

@ -3,13 +3,5 @@
#define _CHAR_H_
#include <kernel/common.h>
#include <kernel/proc.h>
struct char_queue {
char *buf;
size_t size;
struct proc *proc;
struct char_queue *next;
};
#endif /* _CHAR_H_ */

View file

@ -31,6 +31,8 @@
void yield();
void panic();
void cli();
void sti();
typedef uintptr_t paddr_t;
typedef uint32_t paddr32_t;

View file

@ -65,9 +65,25 @@ struct proc {
sem_t block_sem;
};
struct proc_block_queue {
struct proc_block_node *head;
spinlock_t lock;
};
struct proc_block_node {
struct proc *proc;
void *dev;
void *buf;
bool read;
size_t size;
struct proc_block_node *next;
};
struct procregs *proc_current_regs();
void proc_block(pid_t pid);
void proc_block(struct proc *proc, void *dev, void *buf, bool read, size_t size);
void proc_unblock(pid_t pid);
struct proc_block_node *proc_block_find(void *dev);
void proc_block_remove(struct proc_block_node *node);
struct proc *proc_create();
struct proc *proc_get(pid_t pid);
pid_t getpid();

View file

@ -7,4 +7,9 @@
#define SYS_OPEN 2
#define SYS_EXIT 60
#include <kernel/common.h>
#include <kernel/proc.h>
void sys_set_return(struct proc *proc, uint64_t ret);
#endif /* _SYSCALL_H_ */

9
include/kernel/umem.h Normal file
View file

@ -0,0 +1,9 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef _UMEM_H_
#define _UMEM_H_
#include <kernel/proc.h>
void copy_to_user(struct proc *proc, void *dst, const void *src, size_t size);
#endif /* _UMEM_H_ */