views:

206

answers:

3

What are the differences between User Mode and Kernel Mode, and why & how do you activate either (use cases?).

+2  A: 

I'm going to take a stab in the dark and guess you're talking about Windows. In a nutshell, kernel mode has full access to hardware, but user mode doesn't. For instance, many if not most device drivers are written in kernel mode because they need to control finer details of their hardware.

See also this wikibook.

Mark Rushakoff
This is important to you as a programmer because kernel bugs tend to wreak far worse havoc than you may be accustomed to. One reason for the kernel/user distinction is so the kernel can monitor/control critical system resources and protect each user from the others. It's a bit oversimplified, but still helpful, to remind yourself that user bugs are often annoying, but kernel bugs tend to bring the entire machine down.
Adam Liss
+3  A: 
  1. Kernel Mode

    In Kernel mode, the executing code has complete and unrestricted access to the underlying hardware. It can execute any CPU instruction and reference any memory address. Kernel mode is generally reserved for the lowest-level, most trusted functions of the operating system. Crashes in kernel mode are catastrophic; they will halt the entire PC.

  2. User Mode

    In User mode, the executing code has no ability to directly access hardware or reference memory. Code running in user mode must delegate to system APIs to access hardware or memory. Due to the protection afforded by this sort of isolation, crashes in user mode are always recoverable. Most of the code running on your computer will execute in user mode.

Read more

Understanding User and Kernel Mode

rahul
+1  A: 

Other answers already explained the difference between user and kernel mode. If you really want to get into detail you should get a copy of Windows Internals, an excellent book written by Mark Russinovich and David Solomon describing the architecture and inside details of the various Windows operating systems.

0xA3