memory - Computer Science 322 Operating Systems Mount...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Computer Science 322 Operating Systems Mount Holyoke College Spring 2008 Topic Notes: Memory Management Memory is one of the major shared resources in any modern system. A program needs access to the CPU, and space in memory for its instructions and data in order to run. Think of a simple program that does some operations like this: x = x + 1; // stuff do { // stuff while (i!=0); This becomes assembly code that looks something like this: LOAD X, R0 INC R0 STOR R0, X and loopstart: ... ! assuming i is in R1 TEST R1 BNE loopstart Somewhere in memory, there is program text corresponding to these statements and variables. How does the program know how to find the memory location corresponding to variable x ? How does the BNE instruction know where to jump to? Binding to Memory When does an instruction or a variable get assigned an actual memory address? There are three possible times:
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Operating Systems Spring 2008 1. Programming or Compile time : If we can know the actual memory location a priori , absolute code can be generated. The downside is that we must rewrite or recompile code if its starting location changes. This might be used on small systems. Microprocessors might do this. The old DOS .com format programs used this. Programs for things like the Commodore 64 used this. For example, a BASIC program on the Commodore 64 could include the statements 10 POKE 1320, 1 20 POKE 55592, 6 This puts character ’A’ near the middle of the top of the screen, then changes its color to blue. (See Appendix D) We could also see the current status of joystick 1: 10 JV=PEEK(56320) Bits correspond to the 4 directions and the fire button status. A program could also decide to POKE and PEEK values anywhere into memory. This will not work on a multiprogrammed system, unless each program is compiled to have disjoint memory usage, but the idea lives on in the smaller devices today. 2. Load time : Must generate relocatable code if memory location is not known at compile time. Medium/larger systems may do this. The physical address for a variable or an instruction (branch target) is computed when the program is loaded into memory. Once the program has been loaded into a section of memory, it cannot move. If it is removed from memory, it must be returned to the original location. Multiprogramming is possible, and we will consider the issues this brings up for memory management. 3. Execution time : Binding must be delayed until run time if the process can be moved during its execution from one memory segment to another. Need hardware support for address maps (e.g., base and limit registers ). This is also used for modern medium and large systems. A program’s data and instructions can be moved around in memory at run time. This allows
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/15/2010 for the course CS 322 taught by Professor Teresco during the Spring '08 term at Mt. Holyoke.

Page1 / 25

memory - Computer Science 322 Operating Systems Mount...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online