aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--com.c55
-rw-r--r--comhan.c99
-rw-r--r--io.c65
-rw-r--r--main.c7
-rw-r--r--mpx.h3
-rw-r--r--pcb.c12
-rw-r--r--printer.c7
-rw-r--r--prog/COMPRT.MPXbin0 -> 1008 bytes
-rw-r--r--prog/CPUCOM1.MPXbin0 -> 896 bytes
-rw-r--r--prog/CPUCOM2.MPXbin0 -> 896 bytes
-rw-r--r--prog/CPUCOM3.MPXbin0 -> 912 bytes
-rw-r--r--prog/CPUCON.MPXbin0 -> 880 bytes
-rw-r--r--prog/CPUPRT1.MPXbin0 -> 912 bytes
-rw-r--r--prog/CPUPRT2.MPXbin0 -> 880 bytes
-rw-r--r--prog/IDLE.MPXbin0 -> 800 bytes
-rw-r--r--prog/IOCOM1.MPXbin0 -> 880 bytes
-rw-r--r--prog/IOCOM2.MPXbin0 -> 1008 bytes
-rw-r--r--prog/IOCOM3.MPXbin0 -> 1008 bytes
-rw-r--r--prog/IOCOM4.MPXbin0 -> 912 bytes
-rw-r--r--prog/IOCOMPRT.MPXbin0 -> 1024 bytes
-rw-r--r--prog/IOCON.MPXbin0 -> 864 bytes
-rw-r--r--prog/IOPRT1.MPXbin0 -> 880 bytes
-rw-r--r--prog/IOPRT2.MPXbin0 -> 864 bytes
-rw-r--r--prog/IOPRT3.MPXbin0 -> 1008 bytes
-rw-r--r--prog/NULL.MPXbin0 -> 864 bytes
-rw-r--r--sys_sppt.c29
26 files changed, 163 insertions, 114 deletions
diff --git a/com.c b/com.c
index 1d21a0a..d996e66 100644
--- a/com.c
+++ b/com.c
@@ -3,7 +3,8 @@
* CSI350 Operating Systems
* Fall 2013
* Averill Morash, Ben Burwell
- * COM.C
+ *
+ * File: com.c
*/
#include <dos.h>
@@ -16,6 +17,7 @@ void interrupt (*vect0c)();
int com_opened;
+// Open the com port
int com_open(int * flag, int rate) {
unsigned char imr;
unsigned char mcr;
@@ -24,13 +26,15 @@ int com_open(int * flag, int rate) {
disable();
+ // Ensure com has not already been opened, if
+ // it has, we must return.
if (com_opened == NULL || com_opened == 0) {
com_opened = 1;
} else {
return -2;
}
- // modify the interrupt vector table
+ // Modify the interrupt vector table
vect0c = getvect(0x0c);
setvect(0x0c, &com_int);
@@ -48,6 +52,7 @@ int com_open(int * flag, int rate) {
// 1843200 / (1200 * 16) = 96 = 0x0060
// So the MSB is 0x00 and the LSB is 0x60
+ // Ensure baud rate is valid
if (rate != 1200) {
return -3;
}
@@ -97,17 +102,27 @@ int com_open(int * flag, int rate) {
return 0;
}
+// Com Close
void com_close() {
disable();
+
+ // restore MS-DOS com vector
setvect(0x0c, vect0c);
+
enable();
}
+// Interrupt handler
void interrupt com_int() {
int iir;
int *lst_stk;
- int ret = 0; //0 indicates not finished, 1 indicated finshed
+ // 0 indicates not finished, 1 indicated finshed
+ int ret = 0;
+
+ disable();
+
+ // save base pointer
lst_stk = _BP;
// check IIR to see what caused the interrupt
@@ -120,10 +135,11 @@ void interrupt com_int() {
} else if (iir == 0x04) { // 0000-0100
ret = com_read_int();
} else {
- // something is wrong
+ // interrupt was not read or write
return;
}
+ // if the operation is done, call IO_complete
if (ret == 1) {
IO_complete(COM, lst_stk);
}
@@ -131,70 +147,92 @@ void interrupt com_int() {
// write end of interrupt to 8259
outportb(0x20, 0x20);
+ enable();
return;
}
+// Read from the com port
int com_read(char far * buffer, int far * length) {
char dq;
int i;
+ disable();
+
+ // if we haven't yet opened com, we can't proceed
if (&com == NULL) {
- // com not yet open
+ enable();
return -1;
}
// check for invalid length
if (*length < 1) {
+ enable();
return -3;
}
// check if DCB is free
if (com.current_op != NO_OP) {
// previous IO not yet complete
- // TODO: we should block this process
+ enable();
return -2;
}
+ if (buffer == NULL || length == NULL) {
+ printf("error in com_read\n");
+ enable();
+ return;
+ }
+ // set up the DCB
com.buffer = buffer;
com.length = length;
com.current_op = READ_OP;
com.count = 0;
+ // clear the buffer
strcpy(buffer, "");
+ // now we need to use the ring buffer to place typed-ahead
+ // characters into the buffer
+
+ // keep track of how many characters are copied from the
+ // ring buffer.
i = 0;
while (com.ring_count > 0 && strlen(buffer) < *length) {
-
dq = dcb_dequeue(&com);
- //strcat(buffer, &dq);
buffer[i] = dq;
i++;
}
+ // place a null character at the end of the buffer
buffer[i] = '\0';
com.count = i;
+ enable();
return 0;
}
int com_write(char far * buffer, int far * length) {
int ier;
+ disable();
// check that com has been initialized
if (&com == NULL) {
+ enable();
return -1;
}
// check that com is not busy
if (com.current_op != NO_OP) {
+ enable();
return -2;
}
// check that the length is valid
if (*length < 1) {
+ enable();
return -3;
}
@@ -210,6 +248,7 @@ int com_write(char far * buffer, int far * length) {
ier = ier | 0x02;
outportb(IER, ier);
+ enable();
return 0;
}
diff --git a/comhan.c b/comhan.c
index 8506ef4..9e6c03a 100644
--- a/comhan.c
+++ b/comhan.c
@@ -22,36 +22,32 @@
#define PROMPT 5
#define ALIAS 6
#define SHOW 7
-#define ALLOCATE 8
-#define CMD_FREE 9
-#define CMD_LOAD 10
-#define CMD_RESUME 11
-#define CMD_RUN 12
-#define CMD_SUSPEND 13
-#define CMD_TERMINATE 14
-#define CMD_SETPRI 15
-#define CMD_DISPATCH 16
-#define CLOCK 17
-
-#define NUM_CMDS 18
-
-int length; /* Length of the command line. */
+#define CMD_LOAD 8
+#define CMD_RESUME 9
+#define CMD_RUN 10
+#define CMD_SUSPEND 11
+#define CMD_TERMINATE 12
+#define CMD_SETPRI 13
+#define CLOCK 14
+
+#define NUM_CMDS 15
+
+int length = 1; /* Length of the command line. */
unsigned sp_save; /* A stack save for mod 4 dispatch. */
char prompt[20] = "mpx>";
-const char version[] = "MPX OS - Version 1.0\n";
+const char version[] = "MPX-OS 2013 ZOMBIE Edition (v.1010372365424) \n";
char date[] = "01/09/1991";
char *cmds[] = { "version", "date", "directory", "stop",
"help", "prompt", "alias", "show",
- "allocate", "free", "load", "resume",
+ "load", "resume",
"run", "suspend", "terminate", "setpriority",
- "dispatch", "clock", NULL};
+ "clock", NULL};
char *aliases[] = {" ", " ", " ", " ",
" ", " ", " ", " ",
" ", " ", " ", " ",
- " ", " ", " ", " ",
- " ", " ", NULL};
+ " ", " ", " ", NULL};
/*
* comhan() This is the command handler for the MPX OS.
@@ -68,13 +64,18 @@ void comhan() {
static char buffer[BUF_SIZE];
int do_stop = 0;
+ // Occasionally the first con_read request recieves an empty response
+ // Make a dummy request to compensate
+ sys_req(CON, READ, buffer, &length);
+
do {
printf("%s ",prompt); /* Print a prompt. */
- //length = 4; //mpx>
- //sys_req(COM, WRITE, prompt, &length);
length = BUF_SIZE; /* Reset length of buffer. */
sys_req(CON,READ,buffer,&length); /* Request CON input */
+ // For better display, print a newline after user input
+ printf("\n");
+
set_args(buffer, args);
switch (get_cmd(args[0])) {
@@ -86,15 +87,12 @@ void comhan() {
case PROMPT: cmd_prompt(args); break;
case ALIAS: cmd_alias(args); break;
case SHOW: cmd_show(args); break;
-// case ALLOCATE: cmd_allocate(args); break;
-// case CMD_FREE: cmd_free(args); break;
case CMD_LOAD: cmd_load(args); break;
case CMD_RESUME: cmd_resume(args); break;
case CMD_RUN: cmd_run(args); break;
case CMD_SUSPEND: cmd_suspend(args); break;
case CMD_TERMINATE: cmd_terminate(args); break;
case CMD_SETPRI: cmd_setpri(args); break;
-// case CMD_DISPATCH: cmd_dispatch(); break;
case CLOCK: cmd_clock(args); break;
default:
printf("Can't recognize. %s\n", args[0]);
@@ -128,8 +126,7 @@ int get_cmd(char cmd[]){
int set_args(char buffer[], char *args[]) {
/* use string tok to set the contents of args from buffer
and return the number of args (will go into argc) */
- char separators[5] = " /,:"; //Characters that separate tokens
- // TODO: put = back in separators
+ char separators[6] = " /,:="; //Characters that separate tokens
int i = 0; //loop control
args[i] = strtok(buffer, separators); //Get first token
@@ -202,6 +199,7 @@ int cmd_stop(){
sys_req(CON,READ,buffer,&length);
if (strcmp(buffer, "y") == 0 || strcmp(buffer, "Y") == 0) {
+ disable();
do {
if(p->type != FREE) {
freemem(p->loadaddr);
@@ -209,6 +207,7 @@ int cmd_stop(){
}
p = p->chain;
} while(p != NULL);
+ enable();
sys_exit();
printf("** COMHAN execution complete **\n");
return 1;
@@ -234,17 +233,18 @@ void cmd_help(char *args[]) {
help[PROMPT] = "prompt string Change the prompt for commands";
help[ALIAS] = "alias command=string Create an alias for a command";
help[SHOW] = "show Prints PCB information";
- help[ALLOCATE] = "allocate Builds PCB with specified options";
- help[CMD_FREE] = "free name Frees the PCB called name";
help[CMD_LOAD] = "load name[=ppp] Creates a process called name with priority ppp";
help[CMD_RESUME] = "resume name Resumes the process called name";
help[CMD_RUN] = "run name[=ppp] Runs a process called name with priority ppp";
help[CMD_SUSPEND] = "suspend name Suspends the process called name";
help[CMD_TERMINATE] = "terminate name Terminates the process called name";
help[CMD_SETPRI] = "setpriority name=ppp Sets the priority of process name";
- help[CMD_DISPATCH] = "dispatch Runs each process once";
help[CLOCK] = "clock [stop|start] Perform clock operations";
+ if (args[1] != NULL && get_cmd(args[1]) < 0) {
+ printf("Not a valid command.\n");
+ return;
+ }
// print header
printf( " Name Use \n");
printf( " ==================== ================================================= \n");
@@ -294,6 +294,8 @@ void print_pcb(pcb * p) {
str[1] = 'o';
} else if (p->state == BLOCKED) {
str[1] = 'b';
+ } else if (p->state == ZOMBIE) {
+ str[1] = 'z';
} else {
str[1] = '-';
}
@@ -308,7 +310,7 @@ void print_pcb(pcb * p) {
str[3] = '\0';
- printf("0x%04x %8s %s 0x%04x 0x%04x 0x%04x %3d 0x%04x \n",
+ printf("0x%04x %8s %s 0x%04x 0x%04x 0x%04x %4d 0x%04x \n",
p, p->name, str, p->chain, p->prev,
p->next, p->priority, p->loadaddr);
}
@@ -322,12 +324,12 @@ void cmd_show(char *args[]) {
return;
}
- printf("PCB_Ad Name TSP chain prev next pri l_addr \n");
- printf("------ -------- --- ------ ------ ------ --- ------ \n");
+ printf("PCB_Ad Name TSP chain prev next pri l_addr \n");
+ printf("------ -------- --- ------ ------ ------ ---- ------ \n");
if (strcmp(args[1], "init") == 0 || strcmp(args[1], "ready") == 0) {
disable();
- current = (strcmp(args[1], "init") == 0)? io_init_queue : ready_queue_locked;
+ current = (strcmp(args[1], "init") == 0)? io_init_queue_locked : ready_queue_locked;
enable();
if (current == NULL) {
@@ -368,7 +370,7 @@ void cmd_show(char *args[]) {
* Load
*/
void cmd_load(char *args[]) {
- int i, ret, priority = 0;
+ int i, priority = 0;
unsigned segp;
pcb *p;
int paragraphs;
@@ -514,19 +516,10 @@ void cmd_terminate(char *args[]) {
if (strcmp(args[1], "*") == 0) {
p = pcb_list;
do {
+ // Set all application processes to ZOMBIE state
+ // They will be terminated in dispatch()
if (p->type == APP_PROCESS) {
- // remove from queue as needed
- disable();
- if (p->state == READY) {
- remove_pcb(&ready_queue_locked, p);
- } else if (p->state == BLOCKED) {
- remove_pcb(&io_init_queue, p);
- }
- enable();
-
- // free it
- freemem(p->loadaddr);
- free_pcb(pcb_list, p);
+ p->state = ZOMBIE;
}
p = p -> chain;
} while (p != NULL);
@@ -535,19 +528,7 @@ void cmd_terminate(char *args[]) {
p = search_pcb(pcb_list, args[1]);
if (p != NULL && p->type == APP_PROCESS) {
-
- disable();
- // remove from queue as needed
- if (p->state == READY) {
- remove_pcb(&ready_queue_locked, p);
- } else if (p->state == BLOCKED) {
- remove_pcb(&io_init_queue, p);
- }
- enable();
-
- // free it
- freemem(p->loadaddr);
- free_pcb(pcb_list, p);
+ p->state = ZOMBIE;
} else {
printf("No process with the specified name. \n");
}
diff --git a/io.c b/io.c
index aa9b027..f5bf17a 100644
--- a/io.c
+++ b/io.c
@@ -9,14 +9,13 @@
#include <stdio.h>
#include "mpx.h"
-#define DS_OFFSET 6 // was 3 before
+#define DS_OFFSET 6
-int count = 0;
void IO_sup(pcb *p) {
- char far *buffer;
- int far *length;
- unsigned *ds_add;
- int con_w = 0;
+ char far *buffer; // far pointer to the io buffer
+ int far *length; // far pointer to an int representing length of the io buffer
+ unsigned *ds_add; // data segment address
+ int con_w = 0; // flag for if the request was a con_write request
int rc;
disable();
@@ -69,6 +68,9 @@ void IO_sup(pcb *p) {
// put the pcb back in the ready queue, if it was a con_write
if (con_w == 1) {
insert_pcb(&ready_queue_locked, p,0);
+ p->state = READY;
+ } else {
+ p->state = BLOCKED;
}
enable();
return;
@@ -81,9 +83,14 @@ int IO_complete(int device, int *stk_ptr) {
dcb *d;
disable();
+ // get the dcb for the requested device
switch (device){
case CON:
d = &con;
+ // the con dcb isn't managed by con drive
+ // so we need to reset it here, but the
+ // other dcbs are handled in those files
+ // before calling io_complete
d->current_op = NO_OP;
break;
case COM:
@@ -111,20 +118,32 @@ int IO_complete(int device, int *stk_ptr) {
// insert into ready queue
insert_pcb(&ready_queue_locked, current, 0);
- // set its state to ready
- current->state = READY;
+ // set its state to ready, unless it became
+ // a zombie while it was waiting for io to complete
+ if (current->state != ZOMBIE) {
+ current->state = READY;
+ }
- if (strcmp(d->current_pcb->name, "iocom2")==0) {
- count++;
- if (count > 20) {
- d = &com;
+ if (io_init_queue_locked != NULL) {
+ // if there are pending IO requests schedule them
+ current = io_init_queue_locked;
+ while (current != NULL && current->parm_add->op_number != device) {
+ current = current->next;
+ }
+
+ if (current != NULL) {
+ // take the pcb out of the io_init queue
+ remove_pcb(&io_init_queue_locked, current);
+
+ // if it wasn't terminated while waiting for io...
+ if (current->state != ZOMBIE) {
+ // ... schedule the io
+ IO_sched(current);
+ } else {
+ // send the zombie back to be ... dispatched ... muahaha
+ insert_pcb(&ready_queue_locked, current, 0);
+ }
}
- }
- if (d->pcb_head != NULL) {
- // if there are pending IO requests for this device
- //schedule them (IO_sched)
- remove_pcb(&(d->pcb_head), d->pcb_head);
- IO_sched(d->pcb_head);
}
outportb(0x20,0x20); // EOI signal
@@ -145,6 +164,7 @@ int IO_sched(pcb *p) {
int op_num;
int op_type;
+ disable();
if (DEBUG_PRINTS) {printf("in io sched\n");}
// determine which device is requested
@@ -176,17 +196,18 @@ int IO_sched(pcb *p) {
return -2;
}
+ // If the device is busy
if (d->current_op != NO_OP) {
disable();
// put pcb in IO queue
- insert_pcb(&(d->pcb_head), p, 1);
- // take pcb out of ready q
- remove_pcb(&ready_queue_locked, p);
+ insert_pcb(&io_init_queue_locked, p, 1);
+ p->state = BLOCKED;
enable();
} else {
+ // If the device wasn't busy, start the io
d->current_pcb = p;
IO_sup(p);
}
-
+ enable();
return 0;
}
diff --git a/main.c b/main.c
index 41269bf..020ab05 100644
--- a/main.c
+++ b/main.c
@@ -11,7 +11,7 @@
pcb * pcb_list;
pcb * ready_queue_locked;
-pcb * io_init_queue;
+pcb * io_init_queue_locked;
pcb * cop;
pcb pcb0;
@@ -38,7 +38,6 @@ unsigned sys_stack[STACK_SIZE];
int main(void) {
pcb * pcb_addr;
- int rc;
dcb * d = &con;//test
char *args[] = {"load", "idle"};
@@ -88,7 +87,7 @@ int main(void) {
// set up command handler as a PCB
pcb_addr = get_pcb(pcb_list);
- rc = build_pcb(pcb_addr, "ComHan", SYS_PROCESS, READY, NOT_SUSPENDED, 127, _CS,
+ build_pcb(pcb_addr, "ComHan", SYS_PROCESS, READY, NOT_SUSPENDED, 127, _CS,
(unsigned)comhan, _DS, 0x200);
disable();
@@ -106,7 +105,7 @@ int main(void) {
// update priority for idle process
// we can't do this when initially calling because of
// APP_PROCESS type priority validation
- pcb_addr = search_pcb(&pcb_list, "idle");
+ pcb_addr = search_pcb(pcb_list, "idle");
pcb_addr->priority = -128;
pcb_addr->suspend = NOT_SUSPENDED;
pcb_addr->type = SYS_PROCESS;
diff --git a/mpx.h b/mpx.h
index 3a9ad85..09f1ac7 100644
--- a/mpx.h
+++ b/mpx.h
@@ -54,6 +54,7 @@ typedef struct parmstruct parm;
#define READY 0
#define RUNNING 1
#define BLOCKED 2
+#define ZOMBIE 3
#define NOT_SUSPENDED 0
#define SUSPENDED 1
#define STACK_SIZE 900
@@ -227,7 +228,7 @@ extern dir direct[]; /* Array of directory entries - see direct.c */
extern int directory(dir *direct, int dir_size);
extern pcb * pcb_list;
extern pcb * ready_queue_locked;
-extern pcb * io_init_queue;
+extern pcb * io_init_queue_locked;
extern pcb * cop; /* The currently operating process. */
extern unsigned sys_stack[];
extern unsigned sp_save; /* So that mod 4 can return to cmd_dispatch */
diff --git a/pcb.c b/pcb.c
index c69dd87..1375ae0 100644
--- a/pcb.c
+++ b/pcb.c
@@ -126,12 +126,10 @@ int insert_pcb(pcb **queue, pcb * addr, int method) {
pcb * current = *queue;
pcb * one_after;
- disable();
// if there's nothing in the queue yet, make the PCB the start
if (current == NULL) {
*queue = addr;
- enable();
return 1;
}
@@ -147,7 +145,6 @@ int insert_pcb(pcb **queue, pcb * addr, int method) {
current->next = addr;
addr->next = NULL;
addr->prev = current;
- enable();
return 1;
} else if (method == 0) {
// insert in priority order
@@ -176,10 +173,8 @@ int insert_pcb(pcb **queue, pcb * addr, int method) {
addr->next = current;
*queue = addr;
}
- enable();
return 1;
} else {
- enable();
// There was a problem, return error code
return -1;
}
@@ -191,7 +186,11 @@ int insert_pcb(pcb **queue, pcb * addr, int method) {
int remove_pcb(pcb **queue, pcb * addr) {
pcb * current = *queue;
- disable();
+ if (addr == NULL || *queue == NULL) {
+ printf("bad times ahead \n");
+ return;
+ }
+
// are we removing the head?
if (addr == *queue) {
*queue = addr->next;
@@ -215,6 +214,5 @@ int remove_pcb(pcb **queue, pcb * addr) {
}
current = current->next;
} while (current != NULL);
- enable();
return -1;
}
diff --git a/printer.c b/printer.c
index 6eab61e..60e96e3 100644
--- a/printer.c
+++ b/printer.c
@@ -15,7 +15,6 @@ int prt_opened;
int prt_open(int * prt_flag) {
unsigned char imr;
- unsigned char pcr;
disable();
@@ -48,7 +47,6 @@ int prt_open(int * prt_flag) {
}
int prt_write(char far *buffer, int far *length) {
- unsigned char pcr;
disable();
// check that prt isn't busy
@@ -89,7 +87,6 @@ int prt_write(char far *buffer, int far *length) {
}
int prt_close() {
- unsigned char pcr;
unsigned char imr;
disable();
@@ -114,8 +111,8 @@ int prt_close() {
void interrupt prt_int() {
unsigned char pcr;
int *lst_stk;
- float temp;
+ disable();
lst_stk = _BP;
// if no more char to write
@@ -131,7 +128,6 @@ void interrupt prt_int() {
*(prt.event_flag) = 1;
// call io-complete
- // TODO: the book says (pg 86) that there should be stuff passed to io-complete
IO_complete(PRT, lst_stk);
// send end of interrupt signal
@@ -153,4 +149,5 @@ void interrupt prt_int() {
// send EOI
outportb(0x20, 0x20);
+ enable();
} \ No newline at end of file
diff --git a/prog/COMPRT.MPX b/prog/COMPRT.MPX
new file mode 100644
index 0000000..0cf0bc0
--- /dev/null
+++ b/prog/COMPRT.MPX
Binary files differ
diff --git a/prog/CPUCOM1.MPX b/prog/CPUCOM1.MPX
new file mode 100644
index 0000000..007a6ba
--- /dev/null
+++ b/prog/CPUCOM1.MPX
Binary files differ
diff --git a/prog/CPUCOM2.MPX b/prog/CPUCOM2.MPX
new file mode 100644
index 0000000..8c412d7
--- /dev/null
+++ b/prog/CPUCOM2.MPX
Binary files differ
diff --git a/prog/CPUCOM3.MPX b/prog/CPUCOM3.MPX
new file mode 100644
index 0000000..0eee0f6
--- /dev/null
+++ b/prog/CPUCOM3.MPX
Binary files differ
diff --git a/prog/CPUCON.MPX b/prog/CPUCON.MPX
new file mode 100644
index 0000000..cb62708
--- /dev/null
+++ b/prog/CPUCON.MPX
Binary files differ
diff --git a/prog/CPUPRT1.MPX b/prog/CPUPRT1.MPX
new file mode 100644
index 0000000..fe9cc56
--- /dev/null
+++ b/prog/CPUPRT1.MPX
Binary files differ
diff --git a/prog/CPUPRT2.MPX b/prog/CPUPRT2.MPX
new file mode 100644
index 0000000..ce7efee
--- /dev/null
+++ b/prog/CPUPRT2.MPX
Binary files differ
diff --git a/prog/IDLE.MPX b/prog/IDLE.MPX
new file mode 100644
index 0000000..b3d5a4e
--- /dev/null
+++ b/prog/IDLE.MPX
Binary files differ
diff --git a/prog/IOCOM1.MPX b/prog/IOCOM1.MPX
new file mode 100644
index 0000000..93b93a4
--- /dev/null
+++ b/prog/IOCOM1.MPX
Binary files differ
diff --git a/prog/IOCOM2.MPX b/prog/IOCOM2.MPX
new file mode 100644
index 0000000..bba7788
--- /dev/null
+++ b/prog/IOCOM2.MPX
Binary files differ
diff --git a/prog/IOCOM3.MPX b/prog/IOCOM3.MPX
new file mode 100644
index 0000000..439c564
--- /dev/null
+++ b/prog/IOCOM3.MPX
Binary files differ
diff --git a/prog/IOCOM4.MPX b/prog/IOCOM4.MPX
new file mode 100644
index 0000000..cd1879d
--- /dev/null
+++ b/prog/IOCOM4.MPX
Binary files differ
diff --git a/prog/IOCOMPRT.MPX b/prog/IOCOMPRT.MPX
new file mode 100644
index 0000000..c326963
--- /dev/null
+++ b/prog/IOCOMPRT.MPX
Binary files differ
diff --git a/prog/IOCON.MPX b/prog/IOCON.MPX
new file mode 100644
index 0000000..4f831a4
--- /dev/null
+++ b/prog/IOCON.MPX
Binary files differ
diff --git a/prog/IOPRT1.MPX b/prog/IOPRT1.MPX
new file mode 100644
index 0000000..8a76d99
--- /dev/null
+++ b/prog/IOPRT1.MPX
Binary files differ
diff --git a/prog/IOPRT2.MPX b/prog/IOPRT2.MPX
new file mode 100644
index 0000000..258ebf7
--- /dev/null
+++ b/prog/IOPRT2.MPX
Binary files differ
diff --git a/prog/IOPRT3.MPX b/prog/IOPRT3.MPX
new file mode 100644
index 0000000..720371b
--- /dev/null
+++ b/prog/IOPRT3.MPX
Binary files differ
diff --git a/prog/NULL.MPX b/prog/NULL.MPX
new file mode 100644
index 0000000..6c6a6a2
--- /dev/null
+++ b/prog/NULL.MPX
Binary files differ
diff --git a/sys_sppt.c b/sys_sppt.c
index c5b784e..6c4923c 100644
--- a/sys_sppt.c
+++ b/sys_sppt.c
@@ -44,9 +44,11 @@ void sys_init()
void sys_exit()
{
+ disable();
// restore the clock
clock_close();
+ // close IO devices
com_close();
con_close();
prt_close();
@@ -54,6 +56,7 @@ void sys_exit()
/* restore interrupt vector 60 and exit */
setvect(0x60,vect60);
+ enable();
exit();
}
@@ -62,22 +65,33 @@ void interrupt dispatch()
{
disable();
if (DEBUG_PRINTS) {printf("in dispatch \n ");}
- // TODO fix this.. .cop is null when we start
+
cop = ready_queue_locked;
+ // kill zombie processes
+ while (cop->state == ZOMBIE) {
+ remove_pcb(&ready_queue_locked, cop);
+ freemem(cop->loadaddr);
+ free_pcb(pcb_list, cop);
+ cop = ready_queue_locked;
+ }
+
// skip over suspended processes
while (cop != NULL && cop->suspend == SUSPENDED) {
cop = cop -> next;
}
+
if (DEBUG_PRINTS){
- if (cop == NULL) {
- printf("!!cop null?!!!\n");
- } else {
- printf("cop - %s\n", cop->name);
- }
+ if (cop == NULL) {
+ printf("!!cop null?!!!\n");
+ } else {
+ printf("cop - %s\n", cop->name);
+ }
}
remove_pcb(&ready_queue_locked, cop);
+ cop->state = RUNNING;
+
enable();
_SP = cop -> stack_ptr;
@@ -104,10 +118,9 @@ void interrupt sys_call()
// find out if the process wants to die... and kill it
if (parm_add->op_number == EXIT_CODE) {
- strcpy(cop->name,"averill");
- //TODO: CHECK IF THE PCB HAS IO PENDING
freemem(cop->loadaddr);
free_pcb(pcb_list, cop);
+ // NOTE: the process just made this sys_req so it cannot have any io
} else {
IO_sched(cop);
}