


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



process - Answers - sequential program in execution resource - Answers - abstract resource that a process requests. can block! cause you're using it file - Answers - a type of resource, but it's a stream of bytes classic process - Answers - one process per task. you multiprogram them, space- muxing in memory and time-muxing in cpu. so programs are CONCURRENT, not parallel modern process - Answers - process is only the infrastructure, the thread is a part of it with a STACK. since it's executing separately, it also has a STATUS (should be duh) context switching - Answers - run one program for a while, then aanother process descriptor - Answers - something the OS keeps. it has a process's name, owner, children, etc. address space - Answers - remember each process has its own. also, each unit of a resource has a register and mechanisms to manipulate them shared address space - Answers - classic procs share a program, or threads share a proc's address space. three fns to create procs - Answers - fork(label_to_begin_exec_at), quit(), join( count ) unix process - Answers - each proc has its own address space, and a PID (process identifier) seen using ps three fns to destroy procs - Answers - fork(), which creates new address space but copies data/stack and allows child access to files; wait(), which waits for child to terminate; and exec() to run new program idiom to fork() - Answers - int pidValue = fork(); if (pidValue == 0) /* I am the child* childFn(); exit(0); parentAndChildFn(); wait(...); idiom for child to execute diff. program - Answers - int pid; if (pid = fork() == 0)
// I'm the child execve(childProgram.out, argv, 0); printf("Error"); // if you got here, you had an error exit(0); wait(...); idiom for parent to do crap - Answers - if (fork() == 0) // this is child execve("child", NULL, NULL); exit(0); // should never get here // now parent printf("I'm the parent"); if (wait(NULL) > 0) // child terminating. NULL means don't store status info. an exiting child means a positive return printf*(child terminating); unix file - every resource is a file: you OPEN, CLOSE, READ, WRITE, LSEEK, AND IOCTL them open a unix file - Answers - inFile = open(inFileName, O_RDONLY); outFile = open(outFileName, O_WRONLY); while ( (len = read(inFile, &c, 1) ) > 0) write(outFile, &c, 1); close(inFile); close(outFile); os purpose - Answers - 1) abstract resources like memory => address space, and files for secondary storage. 2) manage resource sharing: multiplexing, exclusive use, and sharing os design constraints - Answers - performance, protection, correctness, maintainability, money, standards processor modes - Answers - supervisor or user (some instructions, some memory). trap switches from user to supervisor system call w/ trap - Answers - in the code for fork(), code has "trap N_SYS_FORK()". That sys_fork() is looked up in the trap table, which does some system stuff before returning OS managers - Answers - file, memory, device, process managers ALU usage - Answers - load R3, b; load R3, c; add R3,R4; store R3, a Control unit - Answers - consists of fetch, decode, and execute; PC (program counter) and IR (instruction like "load R4, c") Fetch phase - Answers - retrieve instruction from memory Execute phase - Answers - arithmetic in the ALU, which might reference memory, I/O if needed. Here, keep incrementing PC and getting the next instruction from that address
bsd unix driver fns - Answers - open, close, ioctl, read, write, strategy (block certain i/o ops), select (check for data in bsd), stop idiom for overlapping i/o and cpu - Answers - startRead(); while(stillReading()) y = f(x) driver kernel interface - Answers - drivers are separate from kernel. the kernel makes calls on fns, but the driver implements them. the kernel, in turn, allocates devices and resources and scheduling double buffering - Answers - a buffer in the device controller, and a buffer in the driver disk optimizations - Answers - transfer time, latency (rotate sector), seek (track in a sector). access = all three. optimize using multiprogramming