Rahul Bhattacharya wrote (Thu, Mar 13, 2025 at 01:08:26AM +0530):
> One question in the sequel: When a process is just finished(terminated) and
> context switch yet to happen and others are yet to finish, what would be
> status of the register “R”?
Call the just-terminated process P.
R will hold whatever value was last written into it by P. If R is a commonly used register (like ebx, ecx), then that last value was probably written by the kernel while running the code for the exit system call on behalf of P. Since x86 has only 6 general purpose registers, this scenario is the most likely.
In principle, however, it is possible that P wrote some value into R when doing some computation in user mode, and the kernel did not need to use that register during exit. In this case, the last value stored in R by P (when in user mode) will still be stored in R.
Please let me know if this answers your question.
-mandar