Rewrite resource subsystem

This commit is contained in:
2026-01-18 20:50:45 +01:00
parent 4f7077d458
commit ddafc4eb19
20 changed files with 453 additions and 225 deletions

View File

@@ -8,6 +8,7 @@
#include <libk/std.h>
#include <proc/resource.h>
#include <proc/suspension_q.h>
#include <sync/rw_spin_lock.h>
#include <sync/spin_lock.h>
#include <sys/mm.h>
@@ -16,14 +17,11 @@
#include <amd64/proc.h> /* USTACK_SIZE */
#endif
/* Process is ready to run */
#define PROC_READY 0
/* Process marked garbage collection */
#define PROC_DEAD 1
/* Process is suspended */
/* process states */
#define PROC_READY 0
#define PROC_DEAD 1
#define PROC_SUSPENDED 2
#define PROC_RESOURCES_MAX 1024
#define PROC_PSEUDO 3
#define PROC_USTK_PREALLOC (1 << 0)
@@ -37,9 +35,11 @@ struct proc_mapping {
size_t size;
};
struct proc_sys_rids {
struct proc_resources {
atomic_int refs;
atomic_int counter;
atomic_int sys_rids;
struct rb_node_link* tree;
rw_spin_lock_t lock;
};
struct proc {
@@ -56,9 +56,8 @@ struct proc {
spin_lock_t lock;
struct cpu* cpu;
atomic_int state;
struct rb_node_link* resource_tree;
struct proc_sys_rids* sys_rids;
struct proc_suspension_q* suspension_q;
struct proc_resources* resources;
};
void proc_suspend (struct proc* proc, struct proc_suspension_q* sq);
@@ -70,6 +69,7 @@ bool proc_map (struct proc* proc, uintptr_t start_paddr, uintptr_t start_vaddr,
bool proc_unmap (struct proc* proc, uintptr_t start_vaddr, size_t pages);
struct elf_aux proc_load_segments (struct proc* proc, uint8_t* elf);
void proc_register (struct proc* proc, struct cpu* cpu);
struct proc* proc_find_pid (int pid);
void proc_init (void);
#endif // _KERNEL_PROC_PROC_H