Modestus Moon OS  R4
CS 450 project
comm_list.c
Go to the documentation of this file.
1 #include <comm_vars.h>
2 #include <core/rtc.h>
3 #include <string.h>
4 #include <input.h>
5 #include "include/comm_list.h"
6 #include <core/pcb.h>
7 #include <linked_list.h>
8 #include <core/mcb.h>
9 
10 #include "../procsr3.h"
11 
12 /* __________________________________________________________________ */
13 /* Helper functions below this */
14 
15 int getNumDaysInMonth(int month, int year) {
16  int days = 0;
17  switch (month) {
18  case 01: case 3: case 5: case 7: case 8: case 10: case 12:
19  days = 31;
20  break;
21  case 4: case 6: case 9: case 11:
22  days = 30;
23  break;
24  case 2:
25  if(year%4==0)
26  days = 29;
27  else
28  days = 28;
29  default:
30  break;
31  }
32  return days;
33 }
34 
35 int isEmpty(char parameters[][MAX_LENGTH]) {
36  int empty = 0;
37  if((!strcmp(parameters[0],"")) || (!strcmp(parameters[0],"\0"))) {
38  empty = 1;
39  }
40  return empty;
41 }
42 
43 
44 
45 /* END HELPER FUNCTIONS */
46 /* _______________________________________________________________________ */
47 
48 
49 int helpFunc(char parameters[][MAX_LENGTH]) {
50  if(!strcmp(parameters[0],"") || !strcmp(parameters[0],"\0")) {
51  help();
52  } else if(strcmp(parameters[0],"shutdown")==0) {
53  helpShutdown();
54  } else if(strcmp(parameters[0],"version")==0) {
56  } else if(strcmp(parameters[0],"time")==0) {
57  helpTime(&parameters[1]);
58  } else if(strcmp(parameters[0],"date")==0) {
59  helpDate(&parameters[1]);
60  } else if(strcmp(parameters[0], "pcb")==0) {
61  helpPcb(&parameters[1]);
62  } else if(strcmp(parameters[0], "loadr3")==0) {
63  helpLoadR3();
64  } else if(strcmp(parameters[0], "mcb")==0) {
65  helpMCB(&parameters[1]);
66  } else {
68  }
69  return 0;
70 }
71 
72 void help() {
73 
74  printf("%s%sUNIX style commands%s\r\n",COLOR_BLACK, BG_WHITE, COLOR_STOP);
75  printf("%s%sCommand | what it does%s\r\n", COLOR_BLACK, BG_WHITE, COLOR_STOP);
76  printf("%s%s------- | -----------------------------------%s\r\n", COLOR_BLACK, BG_WHITE, COLOR_STOP);
77  printf("%s%sdate | Interact with the current system date%s\r\n",COLOR_BLACK, BG_RED, COLOR_STOP);
78  printf("%s%shelp | Shows the command options%s\r\n", COLOR_WHITE, BG_ORANGE, COLOR_STOP);
79  printf("%s%spcb | Work with the processes%s\r\n", COLOR_BLACK, BG_YELLOW, COLOR_STOP);
80  printf("%s%sshutdown | Shut down the system%s\r\n", COLOR_BLACK, BG_GREEN, COLOR_STOP);
81  printf("%s%stime | Interact with the current system time%s\r\n", COLOR_WHITE, BG_BLUE, COLOR_STOP);
82  printf("%s%sversion | Get the current version of the OS%s\r\n", COLOR_RED_DARK, BG_MAGENTA, COLOR_STOP);
83  printf("%s%sloadr3 | Loads all of the processes from procsr3%s\r\n",COLOR_BLACK, BG_RED, COLOR_STOP);
84  //serial_println("loadr3 | Loads all of the processes from procsr3");//,COLOR_BLACK, BG_RED, COLOR_STOP);
85  printf("%s%smcb | Work with MCB%s\r\n", COLOR_BLACK, BG_ORANGE, COLOR_STOP);
86 
87 
88  serial_println(" ");
89 
90 
91 }
92 
93 void helpMCB(char parameters[][MAX_LENGTH]){
94 
95  if(isEmpty(&parameters[0])) {
96  helpMcbPrint();
97  } /*else if(!strcmp(parameters[0],"--initheap")) {
98  helpMCBInitHeap();
99  } else if(!strcmp(parameters[0],"--allocate")) {
100  helpMCBAllocate();
101  } else if(!strcmp(parameters[0], "--freemem")) {
102  helpMCBFreeMem();
103  } else if(!strcmp(parameters[0], "--isempty")) {
104  helpMCBIsEmpty();
105  }*/ else if(!strcmp(parameters[0], "--showfree")) {
106  helpMCBShowFree();
107  } else if(!strcmp(parameters[0], "--showallocated")) {
109  } else {
110  serial_println("Invalid parameter, run 'help mcb' to see the valid parameters.");
111  }
112 
113 
114 }
115 
116 void helpMcbPrint() {
117  serial_println("MCB commands\r\n");
118  serial_println("Use 'mcb [command]'");
119  serial_println(" Command | what it does");
120  serial_println("______________ | _________________________________");
121  serial_println("--showfree | Shows all free memory in heap");
122  serial_println("--showallocated | Shows all allocated memory");
123 
124  serial_println("Type 'help [command]' to see what the command does and arguments it requires.");
125  serial_println(" ");
126 }
127 
129  serial_println("Allocate memory for MPX. Size of the heap in bytes.");
130  serial_println("Command: 'mcb --initheap'");
131  serial_println("Arguments:");
132  serial_println("-s/--size 'size of the memory (integer value)'");
133  serial_println("\r\n");
134 }
135 
137  serial_println("Allocate memory from heap. Amount of bytes to be allocated from the heap.");
138  serial_println("Command: 'mcb --allocate'");
139  serial_println("Arguments:");
140  serial_println("-s/--size 'size of the memory (integer value)'");
141  serial_println("\r\n");
142 }
143 
145  serial_println("Free a particular block of memory that was previously allocated. Takes in the pointer to an address in memory");
146  serial_println("Command: 'mcb --freemem'");
147  serial_println("Arguments:");
148  serial_println("-p/--pointer 'pointer to an address'");
149  serial_println("\r\n");
150 }
151 
153  serial_println("Returns true or false based on whether the heap is empty.");
154  serial_println("Command: 'mcb --isempty'");
155  serial_println("No arguments required.");
156  serial_println("\r\n");
157 }
158 
160  serial_println("Show the address and size of the blocks in the free list.");
161  serial_println("Command: 'mcb --showfree'");
162  serial_println("No arguments required.");
163  serial_println("\r\n");
164 }
165 
167  serial_println("Show the address and size of the blocks in the allocated list.");
168  serial_println("Command: 'mcb --showallocated'");
169  serial_println("No arguments required.");
170  serial_println("\r\n");
171 }
172 
173 
174 void helpLoadR3() {
175  serial_println("Loads all of the processes from procsr3.");
176  serial_println("Command: 'loadr3'");
177  serial_println("No arguments required.");
178  serial_println("\r\n");
179 }
180 
182  printf("%sGet the current version of the operating system%s\r\n",COLOR_RED, COLOR_STOP);
183  printf("Command: '%sversion%s'\r\n",COLOR_YELLOW,COLOR_STOP);
184  printf("%sThere are no arguments required.\r\n","");
185  printf("%sThis will return R1, R2,... showing the current module.\r\n","");
186  printf("%s\r\n","");
187  return 0;
188 }
189 
190 void helpGetDate() {
191  serial_println("Get the current date.");
192  serial_println("Command: 'get date'");
193  serial_println("There are no arguments required.");
194  serial_println(" ");
195 }
196 
197 void helpSetDate() {
198  serial_println("Set the current date");
199  serial_println("Command: 'set date --set \"DD/MM/YYYY\" ");
200  serial_println("Arguments:");
201  serial_println("--set \"MM/DD/YYYY\"");
202  serial_println("ex. 'set date --set \"03/12/2017\"'");
203  serial_println(" ");
204 }
205 
206 void helpGetTime() {
207  serial_println("Get the current time in UTC.");
208  serial_println("Command: 'get time'");
209  serial_println("There are no arguments required.");
210  serial_println(" ");
211 }
212 
213 void helpSetTime(){
214  serial_println("Set the current time in UTC");
215  serial_println("Command: 'set time --set \"HH:MM.SS\"'");
216  serial_println("Arguments: ");
217  serial_println("--set \"HH:MM.SS\" using 24 hour");
218  serial_println("ex. 'set time --set[14:20.00]' to set the system time to 2:20.00 PM");
219  serial_println(" ");
220 }
221 
222 void helpShutdown() {
223 
224  serial_println("Shut down the system.");
225  serial_println("Command: 'shutdown'");
226  serial_println("No arguments required.");
227  serial_println("You will be prompted to confirm that you want to shutdown.");
228  serial_println(" ");
229 }
230 
231 void helpVersion() {
232  serial_println("Shows the version of the operating system.");
233  serial_println("Command: 'version'");
234  serial_println("No arguments required.");
235  serial_println("\r\n");
236 }
237 
238 void helpDate(char parameters[][MAX_LENGTH])
239 {
240  if(!strlen(parameters[0]))
241  {
242  serial_println("Retireves or Sets the system date");
243  serial_println("Command: 'date'");
244  serial_println("\033[38;2;255;255;0mArguments available: \033[38;2;255;0;0m--set, --get\033[0m");
245  serial_println("Enter the command 'help date --get' or 'help date --set'");
246  }
247  else if(!strcmp(parameters[0], "--set"))
248  {
249  serial_println("Sets the system date");
250  serial_println("Command: 'date --set'");
251  serial_println("Usage: \033[38;2;255;255;0m 'date --set' \"DD/MM/YYYY\" \033[0m");
252  }
253  else if(!strcmp(parameters[0], "--get"))
254  {
255  serial_println("Gets the system date");
256  serial_println("Command: 'date --get'");
257  serial_println("Usage: \033[38;2;255;255;0m 'date --get' \033[0m");
258  }
259 }
260 
261 void helpTime(char parameters[][MAX_LENGTH])
262 {
263  if(!strlen(parameters[0]))
264  {
265  serial_println("Retrieves or Sets the system time");
266  serial_println("Command: 'time'");
267  serial_println("\033[38;2;255;255;0mArguments available: \033[38;2;255;0;0m--set, --get\033[0m");
268  serial_println("Enter the command 'help time --get' or 'help time --set'");
269  }
270  else if(!strcmp(parameters[0], "--set"))
271  {
272  serial_println("Sets the system time");
273  serial_println("Command: 'time --set'");
274  serial_println("Usage: \033[38;2;255;255;0m 'time --set' \"HH:MM.SS\" \033[0m");
275  }
276  else if(!strcmp(parameters[0], "--get"))
277  {
278  serial_println("Gets the system date");
279  serial_println("Command: 'time --get'");
280  serial_println("Usage: \033[38;2;255;255;0m 'time --get' \033[0m");
281  }
282 }
283 
284 void helpPcb(char parameters[][MAX_LENGTH]) {
285  if(isEmpty(&parameters[0])) {
286  helpPcbPrint();
287  } else if(!strcmp(parameters[0],"--block")) {
288  helpBlockPCB();
289  } else if(!strcmp(parameters[0],"--create")) {
290  helpCreatePCB();
291  } else if(!strcmp(parameters[0], "--delete")) {
292  helpDeletePCB();
293  } else if(!strcmp(parameters[0], "--resume")) {
294  helpResumePCB();
295  } else if(!strcmp(parameters[0], "--setpriority")) {
296  helpSetPriority();
297  } else if(!strcmp(parameters[0], "--show")) {
298  helpShowPCB();
299  } else if(!strcmp(parameters[0],"--showall")) {
301  } else if(!strcmp(parameters[0], "--showblocked")) {
303  } else if(!strcmp(parameters[0], "--showready")) {
305  } else if(!strcmp(parameters[0], "--suspend")) {
306  helpSuspendPCB();
307  } else if(!strcmp(parameters[0],"--unblock")) {
308  helpUnblockPCB();
309  } else {
310  serial_println("Invalid parameter, run 'help pcb' to see the valid parameters.");
311  }
312 }
313 
314 void helpPcbPrint() {
315  serial_println("PCB commands\r\n");
316  serial_println("Use 'pcb [command]'");
317  serial_println(" Command | what it does");
318  serial_println("____________ | _________________________________");
319  serial_println("--block | Sends the PCB to the blocked queue");
320  serial_println("--create | Creates a new PCB and allocates memory");
321  serial_println("--delete | Delete specified PCB and frees memory");
322  serial_println("--resume | Resume the specified PCB");
323  serial_println("--setpriority | Set/change the priority of the specified PCB");
324  serial_println("--show | Show the specified PCB");
325  serial_println("--showall | Show all of the PCBs");
326  serial_println("--showblocked | Show the PCBs in the blocked queue");
327  serial_println("--showready | Show the PCBs in the ready queue");
328  serial_println("--suspend | Suspends the specified PCB");
329  serial_println("--unblock | Moves the specified PCB from the blocked state to ready queue");
330  serial_println(" ");
331  serial_println("Type 'help [command]' to see what the command does and arguments it requires.");
332  serial_println(" ");
333 }
334 
336  serial_println("Suspend a particular PCB.");
337  serial_println("Command: pcb --suspend");
338  serial_println("Arguments:");
339  serial_println("-n/--name 'name of the pcb");
340  serial_println(" ");
341 }
342 
344  serial_println("Resume the specified PCB. Removes PCB from suspended queue and places it into the appropriate queue.");
345  serial_println("Command: pcb --resume");
346  serial_println("Arguments:");
347  serial_println("-n/--name 'name of the PCB'");
348  serial_println(" ");
349 }
350 
352  serial_println("Set/change the priority of a particular PCB.");
353  serial_println("Command: pcb --setpriority");
354  serial_println("Arguments:");
355  serial_println("-n/--name 'name of PCB'\n-p/--priority 'priority from 0-9'");
356  serial_println(" ");
357 }
358 
359 void helpShowPCB() {
360  serial_println("Show the information for a particular PCB.");
361  serial_println("Command: pcb --show");
362  serial_println("Arguments:");
363  serial_println("-n/--name 'name of the PCB'");
364  serial_println(" ");
365 }
366 
368  serial_println("Show all of the processes in the system.");
369  serial_println("Command: pcb --showall");
370  serial_println("Arguments:");
371  serial_println("No arguments required.");
372  serial_println(" ");
373 }
374 
376  serial_println("Show all of the processes that are in the ready queue.");
377  serial_println("Command: pcb --showready");
378  serial_println("Arguments:");
379  serial_println("No arguments required.");
380  serial_println(" ");
381 }
382 
384  serial_println("Show all of the processes that are in the blocked queue.");
385  serial_println("Command: pcb --showblocked");
386  serial_println("Arguments:");
387  serial_println("No arguments required.");
388  serial_println(" ");
389 }
390 
392  serial_println("Creates a new PCB and allocates memory.");
393  serial_println("Command: pcb --create");
394  serial_println("Arguments:");
395  serial_println("-n/--name 'the name of the PCB'\n-p/--priority 'priority from 0-9 of pcb'\n-c/--class 'System or User_app'");
396  serial_println(" ");
397 }
398 
400  serial_println("Delete the specified PCB and frees memory. Removes the PCB from any queues it is currently in.");
401  serial_println("Command: pcb --delete");
402  serial_println("Arguments:");
403  serial_println("-n/--name 'the name of the PCB'");
404  serial_println(" ");
405 }
406 
407 void helpBlockPCB() {
408  serial_println("Removes the PCB from current queue and places it into the blocked queue.");
409  serial_println("Command: pcb --block");
410  serial_println("Arguments:");
411  serial_println("-n/--name 'name of the PCB'");
412  serial_println(" ");
413 }
414 
416  serial_println("Removes the PCB from the blocked queue and places it into the ready queue.");
417  serial_println("Command: pcb --unblock");
418  serial_println("Arguments:");
419  serial_println("-n/--name 'name of the PCB'");
420  serial_println(" ");
421 }
422 
423 /* ____________________________________________________*/
424 
425 int version(char parameters[][MAX_LENGTH]) {
426  (void)parameters;
427  serial_print("Version: ");
429  serial_println(" ");
430  return 0;
431 }
432 
433 /* ___________________________________________ */
434 /* DATE FUNCTIONS BELOW */
435 
436 int date(char parameters[][MAX_LENGTH]) {
437  if(!strcmp(parameters[0],"--get")) {
438  getDate();
439  } else if(!strcmp(parameters[0],"--set")) {
440  setDate(&parameters[1]);
441  } else {
442  serial_println("Check your input, there are only 12 months in a year.");
443  }
444  return 0;
445 }
446 
447 void getDate() {
448  int month=0, day=0, year=0;
449  get_date(&day, &month, &year);
450  printf("The current date is %d/%d/20%d UTC\r\n", day, month, year);
451 }
452 
453 void setDate(char parameters[][MAX_LENGTH]) {
454  //printf("day %d %s, month %d %s, year %d %s\r\n", atoi(parameters[0]), parameters[0], atoi(parameters[1]), parameters[1], atoi(parameters[2]), parameters[2]);
455  if(!strlen(parameters[2]) || !atoi(parameters[0]) || !atoi(parameters[1]) || !atoi(parameters[2]))
456  {
458  serial_println("\r\nInvalid Parameters");
459  }
460  else
461  {
462  int daysInMonth = getNumDaysInMonth(atoi(parameters[1]), atoi(parameters[2]));
463  if((atoi(parameters[0]) > 0) && (daysInMonth >= atoi(parameters[0]))){
464  set_date(atoi(parameters[0]), atoi(parameters[1]), atoi(parameters[2]));
465  } else {
466  serial_println("Double check the input parameters");
467  printf("\033[38;2;255;0;255mTotal days in your selected month are: %d UTC\r\n\033[38;2;255;255;255m", daysInMonth);
468  serial_println("\r\n");
469  }
470  }
471  getDate();
472 }
473 
474 /* END DATE FUNCTIONS */
475 
476 /* _______________________________________*/
477 /* START TIME FUNCTIONS */
478 
479 int time(char parameters[][MAX_LENGTH]) {
480  if(!strcmp(parameters[0],"--get")) {
481  getTime();
482  } else if(!strcmp(parameters[0],"--set")) {
483  setTime(&parameters[1]);
484  } else {
485  serial_println("ERROR HAS BEEN NOTICED");
486  }
487  return 0;
488 }
489 
490 void getTime() {
491  int hour=0, minutes=0, seconds=0;
492  get_time(&hour, &minutes, &seconds);
493 
494  char buf[500]; \
495  sprintf(buf, 500, "\033[38;2;255;0;255mThe current time is %d:%d.%d UTC\r\n\033[38;2;255;255;255m", hour, minutes, seconds); \
496  serial_print(buf);
497  //printf("\033[38;2;255;0;255mThe current time is %d:%d.%d UTC\r\n\033[38;2;255;255;255m", hour, minutes, seconds);
498 }
499 
500 void setTime(char parameters[][MAX_LENGTH]) {
501  if(!strlen(parameters[2]) || !atoi(parameters[0]) || !atoi(parameters[1]) || !atoi(parameters[2]))
502  {
504  serial_println("\r\nInvalid Parameters");
505  }
506  else
507  {
508  if(atoi(parameters[0]) < 0 || atoi(parameters[0]) > 24 || atoi(parameters[1]) < 0 || atoi(parameters[1]) > 59 || atoi(parameters[2]) < 0 || atoi(parameters[2]) > 59) {
509  serial_println("Double check the input parameters");
510  serial_println("Make sure 0 HH 24 and 0 MM 59 and 0 SS 59");
511  serial_println("\r\n");
512  } else {
513  set_time(atoi(parameters[0]), atoi(parameters[1]), atoi(parameters[2]));
514  }
515  }
516  getTime();
517 }
518 
519 /* END TIME FUNCTIONS */
520 
521 int shutdownFunc(char parameters[][MAX_LENGTH]) {
522  int retVal = 0;
523 
524 
525  char buf[500]; \
526  sprintf(buf, 500, "\033[38;2;255;0;255mShutdown called\r\n\033[38;2;255;255;255m"); \
527 
528  serial_println("Shutdown was called.\r\n");
529 
530  if(strcmp(parameters[1],"")==0) {
531  int confirm = 0;
532  char in_string[MAX_LENGTH];
533  serial_print("Confirm shutdown y/n?: ");
534 
535  if(confirm == 0) {
536  serial_print("");
537  serial_poll(in_string);
538  if(strcmp(in_string, "y")==0)
539  {
540  confirm = 1;
541  serial_println("");
542  sys_req(EXIT);
543  }
544  else if (strcmp(in_string, "n")==0)
545  confirm = 2;
546  }
547  serial_println(" ");
548  if(confirm == 1)
549  retVal = 9;
550  } else {
551  serial_println("UNKNOWN_COMMAND");
552  }
553  return retVal;
554 }
555 
556 /* __________ PCB FUNCTIONS _____________ */
557 
558 int pcbFunc(char parameters[][MAX_LENGTH]) {
559  if(!strcmp(parameters[0],"--suspend")) {
560  if(isEmpty(&parameters[1])) {
561  serial_println("Missing name of PCB to suspend.");
562  } else {
563  if(!isEmpty(&parameters[2]) &&
564  (!strcmp(parameters[1],"-n") || !strcmp(parameters[1],"--name"))) {
565  suspendPCB(&parameters[2]);
566  } else {
567  suspendPCB((&parameters[2]));
569  serial_print(parameters[3]);
570  serial_print("\r\n");
571  }
572  }
573  } else if(!strcmp(parameters[0],"--resume")) {
574  if(isEmpty(&parameters[1])) {
575  serial_println("Missing name of PCB to suspend.");
576  } else {
577  if(!isEmpty(&parameters[2]) &&
578  (!strcmp(parameters[1],"-n") || !strcmp(parameters[1],"--name"))) {
579  resumePCB(&parameters[2]);
580  } else {
581  resumePCB((&parameters[2]));
583  serial_print(parameters[3]);
584  serial_print("\r\n"); }
585  }
586 
587  } else if(!strcmp(parameters[0],"--setpriority")) {
588  if(isEmpty(&parameters[4])) {
589  serial_println("Missing parameters.");
590  } else {
591  if((!strcmp(parameters[1],"--name") || !strcmp(parameters[1],"-n")) && (!strcmp(parameters[3],"--priority") || !strcmp(parameters[3],"-p"))) {
592  setPriority(parameters[2], parameters[4]);
593  } else if((!strcmp(parameters[3],"--name") || !strcmp(parameters[3],"-n")) && (!strcmp(parameters[1],"--priority") || !strcmp(parameters[1],"-p"))) {
594  setPriority(parameters[4], parameters[2]);
595  } else {
596  printf("%sProper command: 'pcb --setpriority -n \"pcb name\" -p \"pcb priority\"","");
597  }
598  }
599  } else if(!strcmp(parameters[0],"--show")) {
600  if(isEmpty(&parameters[2])) {
601  printf("Missing name of pcb to show%s.\n","");
602  } else {
603  if(!strcmp(parameters[1],"-n") || !strcmp(parameters[1],"--name")) {
604  showPCB(&parameters[2]);
605  } else {
606  printf("Type 'help pcb --show' to see the arguments required.%s\n","");
607  }
608  }
609  } else if(!strcmp(parameters[0],"--showall")) {
610  if(isEmpty(&parameters[1])) {
611  showAllProcesses(&parameters[0]);
612 
613  } else {
614  printf("No arguments required%s\n","");
615  showAllProcesses(&parameters[0]);
616  }
617  } else if(!strcmp(parameters[0],"--showready")) {
618  if(isEmpty(&parameters[1])) {
619  showReadyProcesses(&parameters[0]);
620 
621  } else {
622  printf("No arguments required%s\n","");
623  showReadyProcesses(&parameters[0]);
624  }
625  } else if(!strcmp(parameters[0],"--showblocked")) {
626  if(isEmpty(&parameters[1])) {
627  showBlockedProcesses(&parameters[0]);
628 
629  } else {
630  printf("No arguments required%s\n","");
631  showBlockedProcesses(&parameters[0]);
632  }
633  } else if(!strcmp(parameters[0],"--create")) {
634  if(isEmpty(&parameters[6])) {
635  printf("Missing parameters of pcb to create%s.\n","");
636  } else {
637  char * procName; char * procPrio; char * procClass;
638  int i = 0;
639  for(;!isEmpty(&parameters[i]); i++) {
640  if(!strcmp(parameters[i], "--name") || !strcmp(parameters[i],"-n")) {
641  i++;
642  procName = parameters[i];
643  } else if(!strcmp(parameters[i], "--priority") || !strcmp(parameters[i],"-p")) {
644  i++;
645  procPrio = parameters[i];
646  } else if(!strcmp(parameters[i], "--class") || !strcmp(parameters[i],"-c")) {
647  i++;
648  procClass = parameters[i];
649  }
650  }
651 
652  createPCB(procName, procPrio, procClass);
653  }
654  } else if(!strcmp(parameters[0],"--delete")) {
655  if(isEmpty(&parameters[2])) {
656  printf("Missing name of pcb to create%s.\n","");
657  } else {
658  if(!strcmp(parameters[1],"-n") || !strcmp(parameters[1],"--name")) {
659  deletePCB(&parameters[2]);
660  } else {
661  printf("Type 'help pcb --delete' to see the arguments required.%s\n","");
662  }
663  }
664  } else if(!strcmp(parameters[0],"--block")) {
665  if(isEmpty(&parameters[2])) {
666  printf("Missing name of pcb to create%s.\n","");
667  } else {
668  if(!strcmp(parameters[1],"-n") || !strcmp(parameters[1],"--name")) {
669  blockPCB(&parameters[2]);
670  } else {
671  printf("Type 'help pcb --block' to see the arguments required.%s\n","");
672  }
673  }
674  } else if(!strcmp(parameters[0],"--unblock")) {
675  if(isEmpty(&parameters[2])) {
676  printf("Missing name of pcb to create%s.\n","");
677  } else {
678  if(!strcmp(parameters[1],"-n") || !strcmp(parameters[1],"--name")) {
679  unblockPCB(&parameters[2]);
680  } else {
681  printf("Type 'help pcb --unblock' to see the arguments required.%s\n","");
682  }
683  }
684  }
685  return 0;
686 }
687 
688 int suspendPCB(char parameters[][MAX_LENGTH]) {
689 
690  e_PCB_ERROR_CODE_t retVal = changeProcessSuspensionState((const char*)parameters[0], SUSPENDED);
691  if(retVal == SUCCESS)
692  {
693  showPCB(parameters);
694  }
695  printf("Status: %s\r\n", errorToString(retVal));
696  return retVal;
697 
698 // const char* name = (const char*)parameters[0];
699 // pcb_t* process = findPCB(name);
700 // e_PROCESS_STATE_t state = process->processState;
701 // if (state == READY || state == RUNNING)
702 // {
703 // changeProcessState(name, BLOCKED);
704 // }
705 // else printf("%s", "\nThe process needs to either be in the ready or the running state to suspend.\n");
706 // return 0;
707 }
708 
709 int resumePCB(char parameters[][MAX_LENGTH]) {
710 
711  e_PCB_ERROR_CODE_t retVal = changeProcessSuspensionState((const char*)parameters[0], NOT_SUSPENDED);
712  if(retVal == SUCCESS)
713  {
714  showPCB(parameters);
715  }
716  printf("Status: %s\r\n", errorToString(retVal));
717  return retVal;
718 
719 // const char* name = (const char*)parameters[0];
720 // pcb_t* process = findPCB(name);
721 // e_PROCESS_STATE_t state = process->processState;
722 // if (state == READY)
723 // {
724 // changeProcessState(name, RUNNING);
725 // }
726 // else printf("%s", "\nThe process must be in the ready state to resume.\n");
727 // return 0;
728 }
729 
730 int setPriority(char * procName, char * procPrio) {
731  //serial_println("PRINTING OUT");
732  printf("Status: %s\r\n", errorToString(changeProcessPriority(procName, atoi(procPrio))));
733  printPCBFunc((void*)findPCB(procName));
734  return 0;
735 }
736 
737 int showPCB(char parameters[][MAX_LENGTH]) {
738  pcb_t* process = findPCB((const char*)parameters[0]);
739  if(!process) { printf("Status: %s\r\n", errorToString(prevPCBError)); return prevPCBError; }
740 
741  printPCBFunc((void*)process);
742 
743  return prevPCBError;
744 }
745 
746 int showAllProcesses(char parameters[][MAX_LENGTH]) {
747  (void)parameters;
748  printf("\n\nReady Queue:%s","\r\n");
750  printf("\n\nBlocked Queue:%s","\r\n");
752  printf("\n\nSuspended-Ready Queue:%s","\r\n");
754  printf("\n\nSuspended-Blocked Queue:%s","\r\n");
756  return 0;
757 }
758 
759 int showReadyProcesses(char parameters[][MAX_LENGTH]) {
760  (void)parameters;
761  printf("%s", "\n\nReady Queue:\n");
763  return 0;
764 }
765 
766 int showBlockedProcesses(char parameters[][MAX_LENGTH]) {
767  (void)parameters;
768  printf("%s", "\n\nBlocked Queue:\n");
770  return 0;
771 }
772 
773 int createPCB(const char* pcbName, const char* pcbPriority, const char* pcbClass) {
774  setupPCB(pcbName, stringToClass(pcbClass), atoi(pcbPriority));
775  //printf("Clas String %s: num %d\r\n", pcbClass, (int) stringToClass(pcbClass));
776  printf("Status: %s\r\n", errorToString(prevPCBError));
777 
778  return prevPCBError;
779 
780 }
781 
782 int deletePCB(char parameters[][MAX_LENGTH]) {
783  pcb_t* foundPCB = findPCB((const char*)parameters[0]);
784  if(!foundPCB)
785  {
786  printf("Status: %s\r\n", errorToString(prevPCBError));
787  return prevPCBError;
788  }
789  e_PCB_ERROR_CODE_t retval = freePCB(foundPCB);
790  printf("Status: %s\r\n", errorToString(retval));
791  return retval;
792 }
793 
794 int blockPCB(char parameters[][MAX_LENGTH]) {
795  e_PCB_ERROR_CODE_t retVal = changeProcessState((const char*)parameters[0], BLOCKED);
796  if(retVal == SUCCESS)
797  {
798  showPCB(parameters);
799  }
800  printf("Status: %s\r\n", errorToString(retVal));
801  return retVal;
802 // const char* name = (const char*)parameters[0];
803 // changeProcessState(name, BLOCKED);
804 // return 0;
805 }
806 
807 int unblockPCB(char parameters[][MAX_LENGTH]) {
808  e_PCB_ERROR_CODE_t retVal = changeProcessState((const char*)parameters[0], READY);
809  if(retVal == SUCCESS)
810  {
811  showPCB(parameters);
812  }
813  printf("Status: %s\r\n", errorToString(retVal));
814  return retVal;
815 // const char* name = (const char*)parameters[0];
816 // changeProcessState(name, READY);
817 // return 0;
818 }
819 
820 int yield() {
821  asm volatile("int $60");
822  return 0;
823 }
824 
825 int loadr3(char parameters[][MAX_LENGTH]) {
826  (void)parameters;
827  serial_println("Loading processes.");
828 
829  pcb_t* newPCB = setupPCB("R3-Proc1", SYSTEM, 1);
830  processContext_t * cp = ( processContext_t *)( newPCB->stackTop );
831  memset ( cp , 0, sizeof ( processContext_t ));
832  cp->fs = 0x10 ;
833  cp->gs = 0x10 ;
834  cp->ds = 0x10 ;
835  cp->es = 0x10 ;
836  cp->cs = 0x8 ;
837  cp->ebp = ( u32int )( newPCB->stackBase );
838  cp->esp = ( u32int )( newPCB->stackTop );
839  cp->eip = ( u32int ) &proc1 ;// The function correlating to the process , ie. Proc1
840  cp->eflags = 0x202 ;
841 
842  newPCB = setupPCB("R3-Proc2", SYSTEM, 1);
843  cp = ( processContext_t *)( newPCB->stackTop );
844  memset ( cp , 0, sizeof ( processContext_t ));
845  cp->fs = 0x10 ;
846  cp->gs = 0x10 ;
847  cp->ds = 0x10 ;
848  cp->es = 0x10 ;
849  cp->cs = 0x8 ;
850  cp->ebp = ( u32int )( newPCB->stackBase );
851  cp->esp = ( u32int )( newPCB->stackTop );
852  cp->eip = ( u32int ) &proc2 ;// The function correlating to the process , ie. Proc1
853  cp->eflags = 0x202 ;
854 
855 
856  newPCB = setupPCB("R3-Proc3", SYSTEM, 1);
857  cp = ( processContext_t *)( newPCB->stackTop );
858  memset ( cp , 0, sizeof ( processContext_t ));
859  cp->fs = 0x10 ;
860  cp->gs = 0x10 ;
861  cp->ds = 0x10 ;
862  cp->es = 0x10 ;
863  cp->cs = 0x8 ;
864  cp->ebp = ( u32int )( newPCB->stackBase );
865  cp->esp = ( u32int )( newPCB->stackTop );
866  cp->eip = ( u32int ) &proc3 ;// The function correlating to the process , ie. Proc1
867  cp->eflags = 0x202 ;
868 
869  newPCB = setupPCB("R3-Proc4", SYSTEM, 1);
870  cp = ( processContext_t *)( newPCB->stackTop );
871  memset ( cp , 0, sizeof ( processContext_t ));
872  cp->fs = 0x10 ;
873  cp->gs = 0x10 ;
874  cp->ds = 0x10 ;
875  cp->es = 0x10 ;
876  cp->cs = 0x8 ;
877  cp->ebp = ( u32int )( newPCB->stackBase );
878  cp->esp = ( u32int )( newPCB->stackTop );
879  cp->eip = ( u32int ) &proc4 ;// The function correlating to the process , ie. Proc1
880  cp->eflags = 0x202 ;
881 
882  newPCB = setupPCB("R3-Proc5", SYSTEM, 1);
883  cp = ( processContext_t *)( newPCB->stackTop );
884  memset ( cp , 0, sizeof ( processContext_t ));
885  cp->fs = 0x10 ;
886  cp->gs = 0x10 ;
887  cp->ds = 0x10 ;
888  cp->es = 0x10 ;
889  cp->cs = 0x8 ;
890  cp->ebp = ( u32int )( newPCB->stackBase );
891  cp->esp = ( u32int )( newPCB->stackTop );
892  cp->eip = ( u32int ) &proc5 ;// The function correlating to the process , ie. Proc1
893  cp->eflags = 0x202 ;
894 
895 
896 
897  return 0;
898 }
899 
900 /* ******************* END PCB FUNCTIONS ********************* */
901 
902 /*___________________ START MCB FUNCTIONS ___________________ */
903 
904 int mcbFunc(char parameters[][MAX_LENGTH]) {
905  /*if(!strcmp(parameters[0],"--allocate")) {
906  int returnError = (int)allocateMemFromHeap((size_t)atoi(parameters[2]));
907  if(returnError == 0 ) {
908  printf("%sNo blocks large enough%s\r\n",COLOR_RED,COLOR_STOP);
909  }
910  printf("%s", "Alloc list\r\n")
911  printList(&mcbAllocList);
912  printf("%s", "free list\r\n")
913  printList(&mcbFreeList);
914  }*/ /*else if(!strcmp(parameters[0],"--freemem")) {
915 
916  if(strcmp(parameters[2],"")) {
917  freeHeapMem((void*)atoi(parameters[2]));
918  printf("Result: %s\r\n",mcbResultToString(lastMCBError));
919  } else {
920  serial_println("Enter a valid address to free");
921  }
922  }*/ /*else if(!strcmp(parameters[0],"--initheap")) {
923  initHeap((size_t)atoi(parameters[2]));
924  serial_println("Heap initialized");
925  } else *//*if(!strcmp(parameters[0],"--isempty")) {
926  if(heapIsEmpty()) {
927  printf("%sHeap is not empty%s\r\n",BG_ORANGE, COLOR_STOP);
928  } else {
929  printf("%s%sHeap is empty%s\r\n",COLOR_BLUE,BG_GREEN, COLOR_STOP);
930  }
931  } else*/ if(!strcmp(parameters[0],"--showfree")) {
932  printf("%s", "free list\r\n")
934  } else if(!strcmp(parameters[0],"--showallocated")) {
935  printf("%s", "Alloc list\r\n")
937  } else if(!strcmp(parameters[0],"--showall")) {
938  printf("%s", "Free list\r\n")
940  printf("%s", "Alloc list\r\n")
942  } else if(!strcmp(parameters[0],"--testheap")) {
943  heapTest();
944  } else {
945  printf("Here are some possible commands: %s--showfree %s--showallocated%s\r\n", COLOR_RED, COLOR_YELLOW, COLOR_STOP);
946  }
947 
948  return 0;
949 }
#define COLOR_YELLOW
Definition: input.h:38
e_PCB_ERROR_CODE_t prevPCBError
Definition: pcb.c:13
#define BG_MAGENTA
Definition: input.h:30
#define COLOR_WHITE
Definition: input.h:39
u32int eflags
Definition: system.h:75
void set_time(int hours, int minutes, int seconds)
set_time sets the RTC time. Military time
Definition: rtc.c:33
linkedList_t mcbAllocList
Definition: mcb.c:6
linkedList_t mcbFreeList
Definition: mcb.c:5
int deletePCB(char parameters[][MAX_LENGTH])
deletePCB deletes the PCB requested by the user.
Definition: comm_list.c:782
Definition: pcb.h:47
void helpMcbPrint()
Prints the help menu for all mcb functions.
Definition: comm_list.c:116
linkedList_t readyQueue
Definition: pcb.c:3
void helpMCB(char parameters[][MAX_LENGTH])
The command handler for mcb&#39;s checking for valid input.
Definition: comm_list.c:93
void printPCBFunc(void *pcb)
printPCBFunc prints the status of a process
Definition: pcb.c:335
const char * errorToString(e_PCB_ERROR_CODE_t error)
errorToString creates a string form of the error passed in
Definition: pcb.c:267
void proc3()
Definition: procsr3.c:42
#define COLOR_RED
Definition: input.h:35
u32int gs
Definition: system.h:73
void proc2()
Definition: procsr3.c:27
int getNumDaysInMonth(int month, int year)
getNumDaysInMonth is a helper function to allow the easy retrieval of days in a month based on the mo...
Definition: comm_list.c:15
int sys_req(int op_code)
Definition: mpx_supt.c:11
void helpResumePCB()
helpResumePCB prints out the parameters and usage of the resume pcb command.
Definition: comm_list.c:343
void helpSuspendPCB()
helpSuspendPCB prints the help instructions for the suspendPCB command.
Definition: comm_list.c:335
void getDate()
getDate Get the current date from the system.
Definition: comm_list.c:447
#define BG_YELLOW
Definition: input.h:29
Definition: pcb.h:49
#define MAX_LENGTH
Definition: input.h:6
const char * procName
Definition: mcb.h:43
void set_date(int day, int month, int year)
set_date sets the RTC Date
Definition: rtc.c:79
int createPCB(const char *pcbName, const char *pcbPriority, const char *pcbClass)
createPCB creates a new PCB and allocates memory for the PCB.
Definition: comm_list.c:773
The s_processContext struct defines the context that each process stores .
Definition: system.h:71
void helpGetTime()
helpGetTime prints the help instructions for get time. Tells the user what the commands and arguments...
Definition: comm_list.c:206
int blockPCB(char parameters[][MAX_LENGTH])
blockPCB blocks the specified PCB
Definition: comm_list.c:794
void helpSetDate()
helpSetDate prints the help instructions for set date. Tells the user what the command and arguments ...
Definition: comm_list.c:197
#define printf(format,...)
printf is simply a wrapper macro around sprintf with built in terminal print builtin needs to be a ma...
Definition: string.h:112
pcb_t * findPCB(const char *processName)
findPCB will search all queues for the PCB with the input name
Definition: pcb.c:100
int time(char parameters[][MAX_LENGTH])
Definition: comm_list.c:479
int serial_print(const char *msg)
Definition: serial.c:59
void proc4()
Definition: procsr3.c:57
u32int esp
Definition: system.h:74
void helpUnblockPCB()
helpUnblockPCB prints out the parameters and usage for unblocking a PCB.
Definition: comm_list.c:415
void proc1()
Definition: procsr3.c:12
void helpBlockPCB()
helpBlockPCB prints out the parameters and usage for blocking a PCB.
Definition: comm_list.c:407
void helpMCBAllocate()
Prints the details for Allocating an mcb.
Definition: comm_list.c:136
void helpMCBIsEmpty()
Prints details for IsEmpty func.
Definition: comm_list.c:152
int showPCB(char parameters[][MAX_LENGTH])
showPCB shows the process information for the process requested by the user
Definition: comm_list.c:737
void proc5()
Definition: procsr3.c:72
e_PCB_ERROR_CODE_t changeProcessPriority(const char *procName, processPriority_t newPriority)
changeProcessPriority
Definition: pcb.c:342
void helpTime(char parameters[][MAX_LENGTH])
helpTime prints out the help information for time, for time –set and time –get
Definition: comm_list.c:261
void helpSetPriority()
helpSetPriority prints out to console the parameters and usage for –setpriority. ...
Definition: comm_list.c:351
int date(char parameters[][MAX_LENGTH])
Definition: comm_list.c:436
#define EXIT
Definition: mpx_supt.h:6
void helpShowReadyProcesses()
helpShowReadyProcesses shows the parameters and usage for showing ready PCBs.
Definition: comm_list.c:375
int isEmpty(char parameters[][MAX_LENGTH])
Definition: comm_list.c:35
Definition: pcb.h:38
void help()
help prints out a list of all possible commands and a brief description of what they do...
Definition: comm_list.c:72
linkedList_t blockedQueue
Definition: pcb.c:4
u32int fs
Definition: system.h:73
int mcbFunc(char parameters[][MAX_LENGTH])
takes in whatever you are looking for and checks to see if it can be done for mcb ...
Definition: comm_list.c:904
typedef for pcb_t struct
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
int suspendPCB(char parameters[][MAX_LENGTH])
suspendPCB suspends the pcb passed in by the user
Definition: comm_list.c:688
char in_string[MAX_LENGTH]
Definition: commhand.c:10
Definition: pcb.h:54
void helpMCBShowAllocated()
Prints details for showing all the allocated memory blocks in the heap.
Definition: comm_list.c:166
void printList(linkedList_t *list)
test function to show list functionality. uses const char* as test data
Definition: linked_list.c:212
void helpLoadR3()
helpLoadR3 prints out the help commands for helpLoadR3 Loads all of the processes from procsr3 ...
Definition: comm_list.c:174
void helpGetDate()
helpGetDate prints the help instructions for get date. Tells the user what the command and arguments ...
Definition: comm_list.c:190
void helpCreatePCB()
helpCreatePCB prints out the parameters and usage for createPCB.
Definition: comm_list.c:391
#define BG_BLUE
Definition: input.h:28
int resumePCB(char parameters[][MAX_LENGTH])
resumePCB resumes the PCB passed in by the user
Definition: comm_list.c:709
void getTime()
getTime this function has the side-effect of printing the current time to the terminal.
Definition: comm_list.c:490
int yield()
stops the exection of commhand and executes each process in the ready queue
Definition: comm_list.c:820
int version(char parameters[][MAX_LENGTH])
version prints out the current version of the operating system. It will print out R1...
Definition: comm_list.c:425
void helpPcbPrint()
helpPcbPrint prints out the commands for PCBs.
Definition: comm_list.c:314
int shutdownFunc(char parameters[][MAX_LENGTH])
shutdownFunc shuts down the OS.
Definition: comm_list.c:521
linkedList_t suspendedBlockedQueue
Definition: pcb.c:6
int loadr3(char parameters[][MAX_LENGTH])
loads all processes into memory in a suspended ready state at any priority of the users choosing ...
Definition: comm_list.c:825
u32int es
Definition: system.h:73
void helpMCBInitHeap()
prints the all details about the initheap func
Definition: comm_list.c:128
void setDate(char parameters[][MAX_LENGTH])
setDate sets the system date using the input from the user.
Definition: comm_list.c:453
void get_date(int *day, int *month, int *year)
get_date this function will retrieve the system date and place in three pointers
Definition: rtc.c:56
#define BG_RED
Definition: input.h:26
Definition: pcb.h:47
int pcbFunc(char parameters[][MAX_LENGTH])
takes in parameters and makes sure its valid then runs what you want to.
Definition: comm_list.c:558
u32int cs
Definition: system.h:75
int serial_println(const char *msg)
Definition: serial.c:44
void helpShowAllProcesses()
helpShowAllProcesses shows all processes in the system. Takes in no parameters and prints out to the ...
Definition: comm_list.c:367
void helpPcb(char parameters[][MAX_LENGTH])
helpPcb takes in the command to print the help information for. Calls the proper function to print th...
Definition: comm_list.c:284
int strlen(const char *s)
strlen returns the length of a string
Definition: string.c:10
void helpDeletePCB()
helpDeletePCB prints out the parameters and usage for deleting a PCB.
Definition: comm_list.c:399
u32int ebp
Definition: system.h:74
int showReadyProcesses(char parameters[][MAX_LENGTH])
showReadyProcesses shows all processes that are ready, in the ready queue (linked list)...
Definition: comm_list.c:759
e_PROCESS_CLASS_t stringToClass(const char *stringifiedClass)
stringToClass returns the enum representation of a string
Definition: pcb.c:328
int atoi(const char *s)
atoi converts and ASCII string to an integer
Definition: string.c:46
void helpShutdown()
helpShutdown prints the help instructions for set date. Tells the user what the command and arguments...
Definition: comm_list.c:222
int showBlockedProcesses(char parameters[][MAX_LENGTH])
showBlockedProcesses shows all processes that are blocked.
Definition: comm_list.c:766
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
#define IMPROPER_COMMAND
Definition: comm_vars.h:2
e_PCB_ERROR_CODE_t changeProcessSuspensionState(const char *processName, e_PROCESS_SUSPENSION_STATE_t suspensionState)
changeProcessSuspensionState
Definition: pcb.c:190
void helpDate(char parameters[][MAX_LENGTH])
helpDate prints out the help information for date, for date –set and date –get
Definition: comm_list.c:238
void helpSetTime()
helpSetTime prints the help instructions for set time. Tells the user what the command and arguments ...
Definition: comm_list.c:213
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
#define BG_GREEN
Definition: input.h:27
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
void heapTest()
heapTest test function to create sample mcbs.
Definition: mcb.c:286
int showAllProcesses(char parameters[][MAX_LENGTH])
showAllProcesses shows all processes in the system.
Definition: comm_list.c:746
char * serial_poll(char in_string[MAX_LENGTH])
Definition: serial.c:114
unsigned long u32int
Definition: system.h:27
int unblockPCB(char parameters[][MAX_LENGTH])
unblockPCB unblocks the specified PCB.
Definition: comm_list.c:807
void get_time(int *hours, int *minutes, int *seconds)
get_time this function will retrieve the system time and place it in three pointers. Military time
Definition: rtc.c:10
linkedList_t suspendedReadyQueue
Definition: pcb.c:5
int sprintf(char *str, int bufLength, const char *format,...) __attribute__((format(printf
sprintf print with format to specified string buffer
int helpGetVersion()
helpGetVersion prints the help instructions for version. Tells the user what the command and argument...
Definition: comm_list.c:181
#define VERSION
Definition: comm_vars.h:1
int setPriority(char *procName, char *procPrio)
setPriority sets the priority of a particular process
Definition: comm_list.c:730
int strcmp(const char *s1, const char *s2)
strcmp compares two strings.
Definition: string.c:77
#define COLOR_STOP
Definition: input.h:47
void helpMCBShowFree()
Prints details for showing all the free memory blocks in the heap.
Definition: comm_list.c:159
#define EXTRA_PARAMETERS
Definition: comm_vars.h:4
void helpShowPCB()
Definition: comm_list.c:359
void * memset(void *s, int c, size_t n)
memset Set a region of memory.
Definition: string.c:139
void helpMCBFreeMem()
Prints the details for freeing an mcb.
Definition: comm_list.c:144
void setTime(char parameters[][MAX_LENGTH])
setTime sets the current system time from the users input.
Definition: comm_list.c:500
void helpVersion()
helpVersion prints the help instructions for using the version command. No arguments are required...
Definition: comm_list.c:231
#define BG_ORANGE
Definition: input.h:32
void helpShowBlockedProcesses()
helpShowBlockedProcesses shows the parameters and usage for showing the blocked PCBs.
Definition: comm_list.c:383
u32int eip
Definition: system.h:75
#define COLOR_BLACK
Definition: input.h:40
int helpFunc(char parameters[][MAX_LENGTH])
helpFunc calls the other help functions
Definition: comm_list.c:49
#define BG_WHITE
Definition: input.h:23
#define COLOR_RED_DARK
Definition: input.h:45
u32int ds
Definition: system.h:73