www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/06/02/19:00:42

From: "John M. Aldrich" <fighteer AT cs DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: I don't want swapping
Date: Tue, 02 Jun 1998 18:56:39 -0400
Organization: Two pounds of chaos and a pinch of salt.
Lines: 37
Message-ID: <35748327.36E0@cs.com>
References: <3 DOT 0 DOT 3 DOT 32 DOT 19980602183929 DOT 006ad4e4 AT ns DOT coba DOT net>
NNTP-Posting-Host: ppp134.cs.net
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Daniel Delorme wrote:
> 
> I've searched the djgpp mailing list archives and found interesting
> stuff on disabling virtual memory and getting memory information from
> the system (_go32_dpmi_get_free_memory_information)
> 
> My problem is: I want a way to know when all the physical memory is
> used up so I can compress the data I'm working on (random map generation)
> and go on processing without having to hear the sweet music of swapping
> 
> In DOS mode (using CSWDPMI), I can use _go32_d[..].available_physical_pages
> The problem is with Win95 (how suprising) : available_physical_pages never
> reaches zero even after the swapping starts.
> 
> If you know an alternative solution to prevent swapping, I'd love to hear
> about it !

You can force all allocated memory to be locked by using the
_crt0_startup_flags variable (look it up in the libc reference). 
Basically, you include the following code in the main module of your
program:

#include <crt0.h>

int _crt0_startup_flags = _CRT0_FLAG_LOCK_MEMORY;

When you do this, all allocated memory will be prevented from paging;
thus, when you run out of unlocked memory, malloc() and company will
fail.

-- 
---------------------------------------------------------------------
| John M. Aldrich, aka Fighteer I |     mailto:fighteer AT cs DOT com      |
| Proud owner of what might one   |   http://www.cs.com/fighteer/   |
| day be a spectacular MUD...     |       ICQ UIN#:  7406319        |
| Plan: To make Bill Gates suffer |     HEAT User ID:  Fighteer     |
---------------------------------------------------------------------

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019