THINK FIRST·CODE LATER

← All labs

How many programs keep the CPU busy? (multiprogramming model)

Problem

Use the multiprogramming model utilization = 1 − pⁿ to size an EdgeCampus server.

Input: lines p target maxN until the end of input, where p is the I/O-wait fraction (0 ≤ p < 1), target is the desired utilization in percent, and maxN the largest number of processes to consider.

For each line print a table of n = 1…maxN, then the answer:

p=0.80 target=90.0%
n=1 util=20.00%
n=2 util=36.00%
...
Minimum n: 11

(Print p with two decimals and target with one decimal; utilization with two decimals.) The minimum n is the smallest n with utilization ≥ target; if none of 1…maxN reaches it, print Minimum n: not reached within maxN. Print an empty line between two inputs.

Input:

0.5 90 5

Output:

p=0.50 target=90.0%
n=1 util=50.00%
n=2 util=75.00%
n=3 util=87.50%
n=4 util=93.75%
n=5 util=96.88%
Minimum n: 4

Write it here or in your IDE, then paste it. Compile and test it yourself before comparing. Your code stays in your browser — it is never sent to or stored on the server.