main() { char name[64]; int cmd; /* resetVideo();*/ while(1){ pid = get_pid(); printf("==============================================\n"); printf("I am task %d in Umode at segment=%x\n", pid, getcs()); show_menu(); printf("Command ? "); mgets(name); if (name[0]==0) continue; cmd = find_cmd(name); switch(cmd){ case 0 : get_pid(); break; case 1 : ps(); break; case 2 : chname(); break; case 3 : kmode(); break; case 4 : kswitch(); break; case 5 : mywait(); break; case 6 : myexit(); break; case 7 : ufork(); break; case 8 : myexec("/u2"); break; case 9 : sin(); break; case 10 : sout(); break; default: invalid(name); break; } } }
main() { char name[64]; int pid, cmd; char c; while(1){ color = 0x0C; printf("----------------------------------------------\n"); pid = getpid(); printf("I am proc %d in U mode: running segment=%x\n", pid, getcs()); show_menu(); printf("Command ? "); gets(name); if (name[0]==0) continue; cmd = find_cmd(name); switch(cmd){ case 0 : getpid(); break; case 1 : ps(); break; case 2 : chname(); break; case 3 : kfork(); break; case 4 : kswitch(); break; case 5 : wait(); break; case 6 : exit(); break; case 7 : c = kgetc(); putc(c); putc('\n'); putc('\r'); break; case 8 : kputc(); break; default: invalid(name); break; } } }
main() { char name[64]; int pid, cmd; while(1){ pid = getpid(); color = 0x000A + (pid % 6); printf("----------------------------------------------\n"); printf("I am proc %d in U mode: running segment=%x\n",getpid(), getcs()); show_menu(); printf("Command ? "); gets(name); if (name[0]==0) continue; cmd = find_cmd(name); switch(cmd){ case 0 : getpid(); break; case 1 : ps(); break; case 2 : chname(); break; case 3 : kmode(); break; case 4 : kswitch(); break; case 5 : wait(); break; case 6 : exit(); break; default: invalid(name); break; } } }
main() { char name[64]; int pid, cmd, out; printf("in u2.c\n"); while(1) { pid = getpid(); color = 0x0C; printf("----------------------------------------------\n"); printf("I am proc %d in U2 mode: running segment=%x\n", getpid(), getcs()); show_menu(); printf("Your Order ? "); gets(name); if (name[0]==0) continue; cmd = find_cmd(name); if (cmd >= 0) { out = commands[cmd].f(); } else { invalid(name); } } }
main() { char name[64]; int cmd; int pid; while(1){ pid = getpid(); printf("==============================================\n"); printf("Das ist prozess %d im Umode segment=%x\n", pid, getcs()); show_menu(); printf("Command ? "); gets(name); if (name[0]==0) continue; cmd = find_cmd(name); switch(cmd){ case 0 : getpid(); break; case 1 : ps(); break; case 2 : chname(); break; case 3 : kmode(); break; case 4 : kswitch(); break; case 5 : mywait(); break; case 6 : myexit(); break; case 7 : ufork(); break; case 8 : myexec("/bin/u1"); break; case 9 : sin(); break; case 10: sout(); break; default: invalid(name); break; } } }
main() { char name[64]; int pid, cmd; color = 0x0F; while(1){ printf("----------------------------------------------\n"); pid = getpid(); printf("I am proc %d in U mode: running segment=%x\n", pid, getcs()); show_menu(); printf("Command ? "); gets(name); if (name[0]==0) continue; cmd = find_cmd(name); switch(cmd){ case 0 : getpid(); break; case 1 : ps(); break; case 2 : chname(); break; case 3 : pid = kfork(); printf("fork returned: %d\n", pid); break; case 4 : kswitch(); break; case 5 : wait(); break; case 6 : exit(); break; case 7 : pid = exec(); printf("exec returned: %d\n", pid); break; default: invalid(name); break; } } }
main() { char name[64]; int pid, cmd; pid = getpid(); while(1){ color = 0x0000B + pid; printf("==============================================\n"); printf("\nIch bin Prozess %d in der U Weise: das laufen im Segment=%x\n", getpid(), getcs()); #include "ubody.c" } }
int main(int argc, char *argv[]) { char name[64]; int pid, cmd; int pd[2]; while(1){ printf("\n----------------------------------------------\n"); #ifndef _LAB_3_ printf("I am proc %d in U mode with ppid %d: running segment=%x\n",getpid(), getppid(), getcs()); #else printf("I am proc "); getpid(); printf(" in U mode: running segment=%x\n", getcs()); #endif #ifdef _SLEEPER_ while(1) { printf("PID: %d PPID: %d\n", getpid(), getppid()); sleep(5); return 0; } #endif show_menu(); printf("Command? "); gets(name); printf("\n"); if (name[0]==0) continue; cmd = find_cmd(name); switch(cmd){ case 0: getpid(); break; case 1: ps(); break; case 2: chname(); break; case 3: kswitch(); break; case 4: wait(); break; case 5: ufork(); break; case 6: uexec(); break; case 7: exit(); break; case 8: pipe(pd); break; case 9: pfd(); break; case 10: uclose(); break; case 11: uread(); break; case 12: uwrite(); break; case 13: usleep(); break; default:invalid(name);break; } } }
int uvfork() { int pid, status; printf("do_vfork()\n"); pid = vfork(); if (pid){ printf("vfork parent %d waits\n", getpid()); pid = wait(&status); printf("vfork parent %d back form wait, dead child=%d\n", getpid(),pid); } else{ printf("vforked child %d in segment=%x\n", getpid(), getcs()); printf("This is Goldilocks playing in Papa bear's bed\n"); printf("**** EXEC NOW! before he wakes up *****\n"); exec("u2 one two three"); printf("exec failed\n"); } }
int do_vfork() { int pid, status; printf("do_vfork()\n"); pid = vfork(); if (pid){ printf("vfork parent %d waits\n", getpid()); pid = wait(&status); printf("vfork parent %d back form wait, dead child=%d\n", getpid(),pid); } else{ printf("vforked child %d in segment=%x\n", getpid(), getcs()); printf("This is Goldilocks playing in Papa bear's bed\n"); printf("EXEC NOW! before he wakes up\n"); syscall(8,"u2 Bye! Bye! Papa Bear"); printf("exec failed\n"); } }
main() { char name[64]; int pid, cmd; pid = getpid(); while(1){ color = 0x0000B + pid; printf("==============================================\n"); printf("\nIch bin Prozess %d in der U Weise: das laufen im Segment=%x\n", getpid(), getcs()); show_menu(); printf("Command ? "); gets(name); if (name[0]==0) continue; cmd = find_cmd(name); printf("find_cmd = %d\n", cmd); switch(cmd){ case 0 : getpid(); break; case 1 : ps(); break; case 2 : chname(); break; case 3 : kmode(); break; case 4 : kswitch(); break; case 5 : wait(); break; case 6 : exit(); break; case 7 : fork(); break; case 8 : exec(); break; case 9 : pipe(); break; case 10: pfd(); break; case 11 : read_pipe(); break; case 12 : write_pipe();break; case 13: close(); break; default: invalid(name); break; } } }
main() { char name[64]; int pid, cmd; while(1){ pid = getpid(); color = 0x000B + (pid % 6); printf("----------------------------------------------\n"); printf("I am proc %d in U mode: running segment=%x\n",getpid(), getcs()); show_menu(); printf("Command ? "); gets(name); if (name[0]==0) continue; cmd = find_cmd(name); printf("find_cmd = %d\n", cmd); /*char *cmd[]={"getpid", "ps", "chname", "kmode", "switch", "wait", "exit", "fork", "exec", "pipe", "pfd", "read", "write", "close", 0};*/ switch(cmd){ case 0 : getpid(); break; case 1 : ps(); break; case 2 : chname(); break; case 3 : kmode(); break; case 4 : kswitch(); break; case 5 : wait(); break; case 6 : exit(); break; case 7 : fork(); break; case 8 : exec(); break; case 9 : pipe(); break; case 10: pfd(); break; case 11 : read_pipe(); break; case 12 : write_pipe();break; case 13: close_pipe(); break; default: invalid(name); break; } } }
main() { char name[64]; int pid, cmd; while(1){ printf("==============================================\n"); printf("\nIch bin Prozess %d in der U Weise: das laufen im Segment=%x\n", getpid(), getcs()); show_menu(); printf("Command ? "); gets(name); if (name[0]==0) continue; cmd = find_cmd(name); switch(cmd){ case 0 : getpid(); break; case 1 : ps(); break; case 2 : chname(); break; case 3 : kmode(); break; case 4 : kswitch(); break; case 5 : wait(); break; case 6 : die(); break; case 7 : ufork(); break; case 8 : uexec(); break; case 9 : chcolor(); break; default: invalid(name); break; } } }