Modestus Moon OS
R4
CS 450 project
|
#include <core/pcb.h>
Go to the source code of this file.
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_PCB_ERROR_CODE_t | changeProcessState (const char *processName, e_PROCESS_STATE_t newState) |
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... | |
e_PROCESS_STATE_t | getState (const char *name) |
getState gets the current state of the process 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... | |
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 | 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... | |
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... | |
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... | |
const char * | suspensionToString (e_PROCESS_SUSPENSION_STATE_t state) |
e_PROCESS_CLASS_t | stringToClass (const char *stringifiedClass) |
stringToClass returns the enum representation of a string More... | |
void | printPCBFunc (void *pcb) |
printPCBFunc prints the status of a process More... | |
e_PCB_ERROR_CODE_t | changeProcessPriority (const char *procName, processPriority_t newPriority) |
changeProcessPriority More... | |
Variables | |
linkedList_t | readyQueue |
linkedList_t | blockedQueue |
linkedList_t | suspendedReadyQueue |
linkedList_t | suspendedBlockedQueue |
pcb_t * | currentOperatingProcess = 0 |
e_PCB_ERROR_CODE_t | prevPCBError |
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
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().
const char* suspensionToString | ( | e_PROCESS_SUSPENSION_STATE_t | state | ) |
Definition at line 317 of file pcb.c.
References NOT_SUSPENDED, SUSPENDED, and SUSPENSION_UNKNOWN.
Referenced by printPCBFunc().
linkedList_t blockedQueue |
Definition at line 4 of file pcb.c.
Referenced by showAllProcesses(), and showBlockedProcesses().
pcb_t* currentOperatingProcess = 0 |
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().