Question: When multiple tasks are executed on a single - threaded CPU, the tasks are scheduled based on the principle of pre - emption. When a
When multiple tasks are executed on a singlethreaded CPU, the tasks are scheduled based on the principle of pre emption. When a higherpriority task arrives in the execution queue, then the lowerpriority task is preempted, ie its execution is paused until the higherpriority task is complete.
There are in functions to be executed on a singlethreaded CPU, with each function having a unique ID between and n Given an integer n representing the number of functions to be executed, and an execution log as an array of strings, logs of size m determine the exclusive times of each of the functions. Exclusive time is the sum of execution times for all calls to a function. Any string representing an execution log is of the form functionid:startend: timestamp indicating that the function with ID functionid either starts or ends at a time identified by the timestamp value.
Note: While calculating the execution time of a function call, both the starting and ending times of the function call have to be included. The log of the form functionid:start: timestamp means that the running function is preempted at the beginning of timestamp second. The log of the form functionid:end: timestamp means that the function functionid is preempted after completing its execution at timestamp second ie after timestamp second.
Example
Suppose n logs :start::start::end::start::end::end:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
