Changeset 4319


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

GlobalMemoryStatus implemented without Open32

Location:
trunk/src/kernel32
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified 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));
  • TabularUnified trunk/src/kernel32/oslibdos.cpp

    r4285 r4319  
    1 /* $Id: oslibdos.cpp,v 1.43 2000-09-20 21:32:53 hugh Exp $ */
     1/* $Id: oslibdos.cpp,v 1.44 2000-09-25 04:35:01 phaller Exp $ */
    22/*
    33 * Wrappers for OS/2 Dos* API
     
    20392039
    20402040
     2041ULONG OSLibDosQuerySysInfo(ULONG iStart, ULONG iLast, PVOID pBuf, ULONG cbBuf)
     2042{
     2043  USHORT sel = RestoreOS2FS();
     2044  APIRET rc;
     2045 
     2046  rc = DosQuerySysInfo(iStart, iLast, pBuf, cbBuf);
     2047 
     2048  SetFS(sel);
     2049  SetLastError(error2WinError(rc,ERROR_INVALID_HANDLE));
     2050  return rc;
     2051}
  • TabularUnified trunk/src/kernel32/oslibdos.h

    r4285 r4319  
    1 /* $Id: oslibdos.h,v 1.23 2000-09-20 21:32:55 hugh Exp $ */
     1/* $Id: oslibdos.h,v 1.24 2000-09-25 04:35:00 phaller Exp $ */
    22
    33/*
     
    202202                           LPDWORD lpBytesPerSector, LPDWORD lpNumberOfFreeClusters,
    203203                           LPDWORD lpTotalNumberOfClusters);
     204
     205ULONG OSLibDosQuerySysInfo(ULONG iStart, ULONG iLast, PVOID pBuf, ULONG cbBuf);
    204206
    205207
     
    282284
    283285ULONG OSLibDosQueryModuleName(ULONG hModule, int cchName, char *pszName);
    284 
    285 
Note: See TracChangeset for help on using the changeset viewer.