#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include <errno.h>
#include <sys/syscall.h>
#include <sys/kassert.h>
#include <sys/kconfig.h>
#include <sys/kdebug.h>
#include <sys/kmem.h>
#include <sys/ktime.h>
#include <sys/mp.h>
#include <sys/spinlock.h>
#include <sys/thread.h>
#include <machine/trap.h>
#include <machine/pmap.h>
Go to the source code of this file.
◆ Debug_Processes()
static void Debug_Processes |
( |
int |
argc, |
|
|
const char * |
argv[] |
|
) |
| |
|
static |
Definition at line 269 of file process.c.
270{
272
273
274
275
276
277
278
280 {
281 kprintf(
"Process: %d(%016llx)\n", proc->
pid, proc);
283 }
284
285
286}
int kprintf(const char *fmt,...)
#define TAILQ_FOREACH(var, head, field)
void Process_Dump(Process *proc)
◆ Debug_ProcInfo()
static void Debug_ProcInfo |
( |
int |
argc, |
|
|
const char * |
argv[] |
|
) |
| |
|
static |
Definition at line 291 of file process.c.
292{
294
295 kprintf(
"Current Process State:\n");
297}
Thread * curProc[MAX_CPUS]
◆ Process_Create()
Process_Create –
Create a process.
- Parameters
-
[in] | parent | Parent process. |
[in] | title | Process title. |
- Returns
- The newly created process.
Definition at line 50 of file process.c.
51{
53
54 if (!proc)
56
57 memset(proc, 0,
sizeof(*proc));
58
64
65 if (title) {
67 } else {
68 proc->
title[0] =
'\0';
69 }
70
75 }
77
79
82
84
86 if (parent) {
90 }
96
100
101 return proc;
102}
void CV_Init(CV *cv, const char *name)
void Handle_Init(Process *proc)
#define PROCESS_TITLE_LENGTH
void Slab_Free(Slab *slab, void *obj)
void * Slab_Alloc(Slab *slab) __attribute__((malloc))
#define MEM_USERSPACE_STKBASE
#define TAILQ_INSERT_TAIL(head, elm, field)
void Semaphore_Init(Semaphore *sema, int count, const char *name)
void Spinlock_Unlock(Spinlock *lock) __UNLOCK_EX(*lock)
#define SPINLOCK_TYPE_NORMAL
void Spinlock_Lock(Spinlock *lock) __LOCK_EX(*lock)
void Spinlock_Init(Spinlock *lock, const char *name, uint64_t type)
char * strncpy(char *to, const char *from, size_t len)
void * memset(void *dst, int c, size_t len)
char title[PROCESS_TITLE_LENGTH]
Semaphore zombieSemaphore
ProcessQueue childrenList
void Mutex_Init(Mutex *mtx, const char *name)
◆ Process_Destroy()
static void Process_Destroy |
( |
Process * |
proc | ) |
|
|
static |
Process_Destroy –
Destroy a process. This should not be called direct, but rather by Process_Release.
- Parameters
-
Definition at line 113 of file process.c.
114{
116
123
124
125
126
130
132}
void Handle_Destroy(Process *proc)
void PMap_DestroyAS(AS *space)
#define TAILQ_REMOVE(head, elm, field)
void Semaphore_Destroy(Semaphore *sema)
void Spinlock_Destroy(Spinlock *lock)
void Mutex_Destroy(Mutex *mtx)
◆ Process_Dump()
void Process_Dump |
( |
Process * |
proc | ) |
|
Definition at line 251 of file process.c.
252{
253 const char *stateStrings[] = {
254 "NULL",
255 "READY",
256 "ZOMBIE"
257 };
258
266}
◆ Process_Lookup()
Process_Lookup –
Lookup a process by PID and increment its reference count.
- Parameters
-
- Return values
-
- Returns
- Process that corresponds to the pid.
Definition at line 145 of file process.c.
146{
149
154 proc = p;
155 break;
156 }
157 }
159
160 return proc;
161}
void Process_Retain(Process *proc)
◆ Process_Release()
void Process_Release |
( |
Process * |
proc | ) |
|
Process_Release –
Decrement the reference count for a given process.
- Parameters
-
proc | Process to release a reference of. |
Definition at line 185 of file process.c.
186{
188 if (__sync_fetch_and_sub(&proc->
refCount, 1) == 1) {
190 }
191}
static void Process_Destroy(Process *proc)
◆ Process_Retain()
void Process_Retain |
( |
Process * |
proc | ) |
|
Process_Retain –
Increment the reference count for a given process.
- Parameters
-
proc | Process to retain a reference to. |
Definition at line 171 of file process.c.
172{
174 __sync_fetch_and_add(&proc->
refCount, 1);
175}
◆ Process_Wait()
Process_Wait –
Wait for a process to exit and then cleanup it's references. If the pid == 0, we wait for any process, otherwise we wait for a specific process.
- Parameters
-
[in] | proc | Parent process. |
[in] | pid | Optionally specify the pid of the process to wait on. |
- Return values
-
- Returns
- Exit status of the process that exited or crashed.
Definition at line 206 of file process.c.
207{
211
212
213
214
215
216
217
218
219
221 return (pid << 16);
222
223
225
226
232
235
237 }
239
240
242
244}
void Thread_Release(Thread *thr)
#define TAILQ_FIRST(head)
#define TAILQ_EMPTY(head)
#define SYSCALL_PACK(_errcode, _val)
void Process_Release(Process *proc)
◆ REGISTER_DBGCMD() [1/2]
REGISTER_DBGCMD |
( |
processes |
, |
|
|
"Display list of processes" |
, |
|
|
Debug_Processes |
|
|
) |
| |
◆ REGISTER_DBGCMD() [2/2]
REGISTER_DBGCMD |
( |
procinfo |
, |
|
|
"Display current process state" |
, |
|
|
Debug_ProcInfo |
|
|
) |
| |
◆ curProc
Current thread executing on a given CPU.
Definition at line 41 of file sched.c.
◆ nextProcessID
◆ processList
◆ processSlab
◆ procLock