48 lines
1.9 KiB
C
48 lines
1.9 KiB
C
// TODO: CHECK/REPLACE/UPDATE OLD CODE (this file is based on xv6)
|
|
|
|
#include "fpu.h"
|
|
#include "sched.h"
|
|
#include "fsinstance.h"
|
|
|
|
#define PROC_NAME_SIZE 16
|
|
|
|
// Per-process state
|
|
struct proc {
|
|
sched_spinlock_t lock;
|
|
|
|
// p->lock must be held when using these:
|
|
sched_state_t state; // Process state
|
|
void *chan; // If non-zero, sleeping on chan
|
|
int killed; // If non-zero, have been killed
|
|
int prio; // Priority level
|
|
int maxprio; // Maximum priority level (LOWEST number the program can set)
|
|
int xstate; // Exit status to be returned to parent's wait
|
|
int pid; // Process ID
|
|
int cwdrive; // Current drive index, paired to cwd
|
|
struct drives* drives; // Drives structure, could differ in the future
|
|
int timeslice;
|
|
int reserved;
|
|
|
|
// wait_lock must be held when using this:
|
|
struct proc *parent; // Parent process
|
|
|
|
struct proc *mainthread; // Pointer to the main-thread process (possibly this or parent) or 0 if single-threaded
|
|
|
|
// these are private to the process, so p->lock need not be held.
|
|
uint64 kstack; // Virtual address of kernel stack
|
|
uint64 sz; // Size of process memory (bytes)
|
|
pagetable_t pagetable; // User page table
|
|
sched_frame_t *trapframe; // data page for trampoline.S
|
|
sched_context_t context;
|
|
//struct context context; // swtch() here to run process
|
|
fpu_context_t fpu_context;
|
|
struct file *ofile[NOFILE]; // Open files
|
|
fsinstance_inode_t *cwd; // Current directory
|
|
int fpu_active;
|
|
int fpu_saved;
|
|
char name[PROC_NAME_SIZE]; // Process name (debugging)
|
|
|
|
// this in theory should maybe lock on affinity_lock, but is probably safe to test without locking (what is the worst case scenario?)
|
|
uint64 affinitymask; // Mask of whether this process should run on CPU #0 to #63 (this can be extended)
|
|
};
|