OS/2, eCS & ArcaOS - Technical > Programming
[GCC] Unable to define getMemorySize()
Lars:
--- Quote from: Silvan Scherrer on September 26, 2024, 05:40:24 pm ---
--- Quote from: Mentore on September 26, 2024, 12:38:34 pm ---
--- Quote from: Dave Yeo on September 25, 2024, 06:31:10 pm ---Looks like you will have to write an OS/2 get_avail_mem_size.
--- End quote ---
Oh, that may be actual fun :) guess I'll give it a go asap.
Mentore
--- End quote ---
libc has that implemented since long. see https://github.com/bitwiseworks/libc/commit/1ee2ad15bb9db8f0a327ec6a3cf6c216d2004b8c
--- End quote ---
The libc implementation returns size in pages whereas in this case it is supposed to be returned in bytes. But of course that is easy enough to take into account.
Mentore:
--- Quote from: Lars on September 26, 2024, 04:01:19 pm ---#if defined(_WIN32)
#undef BOOLEAN
#include <windows.h>
#elif defined(__unix__) || defined(__unix) || defined(unix) || (defined(__APPLE__) && defined(__MACH__))
#include <unistd.h>
#include <sys/types.h>
#include <sys/param.h>
#if defined(BSD) && defined(HAVE_SYS_SYSCTL_H)
#include <sys/sysctl.h>
#endif
#if defined(__APPLE__) && defined(__MACH__)
#import <mach/mach.h>
#import <mach/mach_host.h>
#endif
#elif defined(__OS2__)
#define INCL_BASE
#include <os2.h>
#else
#error "Unable to define getMemorySize( ) for an unknown OS."
#endif
...
unsigned long long getAvailableMemorySize(void)
{
...
#elif defined(__OS2__)
unsigned long mem_got;
if (NO_ERROR == DosQuerySysInfo(QSV_TOTAVAILMEM,QSV_TOTAVAILMEM,&mem_got,sizeof(mem_got)))
{
return (unsigned long long)mem_got;
}
return 0L;
...
--- End quote ---
You guys are invaluable 8)
It's compiling... Will let you know.
Mentore
Mentore:
--- Quote from: Mentore on September 30, 2024, 09:56:12 am ---
You guys are invaluable 8)
It's compiling... Will let you know.
Mentore
--- End quote ---
Compiled. Had to circumvent other two problems though:
* In get_resident_set_size.c there are some calls to get the memory used by the process. I don't know if we have getrusage available, so I remembered processes on OS/2 were limited to 512MB and decided to return a fixed size of 400MB. I'm almost sure it's a stupid idea 8) but will try it. I have to search for getrusage in libc.
* BOOL is defined as unsigned int, conflicting with os2.h definition. Corrected.
* There was another reference to getMemorySize() in another .c file, also tackled this.
Now ngspice-42.exe is available under OS/2 as beta - will try and see if I can use rusage instead of reporting a fixed 400MB memory used by the process.
Mentore
Mentore:
Last update: yes, getrusage is available in our libc. Compiling it - will test this binary asap and - if it works as I expect - it's going to HobbesArchive.
Mentore
Lars:
--- Quote from: Mentore on September 30, 2024, 12:19:06 pm ---Last update: yes, getrusage is available in our libc. Compiling it - will test this binary asap and - if it works as I expect - it's going to HobbesArchive.
Mentore
--- End quote ---
Seems like our getrusage does not return any memory size information, only use of time ("ru_utime", "ru_stime").
I suspect this is not what you are looking for.
As to memory: Rich Walsh has elaborated somewhere in this forum about what the various memory sizes mean and how they play together:
https://www.os2world.com/forum/index.php/topic,3445.msg41758.html#msg41758
It would be nice if we could get that added to "getrusage".
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version