In what order does the context transition to the kernel

Of these three steps, is this the correct order or do I need to switch any?

1) Save current status data

2) Enable kernel mode

3) Determine the reason for the interruption

+3


source to share


2 answers


So let me try to help you figure it out in the correct order.



  • Only the kernel can switch the context, since only the kernel has access to the data it needs and can, for example, modify the page tables for the address space of another process.
  • To determine whether a context switch needs to be executed or not, the kernel must analyze some "inputs". The context switch can be executed, for example, because the timer interrupt is started and the time slice of the process has completed, or because the process has started to perform some I / O.
  • Only the kernel can save the state of the user process, because the user process will change its state when it tries to save it. The kernel, however, knows that when it starts, the user process is currently being interrupted (for example, due to an interruption, or because a user-space process voluntarily entered the kernel, for example, for a system call)
0


source


  • The current process context is first saved partially by the hardware (processor) and rested by the software (kernel).
  • Control is then transferred from the user process to the kernel, loading a new eip, esp, and other saved kernel context, loaded by hardware from the task state segment (TSS).
  • Then there is no interrupt or trap based. the request is sent to the appropriate handler.


0


source







All Articles