An image-processing batch contains NNN independent, indivisible tasks. Each task takes exactly 0.80 ms on one worker. The original serial implementation executes tasks consecutively and has no additional costs.
A proposed parallel implementation uses ppp identical workers and has these measured costs:
These phases do not overlap. Assume enough processor cores, unchanged task execution times, and no other costs. Worker counts may exceed the number of tasks, but all ppp workers still incur their starting and shutdown costs.
For a batch of 10 tasks, calculate the elapsed time with four workers in milliseconds, to one decimal place. Also determine the fastest worker count among 2, 4, and 8 workers for that batch. Finally, find the smallest positive integer NNN for which eight workers are strictly faster than the original serial implementation. Enter worker and task counts as exact integers.
Unlock full course notes by signing up
Speedup of a partly parallel analysis program
A single-threaded data-analysis program takes 120 s per run. Of that, 30 s goes to loading input and merging results, which must stay serial, and 90 s goes to a loop whose iterations are independent. You split the loop evenly across 8 threads on a machine with 8 idle cores, and you ignore threading overhead. What speedup over the single-threaded version do you get? Give the answer as a plain number to two decimal places.
Tracing a lost update step by step
A shared integer x starts at 7. Threads A and B each execute x++, which the processor performs as three steps: load x into the thread's register, add 1 to the register, then store the register back to x. The scheduler runs the six steps in the order shown. Fill in each thread's register value and the value of x in memory after each step, as integers.
Balancing unequal tasks across workers
Eight independent tasks, A through H, take 9, 7, 5, 3, 1, 3, 5, and 7 ms respectively on one worker. Four identical workers start simultaneously. Each worker executes its assigned tasks sequentially. Assume enough processor cores for all workers, unchanged task times during parallel execution, and no scheduling or synchronization costs.
Compare these assignments:
Contiguous assignment: worker 1 receives A and B; worker 2 receives C and D; worker 3 receives E and F; worker 4 receives G and H.
Diagnosing a mutex that does not protect
Four threads each call the function below, and main calls pthread_join on all four before printing total. The intended result is 400000, but a test run prints a smaller number. Assume all pthread calls succeed.
Which statement correctly identifies the synchronization error behind the incorrect result?