The Gateway to Computer Science Excellence
+9 votes
633 views

can anyone tell what are different activities that are performed in 

  • kernel mode
  • user mode
  • how to change frm user mode to kernel mode and vice-versa,,
in Operating System by Boss (12.2k points) | 633 views

3 Answers

+7 votes

Can anyone tell what are different activities that are performed in 

  • kernel mode
  • user mode
  • Kernel mode, also known as system mode, is one of the two distinct modes of operation of the CPU in Linux. The other one is user mode, a non-privileged mode for user programs, that is, for everything other than the kernel.
  • When the CPU is in kernel mode, it is assumed to be executing trusted software, and thus it can execute any instructions and reference any memory addresses (i.e., locations in memory).
  • The kernel (which is the core of the operating system and has complete control over everything that occurs in the system) is a trusted software, but all other programs are considered untrusted software.
  • Thus, all user mode software must request use of the kernel by means of a system call in order to perform privileged instructions, such as process creation or input/output operations. 
  • A system call is a request to the kernel in a Unix-like operating system by an active process for a service performed by the kernel. 
  • All processes begin execution in user mode, and they switch to kernel mode only when obtaining a service provided by the kernel. This change in mode is termed a mode switch .

Reference :

http://www.linfo.org/kernel_mode.html

by Veteran (72.5k points)
+1

how to change frm user mode to kernel mode and vice-versa

  1. From kernel to user mode, a non privileged instruction is required. 
  2. From user to kernel mode., a software interrupt is required.
0

 @Bikram Sir, 

A system call is a request to the kernel in a Unix-like operating system

 So, can we consider System call as Privileged instruction, since we are moving from user mode to Kernel mode.

0

In the ref document.

All processes begin execution in user mode, and they switch to kernel mode only when obtaining a service provided by the kernel.

Does it mean when user program needs to use IO devices then it require to switch the mode from user mode to kernel mode, and perform the required task.

Example, printf() function call needs Display device like monitor to show the output, therefore, it switch its mode to kernel mode and when the task happened, mode changes to user mode again. and whenever it needs IO in future again do the same process.

right??

+2

can we consider System call as Privileged instruction

Yes, System call is a kind of instruction or trap , which we can all as privileged instructions.

By using system call we go from user mode to kernel mode .

To know more, you can read  point 4 here :

We need a mechanism whereby:

  • a user-mode program can switch into kernel mode,

This mechanism is the system call, which is implemented in the CPU as the trap instruction.

http://minnie.tuhs.org/CompArch/Lectures/week05.html

+1

Does it mean when user program needs to use IO devices then it require to switch the mode from user mode to kernel mode, and perform the required task.

Yes , it is right ..when user program needs to use kernel it switch it's mode .. after performing required operation it again come back .

+1
Bikram sir.. A small confusion..

Quoting from Galvin "the h/w allow privileged insn to be executed in kernel mode, if any attempt is made to execute a privileged insn in user mode the h/w doesn't execute insn but rather treat it illegal nd trap it to OS ''

As you told system call comes under privileged insn then how it is treated in user mode to get kernel mode?
+1

system call comes under privileged insn then how it is treated in user mode to get kernel mode?

When you call system call then h/w need to change the mode user to kernel .(i.e. mode change done in privileged mode)

system call made from user mode.like printf(); make system call made by the user program in user mode.

0
It means the system calls are privileged insn and can be executed in user mode to get kernel mode.. Isn't?
0

@Anu007 Since mode Switch is a privileged inst, Thus user to kernel and kernel to user is a privileged instr.

ryt?

+2 votes
Privileged mode==kernel mode
Non privileged mode==user mode
 From kernel to user mode, a non privileged instruction is required.
From user to kernel mode., a software interrupt is required.
by Veteran (72.5k points)
0
From user to kernel mode we require Privileged Instruction.

Right?
0
Yes , right .

In terms of trap or system calls we go from user to kernel mode .

This trap or system call is known as Privileged Instruction .
0

@Shubhanshu privileged instructions are only those we can execute ONLY in the kernel mode so we dont require priviliged instruction to get into kernel mode .. system calls are implemented by the software interrupts and even printf() also leads to a system call this, in turn, calls the WRITE() system call in the library whcih ocurs at the user mode but this call makes a MODE SWITCH to kernel mode 

+1 vote

Kernal mode deals with system calls.

User mode deals with execution of user defined processes.

A privileged instruction sets the mode. 

by Active (1.5k points)

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,645 questions
56,601 answers
195,855 comments
102,228 users