title: how are global variables stored differently in memory than local variables
body: <p>I'm reading a book on operating systems and it says "we must set things up so that the portion of the added space allocated to global variables tensions allocated for the life time of the program, but that portion allocated for a local variable remains allocated only while the thread is in the variables scope"</p>
  
  <p>What I don't understand is when a program is loaded into memory isn't the addresses reserved for it static? It's not like when a variable goes out of scope the operating system sees the address space where the variable was (is?) at can be used by another program now, or is it?</p>
  
  <p>The book says that global variables are stored in memory and local variables are stored in the run time stack. First of all the run time stack is in memory so I don't see the distinction. How does the operating system know how much space to allocate for the run time stack since the number of items to be pushed on can't be determined before runtime?</p>