1,267 views
0 votes
0 votes
Consider a system in which threads are implemented entirely in user space, with the run-time system getting a clock interrupt once a second. Suppose that a clock interrupt occurs while some thread is executing in the run-time system. What problem might occur? Can you suggest a way to solve it?

1 Answer

0 votes
0 votes

Answer:

When the runtime system is at the point of unblocking or blocking a thread, and busy in changing the scheduling queues, then it would be the most inappropriate time for the clock interrupt handler to start checking those queues for thread switching, since at this stage threads may be in a highly inconsistent state.

One of the solutions can be to set a flag when runtime of the system is entered, so that the clock handler can see this and can set its own flag, then return to its original position.  After the runtime system has finished its working, it will inspect the clock flag and will see that a clock interrupt has happened, and then run the clock handler.

Related questions

0 votes
0 votes
1 answer
2
0 votes
0 votes
1 answer
3
admin asked Oct 24, 2019
1,651 views
Why would a thread ever voluntarily give up the CPU by calling thread yield? After all, since there is no periodic clock interrupt, it may never get the CPU back.
0 votes
0 votes
1 answer
4