Ignore:
Timestamp:
Sep 25, 2000, 6:35:01 AM (25 years ago)
Author:
phaller
Message:

GlobalMemoryStatus implemented without Open32

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/KERNEL32.CPP

    r4174 r4319  
    1 /* $Id: KERNEL32.CPP,v 1.52 2000-09-03 18:04:55 phaller Exp $ */
     1/* $Id: KERNEL32.CPP,v 1.53 2000-09-25 04:35:01 phaller Exp $ */
    22
    33/*
     
    3636#include "handlemanager.h"
    3737#include "wprocess.h"
     38#include "oslibdos.h"
    3839#include <versionos2.h>
    3940
     
    184185//******************************************************************************
    185186//******************************************************************************
    186 VOID WIN32API GlobalMemoryStatus( MEMORYSTATUS *arg1)
     187
     188/*
     189 * PH 2000/09/25 This is an experiment to overcome some problems
     190 * with Open32's GMS variant.
     191 */
     192void _GlobalMemoryStatus(MEMORYSTATUS *lpMemStat)
     193{
     194  ULONG  sys[5];
     195  // Note: QSV_TOTPHYSMEM = 17, QSV_MAXSHMEM = 21
     196  lpMemStat->dwLength = sizeof(MEMORYSTATUS);
     197 
     198  if(!OSLibDosQuerySysInfo( 17, 21, (PVOID)sys, sizeof(sys)))
     199  {
     200    // Specified a number between 0 and 100 that gives a general idea of
     201    // current memory utilization, in which 0 indicates no memory use and
     202    // 100 indicates full memory use
     203
     204    //#define MB512 0x1c000000
     205    //lpMemStat->dwMemoryLoad = (MB512-sys[20]) * 100 / MB512;
     206    lpMemStat->dwMemoryLoad = (sys[1] * 100) / sys[0];
     207   
     208    // bytes of physical memory
     209    lpMemStat->dwTotalPhys = sys[0];
     210     
     211    // free physical memory bytes
     212    lpMemStat->dwAvailPhys = sys[0] - sys[1];
     213
     214    // bytes of paging file
     215    lpMemStat->dwTotalPageFile = sys[2] - sys[0];
     216
     217    // free bytes of paging file
     218    // @@@PH subtract swapper.dat size?
     219    lpMemStat->dwAvailPageFile = lpMemStat->dwTotalPageFile;
     220
     221    // user bytes of address space
     222    lpMemStat->dwTotalVirtual = max(sys[2], sys[3]);
     223    lpMemStat->dwAvailVirtual = min(sys[2], sys[3]);
     224  }
     225}
     226
     227
     228
     229VOID WIN32API GlobalMemoryStatus(MEMORYSTATUS *arg1)
    187230{
    188231    dprintf(("KERNEL32:  GlobalMemoryStatus\n"));
    189     O32_GlobalMemoryStatus(arg1);
     232    //O32_GlobalMemoryStatus(arg1);
     233    _GlobalMemoryStatus(arg1);
    190234    dprintf(("dwMemoryLoad    %X\n", arg1->dwMemoryLoad));
    191235    dprintf(("dwTotalPhys     %X\n", arg1->dwTotalPhys));
Note: See TracChangeset for help on using the changeset viewer.