int body(void) { char c, str[64]; printf("proc %d resumes to body()\n\r", running->pid); showLists(); while(1) { printf("\rproc %d running : enter a key [s|f|z|a|w|q|u|p|l]: ", running->pid); c = getc(); printf("%c\n\r", c); switch(c) { case 's': tswitch(); break; case 'q': do_exit(); break; case 'f': kfork("/bin/u1"); break; case 'z': do_sleep(); break; case 'a': do_wake(); break; case 'w': do_wait(); break; case 'u': goUmode(); break; case 'p': do_ps(); break; case 'l': showLists();break; default: break; } } }
int body() { char c; printf("proc %d resumes to body()\n", running->pid); while(1){ printf("-----------------------------------------\n"); printList("freelist ", freeList); printList("readyQueue", readyQueue); printList("sleepList ", sleepList); printf("-----------------------------------------\n"); printf("proc %d running: parent = %d enter a char [s|f|w|q|u] : ", running->pid, running->parent->pid); c = getc(); printf("%c\n", c); switch(c){ case 's' : do_tswitch(); break; case 'f' : do_kfork(); break; case 'w' : do_wait(); break; case 'q' : do_exit(); break; case 'u' : goUmode(); break; } } }
int kexec(char filename[15]) { int segment, i; if(strcmp(filename, "/bin/u1") != 0 && strcmp(filename, "/bin/u2") != 0) { printf("File not found.\n"); return -1; } segment = 0x1000*(running->pid+1); // We load the new file load(filename, segment); // We now fix the stack // (LOW) uSP | by INT 80 | HIGH // --------------------------------------------------------------------- // |uDS|uES| di| si| bp| dx| cx| bx| ax|uPC|uCS|flag| XXXXXX // --------------------------------------------------------------------- // -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 | 0 // (a). re-establish ustack to the very high end of the segment. // (b). "pretend" it had done INT 80 from (virtual address) 0: // (c). fill in uCS, uDS, uES in ustack // (d). execute from VA=0 ==> uPC=0, uFLAG=0x0200, // all other registers = 0; // (e). fix proc.uSP to point at the current ustack TOP (-24) // Finally, return from exec() ==> goUmode(). // Reset all registers to 0. for(i = 1; i <= 12; i++) { put_word(0, segment, 2*-i); } // uCS put_word(segment, segment, 2*-2); // uDS put_word(segment, segment, 2*-12); // uES put_word(segment, segment, 2*-11); // uPC put_word(0, segment, 2*-3); // uFLAG put_word(0x0200, segment, 2*-1); // Correct usp to point to top of stack running->usp = 2*-12; return goUmode(); }
int body() { char c, CR, buf[64]; while(1){ printf("=======================================\n"); printQueue(readyQueue); printf("proc %d %s in Kmode\n", running->pid, running->name); printf("input a command (s|f|u|q|i|o) : "); c=getc(); putc(c); CR=getc(); putc(CR); switch(c){ case 's' : tswitch(); break; case 'u' : printf("\nProc %d ready to go U mode\n", running->pid); goUmode(); break; case 'f': fork(); break; case 'q' : kexit(); break; case 'i' : iline(); break; case 'o' : oline(); break; } } }
int body() { char c; printf("proc %d resumes to body()\n", running->pid); while(1) { printf("-----------------------------------------\n"); //print freeList; printf("Free List:\n"); printQueue(freeList); // print readyQueue; printf("Ready Queue:\n"); printQueue(readyQueue); // print sleepList; printf("Sleep List:\n"); // printSleepQueue(sleepList); printSleepQueue(sleepList); printf("-----------------------------------------\n"); printf("proc %d[%d] running: parent=%d\n", running->pid, running->priority, running->ppid); printf("type a command [s|f|q|w| u ] : "); c = getc(); printf("%c\n", c); switch(c){ case 's' : do_tswitch(); break; case 'f' : do_kfork(); break; case 'q' : do_exit(); break; case 'w' : do_wait(); break; case 'u' : // printf("Running->uss: %x\n", running->uss); // printf("Running->usp: %x\n", running->usp); goUmode(); break; // let process goUmode } } }
int body() { char c; printf("proc %d resumes to body()\n", running->pid); while(1) { printLists(); printf("proc %d[%d] running: parent=%d\n", running->pid, running->priority, running->ppid); printf("enter a char [Debug|Fork|Umode|Ps|Quit|Sleep|Wait] : "); c = getc(); printf("%c\n", c); switch(c) { case 's' : tswitch(); break; case 'f' : kfork(); break; case 'q' : kexit(); break; case 'p' : kps(); break; case 'w' : kwait(); break; case 'd' : debugStatement(); break; case 'u' : goUmode(); break; } } }