memory - Computer Science 322 Operating Systems Mount...

Info icon This 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:
Image of page 1

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

View Full Document Right Arrow Icon
CS 322 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 dynamic loading and/or dynamic linking . Here, a segment of program code is not brought into memory until it is needed.
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern