Modestus Moon OS
R4
CS 450 project
|
Go to the source code of this file.
Data Structures | |
struct | s_pcb_stuct |
defines the properties of a process control block More... | |
Macros | |
#define | PROCESS_CONTEXT_SIZE (32) |
#define | PROCESS_STACK_SIZE (6000) |
#define | PCB_QUEUE_MAX_SIZE (128) |
#define | PROCESS_MAX_NAME_LENGTH (20) |
#define | PROCESS_LOWEST_PRIORITY 0 |
#define | PROCESS_HIGHEST_PRIORITY 9 |
Typedefs | |
typedef struct s_pcb_stuct | pcb_t |
typedef struct s_pcb_list | pcbQueue_t |
typedef size_t | PID_t |
PID_t a type that defines a process operating ID. More... | |
typedef size_t | processPriority_t |
processPriority_t defines a process priority to the system More... | |
typedef uint8_t | programPtr_t |
programPtr_t a pointer to a process's code More... | |
typedef uint32_t | programDataPtr_t |
programDataPtr_t a pointer to a process's data More... | |
typedef uint8_t | processStack_t |
processStack_t a pointer to someplace in a process's stack More... | |
Enumerations | |
enum | e_PCB_ERROR_CODE_t { SUCCESS = 0, ERROR, ERROR_PCB_NOT_FOUND, ERROR_NAME_INVALID, ERROR_PRIORITY_INVALID, ERROR_FREEING_NODE, ERROR_FREEING_STACK, ERROR_FREEING_PCB, ERROR_REMOVING_PCB, ERROR_STATE_INVALID, ERROR_CLASS_INVALID, ERROR_ALLOCATING_NODE, ERROR_NAME_COLLISION, ERROR_INSERTING_PCB } |
The e_PCB_ERROR_CODE_t enum defines the return status of functions working with PCBs. More... | |
enum | e_PROCESS_STATE_t { INITIAL, READY, RUNNING, BLOCKED, TERMINAL, STATE_UNKNOWN } |
The PROCESS_STATE_t enum defines the possible operating states of a process. More... | |
enum | e_PROCESS_SUSPENSION_STATE_t { SUSPENDED, NOT_SUSPENDED, SUSPENSION_UNKNOWN } |
enum | e_PROCESS_CLASS_t { SYSTEM, USER_APP, CLASS_UNKNOWN } |
The PROCESS_CLASS_t enum defines the operating class of the process. More... | |
Functions | |
pcb_t * | allocatePCB (void) |
allocatePCB allocate new memory for a pcb_t More... | |
e_PCB_ERROR_CODE_t | freePCB (pcb_t *pcbToFree) |
freePCB free all associated memory with the PCB, including the stack and other pointers More... | |
pcb_t * | setupPCB (const char *processName, e_PROCESS_CLASS_t processClass, processPriority_t processPriority) |
setupPCB calls allocatePCB, initializes the PCB with the arguments and sets it state to ready More... | |
pcb_t * | findPCB (const char *processName) |
findPCB will search all queues for the PCB with the input name More... | |
void | insertPCB (pcb_t *pcbToInsert) |
insertPCB insert the PCB into the queue represented by the process state, following each queue's rules More... | |
e_PCB_ERROR_CODE_t | removePCB (pcb_t *pcbToRemove) |
removePCB remove the input PCB from its associated queue More... | |
e_PROCESS_STATE_t | getState (const char *name) |
getState gets the current state of the process More... | |
int | pcbSearchFunc (void *pcb, void *nameToFind) |
pcbSearchFunc pcb search function for linked list. All pcb linkedLists use this function for searching See Linked List documentation for a description of a list search function More... | |
int | priorityInsertFunc (void *pcb1, void *pcb2) |
priorityInsertFunc function that inserts pcbs into new pcb queues ordered by the pcbs' priority. See Linked List documentation for a better description of a list insert function. More... | |
int | fifoInsertFunc (void *pcb1, void *pcb2) |
priorityInsertFunc function that inserts pcbs into new pcb queues ordered by the sequence of arrival. See Linked List documentation for a better description of a list insert function. More... | |
void | initPCBQueues (void) |
initPCBQueues initlize the queues for each process queue. This function calls the list init function and sets the function pointers for each list More... | |
void | pcbTest (void) |
pcbTest a simple test case function to show pcb queue functionality More... | |
e_PCB_ERROR_CODE_t | changeProcessState (const char *processName, e_PROCESS_STATE_t state) |
changeProcessState changes the state of the process being called More... | |
e_PCB_ERROR_CODE_t | changeProcessSuspensionState (const char *processName, e_PROCESS_SUSPENSION_STATE_t suspensionState) |
changeProcessSuspensionState More... | |
const char * | errorToString (e_PCB_ERROR_CODE_t error) |
errorToString creates a string form of the error passed in More... | |
const char * | classToString (e_PROCESS_CLASS_t processClass) |
classToString creates a string form of the class passed in More... | |
const char * | stateToString (e_PROCESS_STATE_t state) |
stateToString creates a string form of the state passed in More... | |
e_PROCESS_CLASS_t | stringToClass (const char *stringifiedClass) |
stringToClass returns the enum representation of a string More... | |
e_PCB_ERROR_CODE_t | changeProcessPriority (const char *procName, processPriority_t newPriority) |
changeProcessPriority More... | |
void | printPCBFunc (void *pcb) |
printPCBFunc prints the status of a process More... | |
Variables | |
linkedList_t | readyQueue |
linkedList_t | blockedQueue |
linkedList_t | suspendedReadyQueue |
linkedList_t | suspendedBlockedQueue |
e_PCB_ERROR_CODE_t | prevPCBError |
pcb_t * | currentOperatingProcess |
#define PROCESS_HIGHEST_PRIORITY 9 |
Definition at line 27 of file pcb.h.
Referenced by changeProcessPriority().
#define PROCESS_MAX_NAME_LENGTH (20) |
Definition at line 24 of file pcb.h.
Referenced by setupPCB().
#define PROCESS_STACK_SIZE (6000) |
Definition at line 22 of file pcb.h.
Referenced by setupPCB().
typedef struct s_pcb_stuct pcb_t |
typedef struct s_pcb_list pcbQueue_t |
typedef size_t processPriority_t |
typedef uint8_t processStack_t |
typedef uint32_t programDataPtr_t |
typedef uint8_t programPtr_t |
enum e_PCB_ERROR_CODE_t |
The e_PCB_ERROR_CODE_t enum defines the return status of functions working with PCBs.
Definition at line 38 of file pcb.h.
enum e_PROCESS_CLASS_t |
enum e_PROCESS_STATE_t |
The PROCESS_STATE_t enum defines the possible operating states of a process.
Enumerator | |
---|---|
INITIAL | |
READY | |
RUNNING | |
BLOCKED | |
TERMINAL | |
STATE_UNKNOWN |
pcb_t* allocatePCB | ( | void | ) |
allocatePCB allocate new memory for a pcb_t
Definition at line 15 of file pcb.c.
References ERROR_ALLOCATING_NODE, makeNewNode(), prevPCBError, SUCCESS, and sys_alloc_mem().
Referenced by setupPCB().
e_PCB_ERROR_CODE_t changeProcessPriority | ( | const char * | procName, |
processPriority_t | newPriority | ||
) |
changeProcessPriority
procName | |
newPriority |
Definition at line 342 of file pcb.c.
References ERROR_PCB_NOT_FOUND, ERROR_PRIORITY_INVALID, findPCB(), prevPCBError, PROCESS_HIGHEST_PRIORITY, and SUCCESS.
Referenced by setPriority().
e_PCB_ERROR_CODE_t changeProcessSuspensionState | ( | const char * | processName, |
e_PROCESS_SUSPENSION_STATE_t | suspensionState | ||
) |
changeProcessSuspensionState
name | |
suspensionState |
Definition at line 190 of file pcb.c.
References ERROR_PCB_NOT_FOUND, ERROR_STATE_INVALID, findPCB(), insertPCB(), NOT_SUSPENDED, prevPCBError, removePCB(), SUCCESS, and SUSPENDED.
Referenced by kmain(), resumePCB(), and suspendPCB().
int fifoInsertFunc | ( | void * | pcb1, |
void * | pcb2 | ||
) |
priorityInsertFunc function that inserts pcbs into new pcb queues ordered by the sequence of arrival. See Linked List documentation for a better description of a list insert function.
pcb1 | void* to a pcb to compare with |
pcb2 | void* to the pcb to insert |
pcb_t* findPCB | ( | const char * | processName | ) |
findPCB will search all queues for the PCB with the input name
processName | the name of the PCB searching for |
Definition at line 100 of file pcb.c.
References ERROR_PCB_NOT_FOUND, prevPCBError, searchList(), and SUCCESS.
Referenced by changeProcessPriority(), changeProcessState(), changeProcessSuspensionState(), deletePCB(), getState(), setPriority(), setupPCB(), and showPCB().
e_PCB_ERROR_CODE_t freePCB | ( | pcb_t * | pcbToFree | ) |
freePCB free all associated memory with the PCB, including the stack and other pointers
pcbToFree | pointer to PCB to free |
Definition at line 32 of file pcb.c.
References ERROR_FREEING_NODE, ERROR_FREEING_PCB, ERROR_FREEING_STACK, ERROR_REMOVING_PCB, prevPCBError, removePCB(), and SUCCESS.
Referenced by deletePCB(), and sys_call().
void initPCBQueues | ( | void | ) |
initPCBQueues initlize the queues for each process queue. This function calls the list init function and sets the function pointers for each list
Definition at line 233 of file pcb.c.
References initLinkedList(), pcbSearchFunc(), printPCBFunc(), setPrintFunction(), and setSearchComparisonFunction().
Referenced by kmain().
void insertPCB | ( | pcb_t * | pcbToInsert | ) |
insertPCB insert the PCB into the queue represented by the process state, following each queue's rules
pcbToInsert | pointer to pcb_t to insert |
Definition at line 132 of file pcb.c.
References BLOCKED, ERROR_INSERTING_PCB, insertNode(), NOT_SUSPENDED, prevPCBError, READY, SUCCESS, and SUSPENDED.
Referenced by changeProcessState(), changeProcessSuspensionState(), setupPCB(), and sys_call().
int pcbSearchFunc | ( | void * | pcb, |
void * | nameToFind | ||
) |
pcbSearchFunc pcb search function for linked list. All pcb linkedLists use this function for searching See Linked List documentation for a description of a list search function
pcb | void* to pcb structure |
nameToFind | void* to (const char*) |
Definition at line 228 of file pcb.c.
References strcmp().
Referenced by initPCBQueues().
void pcbTest | ( | void | ) |
pcbTest a simple test case function to show pcb queue functionality
Definition at line 253 of file pcb.c.
References printf, printList(), setupPCB(), sprintf(), and SYSTEM.
int priorityInsertFunc | ( | void * | pcb1, |
void * | pcb2 | ||
) |
priorityInsertFunc function that inserts pcbs into new pcb queues ordered by the pcbs' priority. See Linked List documentation for a better description of a list insert function.
pcb1 | void* to a pcb to compare with |
pcb2 | void* to the pcb to insert |
e_PCB_ERROR_CODE_t removePCB | ( | pcb_t * | pcbToRemove | ) |
removePCB remove the input PCB from its associated queue
pcbToRemove | pointer to pcb_t |
Definition at line 162 of file pcb.c.
References prevPCBError, removeNode(), and SUCCESS.
Referenced by changeProcessState(), changeProcessSuspensionState(), freePCB(), and sys_call().
pcb_t* setupPCB | ( | const char * | processName, |
e_PROCESS_CLASS_t | processClass, | ||
processPriority_t | processPriority | ||
) |
setupPCB calls allocatePCB, initializes the PCB with the arguments and sets it state to ready
processName | the name of the new process |
processClass | the class of the new process |
processPriority | the priority of the new process, must be between 0-9 |
Definition at line 71 of file pcb.c.
References allocatePCB(), ERROR_ALLOCATING_NODE, ERROR_CLASS_INVALID, ERROR_NAME_COLLISION, ERROR_NAME_INVALID, ERROR_PRIORITY_INVALID, findPCB(), insertPCB(), prevPCBError, PROCESS_MAX_NAME_LENGTH, PROCESS_STACK_SIZE, READY, strcpy(), strlen(), SUCCESS, SUSPENDED, SYSTEM, and USER_APP.
Referenced by createPCB(), kmain(), loadr3(), and pcbTest().
linkedList_t blockedQueue |
Definition at line 4 of file pcb.c.
Referenced by showAllProcesses(), and showBlockedProcesses().
pcb_t* currentOperatingProcess |
Definition at line 9 of file pcb.c.
Referenced by allocateMemFromHeap(), freeHeapMem(), and sys_call().
e_PCB_ERROR_CODE_t prevPCBError |
Definition at line 13 of file pcb.c.
Referenced by allocatePCB(), changeProcessPriority(), changeProcessState(), changeProcessSuspensionState(), createPCB(), deletePCB(), findPCB(), freePCB(), getState(), insertPCB(), removePCB(), setupPCB(), and showPCB().
linkedList_t readyQueue |
Definition at line 3 of file pcb.c.
Referenced by idle(), showAllProcesses(), showReadyProcesses(), and sys_call().
linkedList_t suspendedBlockedQueue |
Definition at line 6 of file pcb.c.
Referenced by showAllProcesses().
linkedList_t suspendedReadyQueue |
Definition at line 5 of file pcb.c.
Referenced by showAllProcesses().