study 5 - study questions ------------------------------------------------------------------------ 1. what's wrong with this code: if (fork() == 0) { execvp(argv[0], argv); |/ /wait(&s); 2. explain fork, execl, execvp, wait, and exit 3. a program may "commit suicide" or "be murdered", give one concrete example of how this might occur; e.g., we might use the kill(1) command on a process as an example of being murdered (send it a signal by hand). 4. what's wrong with the following i/o code while((read(fd, buf, count) != 0) write(fd2, buf, count); } 5. assume a shell starts 500 processes and each process randomly waits from 1 to 10000 seconds before exiting. Why is the simple wait(&status) system call not up to dealing with this? 6. explain the following kinds of exceptions (what do they mean) hard disk interrupt clock interrupt segmentation violation exception page fault divide by zero software interrupt (a trap) 7. what is meant by context switch? how is virtual memory affected? 8. what is meant by mode switch? give an example of how a program might experience a mode switch? 9. when a process forks, what is shared with the child? (what about open file descriptors?) 10. in class, the instructor explained the difference between processes and threads - explain in terms of the text (machine code) data (initialized or not initialized) stack which are shared in processes and which are shared in threads 11. give a rough explanation of what happens when a hard disk interrupt occurs and a process is actually RUNNING in user space 12 explain what happens when a system call is executed by a program running in user space?