Modestus Moon OS  R4
CS 450 project
pcb.h
Go to the documentation of this file.
1 
15 #ifndef PCB_H
16 #define PCB_H
17 
18 #include <system.h>
19 #include <linked_list.h>
20 
21 #define PROCESS_CONTEXT_SIZE (32) //4*32
22 #define PROCESS_STACK_SIZE (6000) //bytes
23 #define PCB_QUEUE_MAX_SIZE (128)
24 #define PROCESS_MAX_NAME_LENGTH (20)
25 
26 #define PROCESS_LOWEST_PRIORITY 0
27 #define PROCESS_HIGHEST_PRIORITY 9
28 
33 
34 
43 
48 
50 
55 
61 typedef struct s_pcb_stuct pcb_t;
62 
63 
64 
65 
67 
68 
69 
70 
71 
77 typedef struct s_pcb_list pcbQueue_t;
78 
82 typedef size_t PID_t;
83 
87 typedef size_t processPriority_t;
88 
93 
98 
103 
108 {
111  size_t priority;
112 
115 
117 
120 
121  //pcb_queue_t children;
122 
124  size_t programSize;
125 
127  size_t dataSize;
128 
131 
133 
134 };
135 
140 pcb_t* allocatePCB(void);
141 
147 e_PCB_ERROR_CODE_t freePCB(pcb_t* pcbToFree);
148 
156 pcb_t* setupPCB(const char* processName, e_PROCESS_CLASS_t processClass, processPriority_t processPriority);
157 
163 pcb_t* findPCB(const char* processName);
164 
169 void insertPCB(pcb_t* pcbToInsert);
170 
176 e_PCB_ERROR_CODE_t removePCB(pcb_t* pcbToRemove);
177 
184 e_PROCESS_STATE_t getState(const char* name);
192 int pcbSearchFunc(void* pcb, void* nameToFind);
193 
201 int priorityInsertFunc(void* pcb1, void* pcb2);
202 
210 int fifoInsertFunc(void* pcb1, void* pcb2);
211 
216 void initPCBQueues(void);
217 
221 void pcbTest(void);
222 
230 e_PCB_ERROR_CODE_t changeProcessState(const char* processName, e_PROCESS_STATE_t state);
231 
240 e_PCB_ERROR_CODE_t changeProcessSuspensionState(const char* processName, e_PROCESS_SUSPENSION_STATE_t suspensionState);
241 
248 const char* errorToString(e_PCB_ERROR_CODE_t error);
249 
257 
264 const char* stateToString(e_PROCESS_STATE_t state);
265 
273 e_PROCESS_CLASS_t stringToClass(const char * stringifiedClass);
274 
283 
289 void printPCBFunc(void* pcb);
290 
291 #endif // PCB_H
e_PCB_ERROR_CODE_t prevPCBError
Definition: pcb.c:13
Definition: pcb.h:54
void pcbTest(void)
pcbTest a simple test case function to show pcb queue functionality
Definition: pcb.c:253
e_PROCESS_SUSPENSION_STATE_t
Definition: pcb.h:49
Definition: pcb.h:47
Definition: pcb.h:47
typedef of linked list node (see s_ll_node).
linkedList_t readyQueue
Definition: pcb.c:3
void printPCBFunc(void *pcb)
printPCBFunc prints the status of a process
Definition: pcb.c:335
size_t programSize
Definition: pcb.h:124
const char * errorToString(e_PCB_ERROR_CODE_t error)
errorToString creates a string form of the error passed in
Definition: pcb.c:267
programPtr_t * programStart
Definition: pcb.h:123
processStack_t * stackTop
Definition: pcb.h:130
#define PROCESS_MAX_NAME_LENGTH
Definition: pcb.h:24
Definition: pcb.h:49
const char * procName
Definition: mcb.h:43
int pcbSearchFunc(void *pcb, void *nameToFind)
pcbSearchFunc pcb search function for linked list. All pcb linkedLists use this function for searchin...
Definition: pcb.c:228
void initPCBQueues(void)
initPCBQueues initlize the queues for each process queue. This function calls the list init function ...
Definition: pcb.c:233
pcb_t * currentOperatingProcess
Definition: pcb.c:9
e_PROCESS_STATE_t processState
Definition: pcb.h:113
The s_processContext struct defines the context that each process stores .
Definition: system.h:71
const char * classToString(e_PROCESS_CLASS_t processClass)
classToString creates a string form of the class passed in
Definition: pcb.c:289
processStack_t * stackBase
Definition: pcb.h:129
pcb_t * findPCB(const char *processName)
findPCB will search all queues for the PCB with the input name
Definition: pcb.c:100
typedef of linked list (see s_ll).
e_PROCESS_SUSPENSION_STATE_t processSuspensionState
Definition: pcb.h:114
int priorityInsertFunc(void *pcb1, void *pcb2)
priorityInsertFunc function that inserts pcbs into new pcb queues ordered by the pcbs&#39; priority...
Definition: pcb.c:223
e_PCB_ERROR_CODE_t changeProcessPriority(const char *procName, processPriority_t newPriority)
changeProcessPriority
Definition: pcb.c:342
unsigned char uint8_t
Definition: system.h:29
Definition: pcb.h:38
#define PROCESS_STACK_SIZE
Definition: pcb.h:22
linkedList_t blockedQueue
Definition: pcb.c:4
node_t * representingNode
Definition: pcb.h:132
typedef for pcb_t struct
void insertPCB(pcb_t *pcbToInsert)
insertPCB insert the PCB into the queue represented by the process state, following each queue&#39;s rule...
Definition: pcb.c:132
e_PCB_ERROR_CODE_t freePCB(pcb_t *pcbToFree)
freePCB free all associated memory with the PCB, including the stack and other pointers ...
Definition: pcb.c:32
Definition: pcb.h:54
defines the properties of a process control block
Definition: pcb.h:107
size_t priority
Definition: pcb.h:111
pcb_t * allocatePCB(void)
allocatePCB allocate new memory for a pcb_t
Definition: pcb.c:15
typedef for pcbQueue_t struct
uint32_t programDataPtr_t
programDataPtr_t a pointer to a process&#39;s data
Definition: pcb.h:97
processStack_t stack[PROCESS_STACK_SIZE]
Definition: pcb.h:119
uint8_t processStack_t
processStack_t a pointer to someplace in a process&#39;s stack
Definition: pcb.h:102
e_PCB_ERROR_CODE_t removePCB(pcb_t *pcbToRemove)
removePCB remove the input PCB from its associated queue
Definition: pcb.c:162
linkedList_t suspendedBlockedQueue
Definition: pcb.c:6
const char * stateToString(e_PROCESS_STATE_t state)
stateToString creates a string form of the state passed in
Definition: pcb.c:301
e_PROCESS_CLASS_t processClass
Definition: pcb.h:116
Definition: pcb.h:47
unsigned long uint32_t
Definition: system.h:31
e_PROCESS_STATE_t
The PROCESS_STATE_t enum defines the possible operating states of a process.
Definition: pcb.h:47
size_t PID_t
PID_t a type that defines a process operating ID.
Definition: pcb.h:82
e_PROCESS_CLASS_t stringToClass(const char *stringifiedClass)
stringToClass returns the enum representation of a string
Definition: pcb.c:328
Definition: pcb.h:47
programDataPtr_t * dataStart
Definition: pcb.h:126
Definition: pcb.h:38
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 ...
Definition: pcb.c:71
e_PCB_ERROR_CODE_t changeProcessSuspensionState(const char *processName, e_PROCESS_SUSPENSION_STATE_t suspensionState)
changeProcessSuspensionState
Definition: pcb.c:190
e_PCB_ERROR_CODE_t
The e_PCB_ERROR_CODE_t enum defines the return status of functions working with PCBs.
Definition: pcb.h:38
e_PROCESS_STATE_t getState(const char *name)
getState gets the current state of the process
Definition: pcb.c:210
e_PCB_ERROR_CODE_t changeProcessState(const char *processName, e_PROCESS_STATE_t state)
changeProcessState changes the state of the process being called
Definition: pcb.c:168
PID_t PID
Definition: pcb.h:110
linkedList_t suspendedReadyQueue
Definition: pcb.c:5
int fifoInsertFunc(void *pcb1, void *pcb2)
priorityInsertFunc function that inserts pcbs into new pcb queues ordered by the sequence of arrival...
Definition: pcb.c:217
char name[PROCESS_MAX_NAME_LENGTH]
Definition: pcb.h:109
Definition: pcb.h:47
processContext_t * context
Definition: pcb.h:118
e_PROCESS_CLASS_t
The PROCESS_CLASS_t enum defines the operating class of the process.
Definition: pcb.h:54
size_t dataSize
Definition: pcb.h:127
uint8_t programPtr_t
programPtr_t a pointer to a process&#39;s code
Definition: pcb.h:92
size_t processPriority_t
processPriority_t defines a process priority to the system
Definition: pcb.h:87