2. Why can't I access all 128MB of physical memory available on my machine?
3. How can I allocate a block of memory in protected mode that doesn't cross a page boundary?
We recommend that you use WATCOM 9.5b or later, together with DOS/4G 1.97 or later, to avoid memory fragmentation problems which plagued some earlier versions.
2. Why can't I access all 128MB of physical memory available on my machine?
DOS/4G is currently limited to 64MB of physical memory. We expect to be updating the DOS extender to use the extended XMS and VCPI calls that allow access to greater than 64MB but currently, you must use virtual memory if you need access to more than 64MB of memory
3. How can I allocate a block of memory in protected mode that doesn't cross a page boundary?
If you want to access full pages on page boundaries, you can try:
bufp = malloc(BLOCKSIZE_I_WANT + PSM1);typedef unsigned long ulong;
int *bufp;
int *blockp:
#define BLOCKSIZE_I_WANT 8092 /* or whatever */
#define PAGESIZE 4096 /* must be power of 2 */
#define PSM1 (PAGESIZE - 1)
blockp = (int *) (((ulong) bufp + PSM1) & ~PSM1);
Then blockp
will point to a page aligned buffer.
When you are through with the block, be sure to free(bufp);
,
rather than blockp
, since bufp
is what
malloc returned.