address spaces (week 2) Flashcards
multiprogramming
OS would switch between processes when one decided to do an I/O
this increased CPU utilization and was more efficient
time sharing
leave processes in memory while switching between them, allowing the OS to implement time sharing efficiently
what is a key problem that arises with time sharing?
protection: allowing multiple programs to reside concurrently in memory makes protection an important issue (came about because of time sharing); you don’t want a process to be able to read, or worse, write some other process’s memory
address space of a process
contains all of the memory state of the running program: the code (instructions) has to live in memory somewhere, and thus they are in the address space / also the stack and heap
CODE - STACK - HEAP
Describe this abstraction of address space
- program code: where instructions live; easy to allocate since it is static and we know it won’t grow
- heap: contains the dynamically allocated data structures, grows positively (addresses get larger)
- stack is at the bottom: grows negative (addresses get smaller), contains local variables, arguments to routines, return values, etc.
heap and stack grow towards each other
what do we mean when we say that the OS is virtualizing memory?
(how can the OS build this abstraction of a private, potentially large address space for multiple running processes (all sharing memory) on top of a single, physical memory?
the running program thinks it is loaded into memory at a particular address (say 0) and has a potentially large address space (say 32-bits or 64 bits); the reality is quite different
when a process tries to perform a load at address 0 (which we will call a virtual address) somehow the OS, in tandem with some hardware support, will have to make sure the load doesn’t actually go to physical address 0 but rather to physical address 320 KB (where A is loaded into memory).
What are the goals of virtual memory?
- transparency: the OS should implement virtual memory in a way that is invisible to the running program; the program shouldn’t be aware of the fact that memory is virtualized; the program behaves as if it has its own private physical memory; it is the OS (and hardware) that does all the work to multiplex memory among many different jobs, and hence implements the illusion
- efficiency: time and space, for this, the OS has to rely on hardware support, including hardware features such as TLBs (595!)
- protection: the OS should protect processes from one another as well as the OS itself from processes; for e.g., when one process performs a load, a store, or an instruction fetch, it should not be able to access or affect in any way the memory contents of any other process or the OS itself (that is, anything OUTSIDE of the address space)
- -> protections enables us to deliver the property of isolation
summary of virtual memory (a major OS subsystem)
The VM system is responsible for providing the illusion of a large, sparse, private address space to programs, which hold all of their instructions and data therein. The OS, with some serious hardware help, will take each of these virtual memory references, and turn them into physical addresses, which can be presented to the physical memory in order to fetch the desired information. The OS will do this for many processes at once, making sure to protect programs from one another, as well as protect the OS. The entire approach requires a great deal of mechanism (lots of low-level machinery) as well as some critical policies to work;