search
Log In
9 votes
839 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 839 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

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.
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. 

Related questions

5 votes
2 answers
1
605 views
Assume that process A has 3 user level threads and process B has 4 kernel-level threads. Consider while process A is running in CPU, process B is waiting in ready queue. If one of the thread in A is blocked then find status of A threads and B threads? A. All A threads ... . All A threads are blocked and B threads are not blocked. C. All B threads are blocked and A threads are not blocked. D. None.
asked Sep 20, 2016 in Operating System vijaycs 605 views
0 votes
1 answer
2
78 views
Explain how.. Context Switch overhead is less in thread based systems compared to process based systems.
asked Sep 23, 2018 in Operating System Naveen Kumar 3 78 views
0 votes
0 answers
3
351 views
According to me Answer is C, because Multithreading i.e. User application threads cannot use different processors because processor see all the thread of user process as part of one process so it wont execute on Different Processors. Am i right ? But answer given is (A)
asked Jul 12, 2018 in Operating System Na462 351 views
1 vote
4 answers
4
530 views
The primary difference between process and thread ? (A) The number of I/O requests mode. (B) The amount of overhead associated with creation and context switching . (C) The amount of memory allocation (D) The average number of instructions executed
asked Dec 14, 2017 in Operating System ankitgupta.1729 530 views
...