What are the Privileged and Non-Privileged instructions in Operating System?


Let us understand the privileged instructions in an operating system.

Privileged instructions

These are called machine level instructions that are executed when the processor is in privileged mode.

The examples include the following −

  • Shut down the system

  • Change the contents of a control register.

  • Jump into kernel code.

  • Sending commands to I/O devices.

The processor is said to be in privileged mode when the functions in the OS kernel are executing.

Suppose an attempt is made to execute a privileged instruction in non-privileged mode which causes a run-time error.

Generally the user mode of the operating system is called non-privileged mode and kernel mode of the operating system is called privileged mode.

Characteristics

The characteristics of privileges instructions are as follows −

  • The attempt that is made to execute a privileged instruction in user mode, that is treated as an illegal instruction and it will not execute.

  • When the control is transferring to any User Program, it is the responsibility of the Operating System to make sure that the Timer is set to interrupt.

  • Therefore, if the timer interrupts then the Operating System will gain the control. And any instruction that is going to modify the contents of the Timer is Privileged Instruction.

  • The privileged instructions are mainly used by the Operating System to achieve correct operation.

Non-Privileged Instructions

Non-Privileged mode is also called User mode or it is called as safe instructions.

The examples include the following −

  • Load and store instructions

  • Add, Subtract etc.

The figure given below indicates the non-privileged and privileged mode in an operating system −

User mode
(or)
Non-Privileged Mode
Kernel mode
(or)
Privileged Mode

There must be a mechanism to switch modes and this is as follows −

  • user → kernel (built into hardware)

  • kernel → user (privileged instruction)

Updated on: 01-Dec-2021

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements