Modestus Moon OS
R4
CS 450 project
|
#include <comm_vars.h>
#include <core/rtc.h>
#include <string.h>
#include <input.h>
#include "include/comm_list.h"
#include <core/pcb.h>
#include <linked_list.h>
#include <core/mcb.h>
#include "../procsr3.h"
Go to the source code of this file.
Functions | |
int | getNumDaysInMonth (int month, int year) |
getNumDaysInMonth is a helper function to allow the easy retrieval of days in a month based on the month input by the user. More... | |
int | isEmpty (char parameters[][MAX_LENGTH]) |
int | helpFunc (char parameters[][MAX_LENGTH]) |
helpFunc calls the other help functions More... | |
void | help () |
help prints out a list of all possible commands and a brief description of what they do. More... | |
void | helpMCB (char parameters[][MAX_LENGTH]) |
The command handler for mcb's checking for valid input. More... | |
void | helpMcbPrint () |
Prints the help menu for all mcb functions. More... | |
void | helpMCBInitHeap () |
prints the all details about the initheap func More... | |
void | helpMCBAllocate () |
Prints the details for Allocating an mcb. More... | |
void | helpMCBFreeMem () |
Prints the details for freeing an mcb. More... | |
void | helpMCBIsEmpty () |
Prints details for IsEmpty func. More... | |
void | helpMCBShowFree () |
Prints details for showing all the free memory blocks in the heap. More... | |
void | helpMCBShowAllocated () |
Prints details for showing all the allocated memory blocks in the heap. More... | |
void | helpLoadR3 () |
helpLoadR3 prints out the help commands for helpLoadR3 Loads all of the processes from procsr3 More... | |
int | helpGetVersion () |
helpGetVersion prints the help instructions for version. Tells the user what the command and arguments for 'version' are. More... | |
void | helpGetDate () |
helpGetDate prints the help instructions for get date. Tells the user what the command and arguments for 'get date' are. More... | |
void | helpSetDate () |
helpSetDate prints the help instructions for set date. Tells the user what the command and arguments for 'set date' are. More... | |
void | helpGetTime () |
helpGetTime prints the help instructions for get time. Tells the user what the commands and arguments for 'get time' are. More... | |
void | helpSetTime () |
helpSetTime prints the help instructions for set time. Tells the user what the command and arguments for 'set time' are. More... | |
void | helpShutdown () |
helpShutdown prints the help instructions for set date. Tells the user what the command and arguments for 'set date' are. More... | |
void | helpVersion () |
helpVersion prints the help instructions for using the version command. No arguments are required. More... | |
void | helpDate (char parameters[][MAX_LENGTH]) |
helpDate prints out the help information for date, for date –set and date –get More... | |
void | helpTime (char parameters[][MAX_LENGTH]) |
helpTime prints out the help information for time, for time –set and time –get More... | |
void | helpPcb (char parameters[][MAX_LENGTH]) |
helpPcb takes in the command to print the help information for. Calls the proper function to print the help information for the selected command. More... | |
void | helpPcbPrint () |
helpPcbPrint prints out the commands for PCBs. More... | |
void | helpSuspendPCB () |
helpSuspendPCB prints the help instructions for the suspendPCB command. More... | |
void | helpResumePCB () |
helpResumePCB prints out the parameters and usage of the resume pcb command. More... | |
void | helpSetPriority () |
helpSetPriority prints out to console the parameters and usage for –setpriority. More... | |
void | helpShowPCB () |
void | helpShowAllProcesses () |
helpShowAllProcesses shows all processes in the system. Takes in no parameters and prints out to the console. More... | |
void | helpShowReadyProcesses () |
helpShowReadyProcesses shows the parameters and usage for showing ready PCBs. More... | |
void | helpShowBlockedProcesses () |
helpShowBlockedProcesses shows the parameters and usage for showing the blocked PCBs. More... | |
void | helpCreatePCB () |
helpCreatePCB prints out the parameters and usage for createPCB. More... | |
void | helpDeletePCB () |
helpDeletePCB prints out the parameters and usage for deleting a PCB. More... | |
void | helpBlockPCB () |
helpBlockPCB prints out the parameters and usage for blocking a PCB. More... | |
void | helpUnblockPCB () |
helpUnblockPCB prints out the parameters and usage for unblocking a PCB. More... | |
int | version (char parameters[][MAX_LENGTH]) |
version prints out the current version of the operating system. It will print out R1, R2, R3, ... depending on the current module. More... | |
int | date (char parameters[][MAX_LENGTH]) |
void | getDate () |
getDate Get the current date from the system. More... | |
void | setDate (char parameters[][MAX_LENGTH]) |
setDate sets the system date using the input from the user. More... | |
int | time (char parameters[][MAX_LENGTH]) |
void | getTime () |
getTime this function has the side-effect of printing the current time to the terminal. More... | |
void | setTime (char parameters[][MAX_LENGTH]) |
setTime sets the current system time from the users input. More... | |
int | shutdownFunc (char parameters[][MAX_LENGTH]) |
shutdownFunc shuts down the OS. More... | |
int | pcbFunc (char parameters[][MAX_LENGTH]) |
takes in parameters and makes sure its valid then runs what you want to. More... | |
int | suspendPCB (char parameters[][MAX_LENGTH]) |
suspendPCB suspends the pcb passed in by the user More... | |
int | resumePCB (char parameters[][MAX_LENGTH]) |
resumePCB resumes the PCB passed in by the user More... | |
int | setPriority (char *procName, char *procPrio) |
setPriority sets the priority of a particular process More... | |
int | showPCB (char parameters[][MAX_LENGTH]) |
showPCB shows the process information for the process requested by the user More... | |
int | showAllProcesses (char parameters[][MAX_LENGTH]) |
showAllProcesses shows all processes in the system. More... | |
int | showReadyProcesses (char parameters[][MAX_LENGTH]) |
showReadyProcesses shows all processes that are ready, in the ready queue (linked list). More... | |
int | showBlockedProcesses (char parameters[][MAX_LENGTH]) |
showBlockedProcesses shows all processes that are blocked. More... | |
int | createPCB (const char *pcbName, const char *pcbPriority, const char *pcbClass) |
createPCB creates a new PCB and allocates memory for the PCB. More... | |
int | deletePCB (char parameters[][MAX_LENGTH]) |
deletePCB deletes the PCB requested by the user. More... | |
int | blockPCB (char parameters[][MAX_LENGTH]) |
blockPCB blocks the specified PCB More... | |
int | unblockPCB (char parameters[][MAX_LENGTH]) |
unblockPCB unblocks the specified PCB. More... | |
int | yield () |
stops the exection of commhand and executes each process in the ready queue More... | |
int | loadr3 (char parameters[][MAX_LENGTH]) |
loads all processes into memory in a suspended ready state at any priority of the users choosing More... | |
int | mcbFunc (char parameters[][MAX_LENGTH]) |
takes in whatever you are looking for and checks to see if it can be done for mcb More... | |
int blockPCB | ( | char | parameters[][MAX_LENGTH] | ) |
blockPCB blocks the specified PCB
parameters | takes in the name of the PCB to move to the blocked queue. |
Definition at line 794 of file comm_list.c.
References BLOCKED, changeProcessState(), errorToString(), printf, showPCB(), and SUCCESS.
Referenced by pcbFunc().
int createPCB | ( | const char * | pcbName, |
const char * | pcbPriority, | ||
const char * | pcbClass | ||
) |
createPCB creates a new PCB and allocates memory for the PCB.
pcbName | the name of the PCB to be created |
pcbPriority | the priority of the PCB to be created |
pcbClass | the class of the PCB to be created |
Definition at line 773 of file comm_list.c.
References atoi(), errorToString(), prevPCBError, printf, setupPCB(), and stringToClass().
Referenced by pcbFunc().
int date | ( | char | parameters[][MAX_LENGTH] | ) |
Definition at line 436 of file comm_list.c.
References getDate(), serial_println(), setDate(), and strcmp().
Referenced by initCmdArray().
int deletePCB | ( | char | parameters[][MAX_LENGTH] | ) |
deletePCB deletes the PCB requested by the user.
parameters | takes in the name of the PCB to be deleted. |
Definition at line 782 of file comm_list.c.
References errorToString(), findPCB(), freePCB(), prevPCBError, and printf.
Referenced by pcbFunc().
void getDate | ( | ) |
getDate Get the current date from the system.
No parameters required, prints out a date.
Definition at line 447 of file comm_list.c.
References get_date(), and printf.
Referenced by date(), and setDate().
int getNumDaysInMonth | ( | int | month, |
int | year | ||
) |
getNumDaysInMonth is a helper function to allow the easy retrieval of days in a month based on the month input by the user.
month | is an integer from 1-12 |
year | is an integer representing the year to check if it's a leap year |
Definition at line 15 of file comm_list.c.
Referenced by setDate().
void getTime | ( | ) |
getTime this function has the side-effect of printing the current time to the terminal.
No parameters are required.
Definition at line 490 of file comm_list.c.
References get_time(), serial_print(), and sprintf().
Referenced by setTime(), and time().
void help | ( | ) |
help prints out a list of all possible commands and a brief description of what they do.
Definition at line 72 of file comm_list.c.
References BG_BLUE, BG_GREEN, BG_MAGENTA, BG_ORANGE, BG_RED, BG_WHITE, BG_YELLOW, COLOR_BLACK, COLOR_RED_DARK, COLOR_STOP, COLOR_WHITE, printf, and serial_println().
Referenced by helpFunc().
void helpBlockPCB | ( | ) |
helpBlockPCB prints out the parameters and usage for blocking a PCB.
Definition at line 407 of file comm_list.c.
References serial_println().
Referenced by helpPcb().
void helpCreatePCB | ( | ) |
helpCreatePCB prints out the parameters and usage for createPCB.
Definition at line 391 of file comm_list.c.
References serial_println().
Referenced by helpPcb().
void helpDate | ( | char | parameters[][MAX_LENGTH] | ) |
helpDate prints out the help information for date, for date –set and date –get
parameters | takes in a char array |
[0] can be –set or –get or empty –set tells the parameters and usage for setting the date –get tells the parameters and usage for getting the date
Definition at line 238 of file comm_list.c.
References serial_println(), strcmp(), and strlen().
Referenced by helpFunc().
void helpDeletePCB | ( | ) |
helpDeletePCB prints out the parameters and usage for deleting a PCB.
Definition at line 399 of file comm_list.c.
References serial_println().
Referenced by helpPcb().
int helpFunc | ( | char | parameters[][MAX_LENGTH] | ) |
helpFunc calls the other help functions
parameters | used to determine if just help or help set date was called |
Definition at line 49 of file comm_list.c.
References help(), helpDate(), helpGetVersion(), helpLoadR3(), helpMCB(), helpPcb(), helpShutdown(), helpTime(), IMPROPER_COMMAND, serial_println(), and strcmp().
Referenced by initCmdArray().
void helpGetDate | ( | ) |
helpGetDate prints the help instructions for get date. Tells the user what the command and arguments for 'get date' are.
No parameters are needed to be passed in, as it just prints to the console.
Definition at line 190 of file comm_list.c.
References serial_println().
void helpGetTime | ( | ) |
helpGetTime prints the help instructions for get time. Tells the user what the commands and arguments for 'get time' are.
No parameters are needed to be passed in, as it just prints to the console.
Definition at line 206 of file comm_list.c.
References serial_println().
int helpGetVersion | ( | ) |
helpGetVersion prints the help instructions for version. Tells the user what the command and arguments for 'version' are.
No parameters are needed to be passed in, as it just prints to the console.
Definition at line 181 of file comm_list.c.
References COLOR_RED, COLOR_STOP, COLOR_YELLOW, and printf.
Referenced by helpFunc().
void helpLoadR3 | ( | ) |
helpLoadR3 prints out the help commands for helpLoadR3 Loads all of the processes from procsr3
Definition at line 174 of file comm_list.c.
References serial_println().
Referenced by helpFunc().
void helpMCB | ( | char | parameters[][MAX_LENGTH] | ) |
The command handler for mcb's checking for valid input.
Valid | commands for each function |
Definition at line 93 of file comm_list.c.
References helpMcbPrint(), helpMCBShowAllocated(), helpMCBShowFree(), isEmpty(), serial_println(), and strcmp().
Referenced by helpFunc().
void helpMCBAllocate | ( | ) |
Prints the details for Allocating an mcb.
Type | help –allocate |
Definition at line 136 of file comm_list.c.
References serial_println().
void helpMCBFreeMem | ( | ) |
Prints the details for freeing an mcb.
Type | help –freemem |
Definition at line 144 of file comm_list.c.
References serial_println().
void helpMCBInitHeap | ( | ) |
prints the all details about the initheap func
Type | help –initHeap |
Definition at line 128 of file comm_list.c.
References serial_println().
void helpMCBIsEmpty | ( | ) |
Prints details for IsEmpty func.
Type | help –isempty |
Definition at line 152 of file comm_list.c.
References serial_println().
void helpMcbPrint | ( | ) |
Prints the help menu for all mcb functions.
Type | help mcb |
Definition at line 116 of file comm_list.c.
References serial_println().
Referenced by helpMCB().
void helpMCBShowAllocated | ( | ) |
Prints details for showing all the allocated memory blocks in the heap.
Type | help –showallocated |
Definition at line 166 of file comm_list.c.
References serial_println().
Referenced by helpMCB().
void helpMCBShowFree | ( | ) |
Prints details for showing all the free memory blocks in the heap.
Type | help –showfree |
Definition at line 159 of file comm_list.c.
References serial_println().
Referenced by helpMCB().
void helpPcb | ( | char | parameters[][MAX_LENGTH] | ) |
helpPcb takes in the command to print the help information for. Calls the proper function to print the help information for the selected command.
parameters | takes in a character array |
Definition at line 284 of file comm_list.c.
References helpBlockPCB(), helpCreatePCB(), helpDeletePCB(), helpPcbPrint(), helpResumePCB(), helpSetPriority(), helpShowAllProcesses(), helpShowBlockedProcesses(), helpShowPCB(), helpShowReadyProcesses(), helpSuspendPCB(), helpUnblockPCB(), isEmpty(), serial_println(), and strcmp().
Referenced by helpFunc().
void helpPcbPrint | ( | ) |
helpPcbPrint prints out the commands for PCBs.
Definition at line 314 of file comm_list.c.
References serial_println().
Referenced by helpPcb().
void helpResumePCB | ( | ) |
helpResumePCB prints out the parameters and usage of the resume pcb command.
Definition at line 343 of file comm_list.c.
References serial_println().
Referenced by helpPcb().
void helpSetDate | ( | ) |
helpSetDate prints the help instructions for set date. Tells the user what the command and arguments for 'set date' are.
No parameters are needed to be passed in, as it just prints to the console.
Definition at line 197 of file comm_list.c.
References serial_println().
void helpSetPriority | ( | ) |
helpSetPriority prints out to console the parameters and usage for –setpriority.
Definition at line 351 of file comm_list.c.
References serial_println().
Referenced by helpPcb().
void helpSetTime | ( | ) |
helpSetTime prints the help instructions for set time. Tells the user what the command and arguments for 'set time' are.
No parameters are needed to be passed in, as it just prints to the console.
Definition at line 213 of file comm_list.c.
References serial_println().
void helpShowAllProcesses | ( | ) |
helpShowAllProcesses shows all processes in the system. Takes in no parameters and prints out to the console.
Definition at line 367 of file comm_list.c.
References serial_println().
Referenced by helpPcb().
void helpShowBlockedProcesses | ( | ) |
helpShowBlockedProcesses shows the parameters and usage for showing the blocked PCBs.
Definition at line 383 of file comm_list.c.
References serial_println().
Referenced by helpPcb().
void helpShowPCB | ( | ) |
void helpShowReadyProcesses | ( | ) |
helpShowReadyProcesses shows the parameters and usage for showing ready PCBs.
Definition at line 375 of file comm_list.c.
References serial_println().
Referenced by helpPcb().
void helpShutdown | ( | ) |
helpShutdown prints the help instructions for set date. Tells the user what the command and arguments for 'set date' are.
No parameters are needed to be passed in, as it just prints to the console.
Definition at line 222 of file comm_list.c.
References serial_println().
Referenced by helpFunc().
void helpSuspendPCB | ( | ) |
helpSuspendPCB prints the help instructions for the suspendPCB command.
Definition at line 335 of file comm_list.c.
References serial_println().
Referenced by helpPcb().
void helpTime | ( | char | parameters[][MAX_LENGTH] | ) |
helpTime prints out the help information for time, for time –set and time –get
parameters | takes in a char array |
[0] can be –set or –get or empty –set tells the parameters and usage for setting the time –get tells the parameters and usage for getting the time
Definition at line 261 of file comm_list.c.
References serial_println(), strcmp(), and strlen().
Referenced by helpFunc().
void helpUnblockPCB | ( | ) |
helpUnblockPCB prints out the parameters and usage for unblocking a PCB.
Definition at line 415 of file comm_list.c.
References serial_println().
Referenced by helpPcb().
void helpVersion | ( | ) |
helpVersion prints the help instructions for using the version command. No arguments are required.
Definition at line 231 of file comm_list.c.
References serial_println().
int isEmpty | ( | char | parameters[][MAX_LENGTH] | ) |
Definition at line 35 of file comm_list.c.
References strcmp().
Referenced by helpMCB(), helpPcb(), and pcbFunc().
int mcbFunc | ( | char | parameters[][MAX_LENGTH] | ) |
takes in whatever you are looking for and checks to see if it can be done for mcb
type | anthing into the command line prompt |
Definition at line 904 of file comm_list.c.
References COLOR_RED, COLOR_STOP, COLOR_YELLOW, heapTest(), mcbAllocList, mcbFreeList, printf, printList(), and strcmp().
Referenced by initCmdArray().
int pcbFunc | ( | char | parameters[][MAX_LENGTH] | ) |
takes in parameters and makes sure its valid then runs what you want to.
Type | anything in command line, valid inputs work. |
Definition at line 558 of file comm_list.c.
References blockPCB(), createPCB(), deletePCB(), EXTRA_PARAMETERS, isEmpty(), printf, procName, resumePCB(), serial_print(), serial_println(), setPriority(), showAllProcesses(), showBlockedProcesses(), showPCB(), showReadyProcesses(), strcmp(), suspendPCB(), and unblockPCB().
Referenced by initCmdArray().
int resumePCB | ( | char | parameters[][MAX_LENGTH] | ) |
resumePCB resumes the PCB passed in by the user
parameters | - the rest of the input from the user, the name of the PCB to be resumed. |
Definition at line 709 of file comm_list.c.
References changeProcessSuspensionState(), errorToString(), NOT_SUSPENDED, printf, showPCB(), and SUCCESS.
Referenced by pcbFunc().
void setDate | ( | char | parameters[][MAX_LENGTH] | ) |
setDate sets the system date using the input from the user.
parameters | take the unconsumed parameters from commhandler from the command prompt. |
Checks if the parameters exist, otherwise will return improper command. If paramters exist, will check to make sure the parameters are correct, such that the days and months are valid.
Calls set_date from rtc to set the current date. After setting the date, will print the current date.
Ex. Command is "date –set '03/12/2017', 03, 12 , 2017 are passed over. parameters[0] is the day parameters[1] is the month parameters[2] is the year
Definition at line 453 of file comm_list.c.
References atoi(), getDate(), getNumDaysInMonth(), IMPROPER_COMMAND, printf, serial_println(), set_date(), and strlen().
Referenced by date().
int setPriority | ( | char * | procName, |
char * | procPrio | ||
) |
setPriority sets the priority of a particular process
procName | is the process name to be modified |
procPrio | is the new priority of the PCB |
Definition at line 730 of file comm_list.c.
References atoi(), changeProcessPriority(), errorToString(), findPCB(), printf, and printPCBFunc().
Referenced by pcbFunc().
void setTime | ( | char | parameters[][MAX_LENGTH] | ) |
setTime sets the current system time from the users input.
parameters | take the unconsumed parameters from commhandler from the command prompt. |
Calls set_time from rtc to set the sytem time. Then prints out the current time.
Ex. Command is "time –set '14:20.55', 14, 20 , 55 are passed over. parameters[1] is the hour (24 hour) parameters[2] is the minute parameters[3] is the second
Definition at line 500 of file comm_list.c.
References atoi(), getTime(), IMPROPER_COMMAND, serial_println(), set_time(), and strlen().
Referenced by time().
int showAllProcesses | ( | char | parameters[][MAX_LENGTH] | ) |
showAllProcesses shows all processes in the system.
Definition at line 746 of file comm_list.c.
References blockedQueue, printf, printList(), readyQueue, suspendedBlockedQueue, and suspendedReadyQueue.
Referenced by pcbFunc().
int showBlockedProcesses | ( | char | parameters[][MAX_LENGTH] | ) |
showBlockedProcesses shows all processes that are blocked.
Definition at line 766 of file comm_list.c.
References blockedQueue, printf, and printList().
Referenced by pcbFunc().
int showPCB | ( | char | parameters[][MAX_LENGTH] | ) |
showPCB shows the process information for the process requested by the user
parameters | the name of the PCB to show the information of. |
Definition at line 737 of file comm_list.c.
References errorToString(), findPCB(), prevPCBError, printf, and printPCBFunc().
Referenced by blockPCB(), pcbFunc(), resumePCB(), suspendPCB(), and unblockPCB().
int showReadyProcesses | ( | char | parameters[][MAX_LENGTH] | ) |
showReadyProcesses shows all processes that are ready, in the ready queue (linked list).
Definition at line 759 of file comm_list.c.
References printf, printList(), and readyQueue.
Referenced by pcbFunc().
int shutdownFunc | ( | char | parameters[][MAX_LENGTH] | ) |
shutdownFunc shuts down the OS.
parameters | the input from the user |
Definition at line 521 of file comm_list.c.
References EXIT, in_string, MAX_LENGTH, serial_poll(), serial_print(), serial_println(), sprintf(), strcmp(), and sys_req().
Referenced by initCmdArray().
int suspendPCB | ( | char | parameters[][MAX_LENGTH] | ) |
suspendPCB suspends the pcb passed in by the user
parameters | takes in the name of the PCB to be suspended. |
Definition at line 688 of file comm_list.c.
References changeProcessSuspensionState(), errorToString(), printf, showPCB(), SUCCESS, and SUSPENDED.
Referenced by pcbFunc().
int time | ( | char | parameters[][MAX_LENGTH] | ) |
Definition at line 479 of file comm_list.c.
References getTime(), serial_println(), setTime(), and strcmp().
Referenced by initCmdArray().
int unblockPCB | ( | char | parameters[][MAX_LENGTH] | ) |
unblockPCB unblocks the specified PCB.
parameters | takes in the name of the PCB to move from the blocked queue to the ready queue. |
Definition at line 807 of file comm_list.c.
References changeProcessState(), errorToString(), printf, READY, showPCB(), and SUCCESS.
Referenced by pcbFunc().
int version | ( | char | parameters[][MAX_LENGTH] | ) |
version prints out the current version of the operating system. It will print out R1, R2, R3, ... depending on the current module.
No parameters are required.
Definition at line 425 of file comm_list.c.
References serial_print(), serial_println(), and VERSION.
Referenced by initCmdArray().