Add Userspace Addr Space notion

This commit is contained in:
Mathieu Maret 2022-08-07 23:14:26 +02:00
parent 0e11da855c
commit c59eb339e9

View File

@ -4,12 +4,13 @@
#include "klibc.h"
#include "list.h"
#include "mmuContext.h"
#include "uaddrspace.h"
struct process {
char name[PROCESS_NAME_MAX_LENGTH];
int ref;
int pid;
struct mmu_context *context;
struct uAddrSpace *addrSpace;
struct thread *thList;
struct process *prev, *next;
@ -35,10 +36,9 @@ struct process *processCreate(char *name)
if (new == NULL)
return NULL;
new->context = mmuContextCreate();
if (new->context == NULL) {
new->addrSpace = uAddrSpaceCreate(new);
if(new->addrSpace == NULL){
free(new);
return NULL;
}
@ -103,6 +103,7 @@ int processRef(struct process *proc)
int processUnref(struct process *proc)
{
uint32_t flags;
int ret;
assert(proc->ref > 0);
@ -116,10 +117,10 @@ int processUnref(struct process *proc)
list_delete(processList, proc);
restore_IRQs(flags);
mmuContextUnref(proc->context);
ret = uAddrSpaceDelete(proc->addrSpace);
free(proc);
return 0;
return ret;
}
int processAddThread(struct process *proc, struct thread *th)
@ -164,5 +165,5 @@ int processSetName(struct process *proc, char *name)
struct mmu_context *processGetMMUContext(struct process *proc)
{
return proc->context;
return uAddrSpaceGetMMUContext(proc->addrSpace);
}