Sample Midterm Flashcards

Turned sample midterm into flashcards

1
Q

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
A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Is there a benefit of multithreading on 1 CPU?

  • Yes
  • No

Give 1 reason to support your answer.

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

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:

  1. How many threads will you allocate to each pipeline stage?
  2. What is the expected execution time for 100 requests (in sec)?
  3. What is the average throughput of this system (in req/sec)? Assume there are infinite processing resources (CPU’s, memory, etc.).
A

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. 1, 3, 2
  2. So: 60 + 99*10 = 990 + 60 = 1050 –> 1.05 seconds
  3. 100/1.05 = 95.2 requests/sec
How well did you know this?
1
Not at all
2
3
4
5
Perfectly