Concurrency and parallelism

R-CONC-V4-3hard

Keep both slots busy

A report builder downloads several files. Downloads are authored wait jobs implemented with real timer/thread sleeps, not network requests. Pending waits can overlap while setup/completion still use CPU. The historical runner has a one-CPU-time quota, not a guarantee that only one thread can execute at every instant. Stdin lists job <id> <ms> lines, a deadline <ms> line and, where there is one, a limit <n> line. The report prints the results in job order, whether the whole run met the deadline, and the most downloads inside runJob at once. Inputs are complete well-formed positive-wait jobs with unique token ids, 1–32 jobs of 50–1000 integer milliseconds, limit 1–8 where present and a positive deadline chosen to admit the target schedule as in the fixtures. For these nonempty profiles the target peak is min(limit, job count), matching the printed check; lower peak is not this target even if a loose deadline could be met. OS launch/timer jitter can affect native timings/peak; no new native timing pass is claimed. Invalid/missing commands, zero/negative durations/limits, failures/cancellation and actual connection or rate-limit enforcement are outside the supplied model. The editable counters are not adversarial enforcement.

What needs to change

Downloads now take different times. Keep at most limit in flight and still meet the deadline.

Reproduce

  1. Compile and run main.cpp with the sample stdin: one 600 ms and six 100 ms downloads, limit 2. Compare within deadline.

Acceptance criteria

Your review marks · Saved in this browser. Test acceptance is tracked separately.

Notes

Review run_all. It respects limit and keeps results in order.

The deadline is 750 ms.

run_job is supplied.

Sign in to open this exercise

The ticket brief is public. Sign in to access the exercise. Paid exercises require Pro.

Sign in