1

What is the exact definition of a memory address space?

Is it correct to name the set of all the numbers from 0 to the highest addressable byte the definition of an address space?

EDIT: I would like to know if there is a formal definition of an address space the same way as there is a mathematical formal definition for a Finite State Automata.

yoyo_fun
  • 2,267
  • 3
  • 17
  • 22
  • Possible duplicate of [What are memory addresses?](https://softwareengineering.stackexchange.com/questions/255379/what-are-memory-addresses) – gnat Oct 02 '17 at 12:23
  • Not necessarily contiguous. *By convention* labelled with numbers, but they could be labelled in any manner – Caleth Oct 02 '17 at 12:39
  • 3
    It's fine and good to be speculating, however as a programmer, you should never ever attempt to guess how the operating system handles memory for any reasons other than the two following exceptions: 1) you're writing drivers for your hardware containing onboard memory directly under your control, 2) your program *IS* the operating system. – Neil Oct 02 '17 at 14:34
  • The subset of memory addresses which you can write arbitrary data to and read from, and neither writing nor reading would cause any unforeseeable side effect other than due to code that is written by you. Basically, this is what we mean when we say "this is the part of memory you have allocated; and this is what you are *allowed to* write to or read from". Although you can write code that will write to or read from addresses which you haven't been given permission to, the possible consequences are truly "unbounded" (unspecified), including e.g. resurrection of dinosaurs. – rwong Oct 03 '17 at 05:54
  • There is something wrong from me, you want either the definition of *memory address*, *memory space*, or *size of addressable memory* or *size of one addressed block of memory*. Moreover, there is a difference between the usage of the memory : it can basically either be instruction to execute, or data. The pointer to the current instruction to execution is called the instruction pointer. You have to know when you pick an address if you're looking for data or instructions. – Walfrat Oct 03 '17 at 11:25

1 Answers1

4

Sure, and it is pretty simple. A linear memory adress space can be mathematically modeled as an n-dimensional vector from the set Mn, where M represents the finite set of numbers which fit into one memory cell (for example, M={0,...,255} when the memory is addressed in portions of one byte), and n is the maximum number of addresses.

The "address of a memory cell" then is nothing but an index into the vector, from 0 to n-1, where the related coordinate represents the content of the memory cell.

Doc Brown
  • 199,015
  • 33
  • 367
  • 565
  • 2
    I think your answer goes beyond memory address space, it's a modelling for the memory (including the contents). I'd see an address space as the set of addresses that belong to this space, e.g. {0, 1, 2, ... N-1} for a contiguous address space of N addresses (not necessarily bytes) starting from zero. – Ralf Kleberhoff Oct 02 '17 at 12:52
  • 3
    @RalfKleberhoff: without modeling the memory itself this becomes pretty meaningless. – Doc Brown Oct 02 '17 at 13:07
  • @DocBrown What you modeled there is the set of all possible combinations of bits inside the whole memory? Am I right? – yoyo_fun Oct 02 '17 at 13:44
  • @JenniferAnderson I think 'yes' - Doc Brown took your word **space** to mean what you can *put in the space* as well as how to address it. It is like if you asked what is a 'neighborhood' and someone said, "all the houses and their addresses." –  Oct 02 '17 at 16:36
  • 1
    @RalfKleberhoff I guess in order to model a memory address space you need to model both the memory and the addresses. If you only model the addresses then it is just an address space. – Stop harming Monica Oct 02 '17 at 18:21
  • @JenniferAnderson Not the whole memory but the addressable memory, – Stop harming Monica Oct 02 '17 at 18:24
  • 1
    I'd also add that your definition implies that there is only one possible address space. There are systems which have segmented memory so that you would have N such vectors to truly describe their address spaces. – Peter M Oct 02 '17 at 22:15
  • 1
    @PeterM: my answer does in no way imply "there is only one possible address space", or that this is the one and only mathematical model for an adress space. It is one possible model, and as I wrote, a linear memory adress space *can* be modeled that way, and not "must be modeled". – Doc Brown Oct 02 '17 at 22:34
  • I think the actual limit on `n` should be emphasised as that's the thing that differentiate real computers from turing machine, i.e. `n = 2^64 - 1`. Also, IIRC, `n = 0` is not really addressable – imel96 Oct 03 '17 at 06:28
  • @imel96: it is a mathematical model - the fact n is a natural number already expresses the number of addresses is finite, and a finite set cannot be "more finite" than another. – Doc Brown Oct 03 '17 at 08:38