*****************************************************
* Description: Knowledge of CPU kernel and user mode
* Compatiablity: RDBMS 11g, 12c
* Date: 03:52 PM EST, 04/28/2017
*****************************************************



<1> General:
     |
     |__ CPU can only execute one process at one time. Even now, one CPU can contain 4 cores, 8 cores, or even 32 cores. Still, that is not enough to assign each tasks with one core.
     |   So, that is the reason why CPU should be a gloable resource shared by multuple tasks launched by operating system. But, how to allocate the CPU to process?
     | 
     |   Priority dispatch algorithm will cut CPU time into Time Slot, and each task can only use CPU in certain mount of time slot. When the time slot is done, it will trigger an 
     |   "Interrupt", so OS will notice the running process to release the CPU, and transfer the CPU resource to other process. 
     |   The algorithm is vary across different operating system.		 
     |   
     |__ CPU usage is generally represented as a simple percentage of CPU time spent on non-idle tasks. But this is a bit of a simplification. 
         In any modern operating system, the CPU is actually spending time in two very distinct modes:
       
         [a] Kernal Mode:
             |
             |__ In this mode, OS has the absolute control of all basic hardware, and can command the hardware to execute all the commands. In contrast, OS inuser mode does not have 
                 the privilege to access hardware.
				 
                 >> So, any software based on OS, must use "System API" to access hardware, such as Python readfile() function to read/write file.
                 >> If the software wants to access hardware or call kernel function, the "Trap transaction" function can let the running mode got switched from User mode 
                    to Kernal 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. 
		 
         [b] 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.
			

			
<2> Windows Task Manager to display CPU kernel mode:
     |
     |__ Task Manager ==> View ==> Show Kernal Time ==> Display by red line, the gap between Green and Red lines are in user mode.
      			 
	
	
<3> Reference:
     |
     |__ https://blog.codinghorror.com/understanding-user-and-kernel-mode/
         http://blog.csdn.net/cww97/article/details/52752967
         http://www.cnblogs.com/ck1020/p/6024330.html
         http://minnie.tuhs.org/CompArch/Lectures/week05.html		 
         http://blog.csdn.net/liutianshx2012/article/details/47615603