1,906 views
3 votes
3 votes

The hardware allows privileged instruction to be executed only in kernel mode. if an attempt to execute a privileged instruction in user mode, the hardware does not execute the instruction but rather treat it as illegal and traps it to the operating system.

The instruction to switch to kernel mode is an example of privileged instruction.

above are the exact lines from the book.

my question is... privileged instruction should be executed in kernel mode, and switching to kernel mode is itself a privileged instruction. how can it be then executed if the system is not in kernel mode?

please clarify...

 

1 Answer

3 votes
3 votes
Basically, Instructions that change user mode to kernel mode are system calls. A system call internally generates a software interrupt. As soon as the interrupt is generated, mode bit is changed from user mode(1) to kernel mode(0), pointer is set to the beginning of interrupt service routine and the system enters to kernel mode. After the execution of ISR mode is again changed to user.

Related questions

0 votes
0 votes
0 answers
2
akash.dinkar12 asked Mar 19, 2019
223 views
When a process creates a new process using the fork() operation, which of the following states is shared between the parent process and the child process ?a. Stackb. Heap...