<< Chapter < Page Chapter >> Page >
Memory Management

Storage allocation

Information stored in memory is used in many different ways. Some possible classifications are:

  • Role in Programming Language:
    • Instructions (specify the operations to be performed and the operands to use in the operations).
    • Variables (the information that changes as the program runs: locals, owns, globals, parameters, dynamicstorage).
    • Constants (information that is used as operands, but that never changes: pi for example).
  • Changeability:
    • Read- only: (code, constants).
    • Read&write: (variables).

Why is identifying non-changing memory useful or important?

  • Initialized:
    • Code, constants, some variables: yes.
    • Most variables: no.
  • Addresses vs. Data: Why is this distinction useful or important?
  • Binding time:
    • Static: arrangement determined once and for all, before the program starts running. Mayhappen at compile-time, link-time, or load-time.
    • Dynamic: arrangement cannot be determined until runtime, and may change.

Note that the classifications overlap: variables may be static or dynamic, code may be read-only or read&write, etc.

The compiler, linker, operating system, and run-time library all must cooperate to manage this information and perform allocation.

When a process is running, what does its memory look like? It is divided up into areas of stuff that the OS treats similarly, calledsegments. In Unix, each process has three segments:

  • Code (called "text" in Unix terminology)
  • Initialized data
  • Uninitialized data
  • User's dynamically linked libraries (shared objects (.so) or dynamically linked libraries (.dll))
  • Shared libraries (system dynamically linked libraries)
  • Mapped files
  • Stack(s)

In some systems, can have many different kinds of segments.

One of the steps in creating a process is to load its information into main memory, creating the necessary segments. Information comesfrom a file that gives the size and contents of each segment (e.g. a.out in Unix). The file is called an object file. See man 5 a.out for format of Unixobject files.

Division of responsibility between various portions of system:

  • Compiler: generates one object file for each source code file containing information for that file. Information is incomplete, since eachsource file generally uses some things defined in other source files.
  • Linker: combines all of the object files for one program into a single object file, which is complete and self-sufficient.
  • Operating system: loads object files into memory, allows several different processes to share memory at once, provides facilities for processesto get more memory after they have started running.
  • Run-time library: provides dynamic allocation routines, such as calloc and free in C.

Dynamic memory allocation

Why is not static allocation sufficient for everything? Unpredictability: cannot predict ahead of time how much memory, orin what form, will be needed:

  • Recursive procedures. Even regular procedures are hard to predict (data dependencies).
  • OS does not know how many jobs there will be or which programs will be run.
  • Complex data structures, e.g. linker symbol table. If all storage must be reserved in advance (statically), then it will be used inefficiently(enough will be reserved to handle the worst possible case).

Questions & Answers

what is biology
Hajah Reply
the study of living organisms and their interactions with one another and their environments
AI-Robot
what is biology
Victoria Reply
HOW CAN MAN ORGAN FUNCTION
Alfred Reply
the diagram of the digestive system
Assiatu Reply
allimentary cannel
Ogenrwot
How does twins formed
William Reply
They formed in two ways first when one sperm and one egg are splited by mitosis or two sperm and two eggs join together
Oluwatobi
what is genetics
Josephine Reply
Genetics is the study of heredity
Misack
how does twins formed?
Misack
What is manual
Hassan Reply
discuss biological phenomenon and provide pieces of evidence to show that it was responsible for the formation of eukaryotic organelles
Joseph Reply
what is biology
Yousuf Reply
the study of living organisms and their interactions with one another and their environment.
Wine
discuss the biological phenomenon and provide pieces of evidence to show that it was responsible for the formation of eukaryotic organelles in an essay form
Joseph Reply
what is the blood cells
Shaker Reply
list any five characteristics of the blood cells
Shaker
lack electricity and its more savely than electronic microscope because its naturally by using of light
Abdullahi Reply
advantage of electronic microscope is easily and clearly while disadvantage is dangerous because its electronic. advantage of light microscope is savely and naturally by sun while disadvantage is not easily,means its not sharp and not clear
Abdullahi
cell theory state that every organisms composed of one or more cell,cell is the basic unit of life
Abdullahi
is like gone fail us
DENG
cells is the basic structure and functions of all living things
Ramadan
What is classification
ISCONT Reply
is organisms that are similar into groups called tara
Yamosa
in what situation (s) would be the use of a scanning electron microscope be ideal and why?
Kenna Reply
A scanning electron microscope (SEM) is ideal for situations requiring high-resolution imaging of surfaces. It is commonly used in materials science, biology, and geology to examine the topography and composition of samples at a nanoscale level. SEM is particularly useful for studying fine details,
Hilary
cell is the building block of life.
Condoleezza Reply
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Operating systems. OpenStax CNX. Aug 13, 2009 Download for free at http://cnx.org/content/col10785/1.2
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Operating systems' conversation and receive update notifications?

Ask