title: How JVM stack, heap and threads are mapped to physical memory or operation system
body: <p>The compiler book(The dragon book) explains that value types are created on the stack, and reference types are created on the heap. </p>
  
  <p>For Java, JVM also contains heap and stack in runtime data area.  Objects and arrays are created on heap, method frames are pushed to stack. One heap is shared by all threads, while each thread has its own stack. The following diagram shows this: </p>
  
  <p><img src="https://i.stack.imgur.com/cFTf6.jpg" alt="enter image description here"></p>
  
  <p>More about <a href="http://www.programcreek.com/2013/04/jvm-run-time-data-areas/" rel="noreferrer">Java run-time data areas</a>.</p>
  
  <p>What I don't understand is that since JVM is essentially a software, how are those JVM heap, stack and threads mapped to physical machine? </p>
  
  <p>I would appreciate it if someone can compare those concept between Java and C++. Because Java runs on JVM, but C++ does not. </p>
  
  <p>To make this question more precise, I want to know the following: </p>
  
  <ol>
  <li>Comparing with Java, What does C++ run-time data area look like? A picture would be helpful, I can't find a good picture like the JVM one above. </li>
  <li>How the JVM heap, stack, registers and threads are mapped to operating system? or I should ask how they are mapped to physical machine? </li>
  <li>Is it true that each JVM threads is simply a user thread and gets mapped to kernal in some way? (user thread vs kernel thread)</li>
  </ol>
  
  <p><strong>Update</strong>: 
  I draw a picture for runtime physical memory of a process.<br>
  <img src="https://i.stack.imgur.com/xAPl5.jpg" alt="enter image description here"></p>