• C

More DOS memory!

Having run out of conventional memory, I'd like to use all of the other megabytes available to the PC.

What I'm looking for is a way of using this extra memory in the most transparent way possible. Idealy by reserving a chunk of memory (any size) and then accessing it using a pointer/s.
(Is this possible?)
e.g.

void main(void)
{
.
.
memory_handle=reserve_memory(2048);// Reserve 2MB's of memory.
.
.
*(memory_handle)=0;
.
.
}


If I can't do it that way, what options are open to me?
LVL 1
Lab_RatAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PinTailCommented:
What Operating System ??

I know you said more DOS memory, but do you really mean DOS ??
0
captainkirkCommented:
If you're using DOS, might consider using a mem extender like PharLap...
0
prabhuramCommented:
you may try using EMM software to
 put ur data into the extended mem. area
or
first try to free as much conventional
mem by loading the drivers,kernel into
the highmemory area
0
Get Certified for a Job in Cybersecurity

Want an exciting career in an emerging field? Earn your MS in Cybersecurity and get certified in ethical hacking or computer forensic investigation. WGU’s MSCSIA degree program was designed to meet the most recent U.S. Department of Homeland Security (DHS) and NSA guidelines.  

PinTailCommented:
based upon your sample code it looks like you are simply trying to allocate some memory at runtime.  Although the description of your problem is somewhat confusing.

do you want to do this

void main(void)
{
..
..
memory_handle = malloc(2048);// Reserve 2MB's of memory.
..
..
free(memory_handle);
..
..
}


0
KangaRooCommented:
1. Use dos extender as suggested
2. Build your own VMM. Something that can 'swap' extended memory and detect that the code is trying to access memory that has to be swapped in.
3. Switch to C++ and use smart classes for pointers, arrays etc..., that do the swapping.
4. Switch to 32 bit OS
0
Lab_RatAuthor Commented:
Thanks for the input everyone!
What I'm trying to do is allocate lots of memory at run time, but without having to swap memory pages in and out.

Option 2 that kangaroo mentioned sounds like it could be the most usefull, if I HAVE to, how do I go about writing one then?

prabhuram, that is what I originally looked at, but the demos I saw seemed to point to the fact that you can only access a limited amount of your allocated memory at once, and if you want to use the whole allocated range, then you have to start swapping memory in and out (this sounds time consuming, especially if you have to swap memory for every program cycle...)

So can I get out of writing a VMM, and get my Christmas wish of being able to access all of my allocated memory at once?

(I'll be back after Christmas, Jan 4th...)
Merry Christmas everyone! :)
0
KangaRooCommented:
VMM 'must' use some processor exceptions, but frankly, I have no details on this, nor even if this is possible on the platform you are using.

Merry Christmas :)
0
jjmcdCommented:
LabRat - what you want is exactly why Windoze (and the hundred DOS extenders that preceeded it) was invented.

Accessing >1Mb of memory from real (i.e. DOS) mode in an 80x86 is a pain.  There are all sorts of ways to do it, none expecially satisfying.  All are either very clumsy or very slow.

The best approach is to use a DOS extender and program in a flat, 32 bit model.  This greatly simplifies a lot of your programming, although it can clumsy up access to the hardware for some things.

In order for your program to run, the target system also needs to have the DOS extender installed.  For this reason, it's probably best to use the most popular DOS extender, Windows.

Although Windows GUI programming is a pain in the neck,  Win32 console programming is just like normal C programming.  You don't need to use any special APIs and memory, by default, is a flat 32-bit space.  You can simply malloc() a 2Mb chunk of memory if you want.

As far as writing your own VMM, this isn't nearly as satisfying as you would like, and keep in mind, IT WILL BE SLOW.  (I suspect you want to stay close to the metal for speed reasons).  Here's the problem, in real (DOS) mode, the 80x86 can only address 1Mb of memory.  If you want to access any memory outside of 1Mb, you need to switch to one of the protected modes to do the memory access.  Just switching modes, setting up the registers, etc, is kind of a pain if you need to access this additional memory very often, but here's were it gets really bad ... the 80x86 is horribly slow at switching back to real mode.  This is somewhat motherbard dependent, but in general, it's real bad, and it's worse the more up to date the motherboard (because this isn't something you ever do these days).

So from a practical perspective, you need to switch to a protected mode, and do a big chunk of work in protected mode, before switching back.  Of course, your garden-variety compiler isn't going to support this.  Assuming you're not going to write a compiler first, you will need to do a big chunk of work in assembler, and oh by the way, the 80x86 instructions behave quite differently depending on processor mode (that's the point, isn't it!)

SO again I suggest, program to Win32 console mode, get the full shot of available memory and avoid the hassles.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Lab_RatAuthor Commented:
Adjusted points to 50
0
Lab_RatAuthor Commented:
Thanks everyone, but especially jjmcd, the quality of your answer far exceeds my offered reward, so I'll up it a bit. :)
0
FHippieCommented:
I know you won't use forth, but here is the easy way out...


80386 UR/FORTH 1.21 (Forth-83 Compatible)
Protected mode 32-bit version of 06/09/96
(C) 1996 Laboratory Microsystems, Inc.
Current path:  c:\whatever

Memory available:  751,423,488 bytes

Ready!
ok

You dont have to install the Pharlap dos extender on the target system.
Works on w2k and XP and dos6.22
Also works on 386, 486, Pentium etc

Has built in assembler and does INT86 calls.
Also has software and hardware FP support.

The turnkeyed application   example:    myapp.exe + myapp.ovl
will contain the Pharlap dos extender...  the 32 bit forth system is based on the Pharlap
dos extender.

GOOD LUCK
.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C

From novice to tech pro — start learning today.