title: Kernel Code vs User Code
body: <p>Here's a passage from the book</p>
  
  <blockquote>
    <p>When executing kernel code, the system is in kernel-space execut-
    ing in kernel mode.When running a regular process, the system is in user-space executing
    in user mode.</p>
  </blockquote>
  
  <p>Now what really is a kernel code and user code. Can someone explain with example?</p>
  
  <p>Say i have an application that does <code>printf("HelloWorld")</code> now , while executing this application, will it be a user code, or kernel code. </p>
  
  <p>I guess that at some point of time, user-code will switch into the kernel mode and kernel code will take over, but I guess that's not always the case since I came across this</p>
  
  <blockquote>
    <p>For example, the open() library function does little except call the open() system call.
    Still other C library functions, such as strcpy(), should (one hopes) make no direct use
    of the kernel at all.</p>
  </blockquote>
  
  <p>If it does not make use of the kernel, then how does it make everything work?</p>
  
  <p>Can someone please explain the whole thing in a lucid way.  </p>