9os

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 11d57f50f23ea8fffe3bdabd37f9ecf8c9e1b3f4
parent 4fb757020d858b0826a8a23e2191ed90da5d72fd
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sun, 25 Oct 2020 22:20:52 +0100

os9/proc: Add newspace()

Change-Id: I2213977d0eabb045241474f49a45249520cc1afa

Diffstat:
Minclude/os9/os9.h | 4++--
Msrc/os9/proc.c | 26++++++++++++++++++++++++++
2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/include/os9/os9.h b/include/os9/os9.h @@ -44,7 +44,7 @@ typedef struct qid Qid; typedef struct dir Dir; typedef struct mach Mach; typedef struct map Map; -typedef struct namespace Namespace; +typedef struct nspace Nspace; typedef struct fdset Fdset; typedef struct ref Ref; @@ -193,7 +193,7 @@ struct task { Map *text; Map *data; Map *stack; - Namespace *ns; + Nspace *ns; Fdset *fds; }; diff --git a/src/os9/proc.c b/src/os9/proc.c @@ -2,9 +2,22 @@ #include <limits.h> +struct nspace { + Ref ref; + mutex_t m; + struct mpoint mpoints[NR_MPOINTS]; +}; + static Task tasktab[NR_TASKS]; static void +initref(Ref *rp) +{ + rp->m = 0; + rp->cnt = 0; +} + +static void incref(Ref *rp) { lock(&rp->m); @@ -82,3 +95,16 @@ newslot(void) return (tp != &tasktab[NR_TASKS]) ? tp : NULL; } + +static Nspace * +newspace(Nspace *from) +{ + Nspace *ns; + + ns = alloc(sizeof(*ns)); + if (from) + *ns = *from; + initref(&ns->ref); + + return ns; +}