Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do computers prevent programs from interfering with each other?

For example, I heard in class that global variables are just put in a specific location in memory. What is to prevent two programs from accidentally using the same memory location for different variables?

Also, do both programs use the same stack for their arguments and local variables? If so, what's to prevent the variables from interleaving with each other and messing up the indexing?

Just curious.

like image 869
i love stackoverflow Avatar asked Aug 31 '12 18:08

i love stackoverflow


1 Answers

Most modern processors have a memory management unit (MMU) that provide the OS the ability to create protected separate memory sections for each process including a separate stack for each process. With the help of the MMU the processor can restrict each process to modifying / accessing only memory that has been allocated to it. This prevents one process from writing into a another processes memory space.

Most modern operating systems will use the features of the MMU to provide protection for each process.

Here are some useful links:
Memory Management Unit
Virtual Memory

like image 66
Chimera Avatar answered Oct 14 '22 09:10

Chimera