<< 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
ROHIN Reply
I don't know answer of this question can u help me
ROHIN
yes
Bisa
what is a cell
Fatima Reply
what is genetic
Janet Reply
I join
Janet
what are the branchas of biology
Prisca Reply
zoology, ecology
Millicent
biochemistry,cytology,herpetology...etc
R0se
genetics, microbiology,botany and embryology
Muhammad
what is a cell
Kulunbawi Reply
cell is smallest unit of life. cells are often cell the building blocks of life...
Muhammad
the first twenty element
Orapinega Reply
what are the characteristics of living things?
R0se
growth,respiration,nutrition,sensitivity, movement,irritability, excretion,death.
Obinna
What is the difference between adaptation and competition in animals
Adeyemi Reply
What is biology
Adeyemi
it is a natural science stadey about living things
Zamiil
Biology is the bronch of science which deals with the study of life is called biology
Aziz
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.....
Pushpam
hello.
Daniela
hi
MacPeter
Good
Thomas
what is reproduction
Tims
Reproduction is a fundamental feature of all known life,each individual organism exist as a result of re production.....or else Multiplying...
R0se
a complete virus particle known as
Darlington Reply
These are formed from identical protein subunitscalled capsomeres.
Pushpam
fabace family plant name
Pushpam Reply
in eukaryotes ...protein channel name which transport protein ...
Pushpam Reply
in bacteria ...chromosomal dna duplicate structure called
Pushpam
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.
juanita
Prokaryotic cells are one celled (single celled).
juanita
Prokaryotic cells are Bacteria and Archea
juanita
Prokaryotic cells are smaller than Eukaryotic cells.
juanita
Eukaryotic cells are more complex. They are much bigger than Prokaryotic cells.
juanita
Eukaryotic cells have a nucleus and membrane bound organelles.
juanita
Eukaryotic cells are animals cells which also includes us.
juanita
Eukaryotic cells are also multicellular.
juanita
nice explaination
Amna
eukaryotic cells are individual cells .. but eukaryotes are multicellular organisms which consist of many different types of eukaryotic cells
Will
also eukaryotic cells have mitochondria. prokaryotic cells do not
Will
Good
John
in prokaryotes only ribosomes are present... in eukaryotes mitochondria ...glogi bodies ..epidermis .....prokaryotes one envelop but eukaryotes compartment envelop....envelop mean membrane bound organelles......
Pushpam
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
Divine
grt
Thomas
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
Amna
thanks
Matilda
we have 23 pairs of chromosomes,22 pairs of somatic and one pair of sex chromosomes
Amna
23 chromosomes from dad & 23 chromosomes from mom 23 +23=46 total chromosomes
juanita
X & Y chromosomes are called sex cells, the very presence of a Y chromosome means the person is Male.
juanita
XX Female XY Male
juanita
If a Karyotype has more than 46 Chromosomes then nondisjunction occured. For example, having an extra chromosome 21 will cause Down Syndrome.
juanita
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?

Ask