Saturday, August 18, 2012

HOW CAN USER APPLICATION SWITCH TO KERNEL MODE EXPLICITLY?


Yet another question at stack overflow that I answered involved around a query from the user looking for ways to switch from user mode to kernel mode in an application.

Assuming that the user wanted to switch over explicitly during the program code execution, below was my answer for the same. Hope this will be useful for some one else looking answers for similar questions:

The only way an user space application can explicitly initiate a switch to kernel mode during normal operation is by making an system call such as openreadwrite etc.
Whenever a user application calls these system call APIs with appropriate parameters, a software interrupt/exception(SWI) is triggered.
As a result of this SWI, the control of the code execution jumps from the user application to a predefined location in the Interrupt Vector Table [IVT] provided by the OS.
This IVT contains an adress for the SWI exception handler routine, which performs all the necessary steps required to switch the user application to kernel mode and start executing kernel instructions on behalf of user process.
share|edit|delete|flag

No comments:

Post a Comment