<< 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

there are 3 trimester in human pregnancy
I don't know answer of this question can u help me
what is a cell
Fatima Reply
what is genetic
Janet Reply
I join
what are the branchas of biology
Prisca Reply
zoology, ecology
genetics, microbiology,botany and embryology
what is a cell
Kulunbawi Reply
cell is smallest unit of life. cells are often cell the building blocks of life...
the first twenty element
Orapinega Reply
what are the characteristics of living things?
growth,respiration,nutrition,sensitivity, movement,irritability, excretion,death.
What is the difference between adaptation and competition in animals
Adeyemi Reply
What is biology
it is a natural science stadey about living things
Biology is the bronch of science which deals with the study of life is called biology
what is the x in 300 stands for?
Ogbudu Reply
the properties of life
Clarinda Reply
response to the environment, reproduction, homeostasis, growth,energy processing etc.....
what is reproduction
Reproduction is a fundamental feature of all known life,each individual organism exist as a result of re production.....or else Multiplying...
a complete virus particle known as
Darlington Reply
These are formed from identical protein subunitscalled capsomeres.
fabace family plant name
Pushpam Reply
in eukaryotes ...protein channel name which transport protein ...
Pushpam Reply
in bacteria ...chromosomal dna duplicate structure called
what is a prokaryotic cell and a eukaryotic cell
Matilda Reply
There are two types of cells. Eukaryotic and Prokaryotic cells. Prokaryotic cells don't have a nucleus or membrane enclosed organelles (little organs within that cell). They do however carry genetic material but it's not maintained in the nucleus. Prokaryotic cells are also one celled.
Prokaryotic cells are one celled (single celled).
Prokaryotic cells are Bacteria and Archea
Prokaryotic cells are smaller than Eukaryotic cells.
Eukaryotic cells are more complex. They are much bigger than Prokaryotic cells.
Eukaryotic cells have a nucleus and membrane bound organelles.
Eukaryotic cells are animals cells which also includes us.
Eukaryotic cells are also multicellular.
nice explaination
eukaryotic cells are individual cells .. but eukaryotes are multicellular organisms which consist of many different types of eukaryotic cells
also eukaryotic cells have mitochondria. prokaryotic cells do not
in prokaryotes only ribosomes are present... in eukaryotes mitochondria ...glogi bodies ..epidermis .....prokaryotes one envelop but eukaryotes compartment envelop....envelop mean membrane bound organelles......
prokaryotic cell are cells dat have no true nuclei i.e no cell membrane while eukaryotic cell are cell dat have true nuclei i.e have cell membrane
we have 46 pair of somatic cell and 23 pair of chromosomes in our body, pls can someone explain it to me. pls
Matilda Reply
we have 22 pairs of somatic chromosomes and one pair of sex chromosome
we have 23 pairs of chromosomes,22 pairs of somatic and one pair of sex chromosomes
23 chromosomes from dad & 23 chromosomes from mom 23 +23=46 total chromosomes
X & Y chromosomes are called sex cells, the very presence of a Y chromosome means the person is Male.
XX Female XY Male
If a Karyotype has more than 46 Chromosomes then nondisjunction occured. For example, having an extra chromosome 21 will cause Down Syndrome.
in mammal state the different vertebrae and their location in the body
Igbinigie Reply
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get the best Algebra and trigonometry course in your pocket!

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?