Sample Midterm Flashcards
Turned sample midterm into flashcards
How is a new process created? Select all that apply.
- Via fork
- Via exec
- Via exec followed by fork
- Via exec or fork followed by exec
- Via fork or fork followed by exec
- None of the above
- All of the above
Via fork - if we want to create a process that is an exact replica of the calling process
Via fork followed by exec - If we want to create a process that is not an exact replica of the calling process
Via fork or fork followed by exec
******************************************************************
Relevant Sections
P2L1: Processes and Process Management
Process Life Cycle: Creation
Is there a benefit of multithreading on 1 CPU?
- Yes
- No
Give 1 reason to support your answer.
Yes. The main reason is to hide the latency associated with code that blocks processing (such as a disk I/O request).
****************************************************
Relevant Sections
P2L2: Threads and Concurrency
Benefits of Multithreading: Single CPU
An image web server has three stages with average execution times as follows:
- Stage 1: read and parse request (10ms)
- Stage 2: read and process image (30ms)
- Stage 3: send image (20ms)
Implement multithreaded pipeline model, answer the following questions:
- How many threads will you allocate to each pipeline stage?
- What is the expected execution time for 100 requests (in sec)?
- What is the average throughput of this system (in req/sec)? Assume there are infinite processing resources (CPU’s, memory, etc.).
Use threads to overcome the weakest link.
In this case 30ms and 20ms can be overcome by 3 threads and 2 threads respectively.
So first request is processed in 60ms
Next 99 processed in 10s each -as fast as the fastest link.
- 1, 3, 2
- So: 60 + 99*10 = 990 + 60 = 1050 –> 1.05 seconds
- 100/1.05 = 95.2 requests/sec