Midterm #1 Study Question Answers
- Name three ways in which a program executing in user mode can enter kernel mode.
Device interupt, trap instruction, clock tick, illegal memory operation.
- If a process writes continuously to a pipe but no data is read, where does the data reside and what action does the kernel eventually take?
The data resides in a buffer in the kernel's memory space. When the buffer is full, the writing process is blocked on the write operation.
- Why is user level thread creation a more "lightweight" (efficient) operation than forking a child process?
When forking a child process, the code and data segments must be copied into newly allocated memory. When creating a thread, these segements are shared.
- A program is structured using three threads: one reads input from an input file, one processes it and one writes the result to an output file. Is many-to-one or one-to-one a better thread management scheme for this program, and why?
One-to-one is better because it allows one or more of the threads to block on system calls due I/O or other synchronization while the others continue running.For example, if there is no new input, the processing and output processes can continue working on data that was previously input.