Data space notion in Forth Standard #124
ruv
started this conversation in
Show and tell
Replies: 1 comment 5 replies
-
An issue I face (with C-based OS hosted implementation) is the question of whether |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First of all, by memory region we mean a set of contiguous address units (an interval in the memory address space).
Sometimes people could think that data space is a single memory region. But it's wrong.
In the standard this term is defined in the following way:
Actually, data space is a set of all those and only those address units which are accessible by a program. If a program may read or write an address unit, then this unit is a part of data space. If an address unit is not a part of data space, then a program is not allowed to read or write this unit ("A program shall not fetch from or store into locations outside data space" in 3.3).
So, data space is only one. Conceptually, there can be another data space (probably with another name), in a different address space (for example, the space of i/o ports). But there is no other data space that can be accessed by a standard program (3.3.3 "Data space is the only logical area of the dictionary for which standard words are provided to allocate and access regions of memory").
It is not required that all units of data space are contiguous. For example, in the section 3.3.3.2 the standard explicitly says: “the above operators need not produce contiguous regions of data space if definitions are added to or removed from the dictionary between allocations”.
Data space is not a constant set. For example, when a region is allocated (by means of
allocate
), new address units become members of this set. When a region is freed (by means offree
), the corresponding address units are not members of this set anymore.In contrast to allocations, a region reservation or releasing (by means of
allot
) usually does not change the set of address units available for a program. And the region returned by the phrasehere unused ( -- addr u )
is a part of data space as long as contiguity of subsequent reservations is guaranteed (see 3.3.3.2).Code space is not accessible by a program, so it cannot formally be a part of data space at all. An implementation may allocate or reserve data space regions for use by code (or by headers), but there is no way for a standard program to access these regions. So they don't belong to data space (that is, they are excluded from data space when the system reserves them for code or other internal purposes).
Beta Was this translation helpful? Give feedback.
All reactions