Splitting a long handler to bound click latency

A spreadsheet app runs on a single-threaded event loop with one FIFO queue; a running handler is never interrupted. At t=0t = 0 ms, with the queue otherwise empty, an import event starts a job that processes 12,000 rows at 0.05 ms per row. At t=130t = 130 ms the user clicks a button whose handler takes 8 ms. Posting an event takes negligible time.

  • Version A processes all 12,000 rows in a single handler call.
  • Version B processes 1,000 rows per handler call, then, as its last action, posts a continue event to the back of the queue; the continue handler does the next 1,000 rows the same way until all rows are done.

Find the number of handler calls Version B needs for the job, the click's waiting time (from arrival until its handler starts) in Version A and in Version B, and the time at which Version B finishes the last row. Give every time in milliseconds as a whole number.

Your answers

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Event-Driven Programming Questions: