Thread View: comp.sys.ibm.pc.rt
1 messages
1 total messages
Started by Nicholas J. Simicich
Tue, 26 Sep 1989 17:47
Using AIX 2 with large ported BSD programs
Author: Nicholas J. Simicich
Date: Tue, 26 Sep 1989 17:47
Date: Tue, 26 Sep 1989 17:47
139 lines
4519 bytes
4519 bytes
I'm posting this for someone with no net access.
Posted-Date: Mon, 25 Sep 89 11:17:24 -0600
To: bywater!scifi!njs (Nick Simicich)
Subject: overcommitting the page space on RT
Date: Mon, 25 Sep 89 11:17:24 -0600
From: "James Moody" <uunet!cs.utexas.edu!auschs!moody.austin.ibm.com!moody>
Nick,
Recently, Mark Spotswood posted a news article (I believe it
was comp.sys.ibm.pc.rt) asking for help with a problem on
overcommitting the page space on the RT. I am most familiar with this
problem since I was/am a development programmer on the VRM. One of
our vendors was the first we knew of to have the problem and I
developed a solution for them. Mark's article reminded me that this
is always going to be a problem for large, memory consuming
applications that were originally written for a BSD system. My
solution is an easy way for developers to port these kind of apps to a
system that uses delayed allocation of paging slots (like AIX version
2).
I don't have the capability to post articles to the outside
world but I believe this may be an article worth posting. I mailed
Mark a copy of this and he replied saying it was exactly what he
wanted. If you could post this for me I would appreciate it. Thanks
in advance.
/* ----------------------- cut here --------------------------------*/
#define PAGESIZE 2048
#define NULL 0
#include <sys/signal.h>
volatile int dangerflag;
void free();
int main()
{ int size, *ptr;
void handler();
char *MALLOC();
/* ensure this program catches sigdanger */
signal(SIGDANGER,handler);
/*************************************************************
your favorite memory hogging program which uses MALLOC to
allocate storage (not malloc)
*************************************************************/
size = ????;
ptr = MALLOC(size);
....
....
}
void handler()
{
/* sigdanger is sent when the number of paging slots drops
below the pswarn threshold (see /etc/master) */
dangerflag = 1;
}
#define MAXMEMSIZE 0x1000000
/* MALLOC is used to overcome the possibility of overcommitting the
page space */
char *MALLOC(size)
unsigned int size;
{
char *malloc();
char *p,*q;
int i;
volatile int *numps; /* number of paging slots from low memory */
/* Make sure dangerflag is initialized */
dangerflag = 0;
/* point to number of paging slots in AIX low memory */
numps = (int *)0xb8;
printf("slots,size is %d %d",*numps,size);
/* ensure there is enough backing storage to back all of
memory (note MAXMEMSIZE is as good as I can get here: that
is, a lessor value wouldn't work on machines with less
memory */
if ((*numps * PAGESIZE) < (size + MAXMEMSIZE)) return((char*)NULL);
/* call the real malloc to get the storage */
q = p = malloc(size);
if (p == (char *)NULL) return(p);
for(i = 0; i < size ; i += PAGESIZE)
{
/* touch and dirty the next page */
*q = 0;
/* Get out if we went below the pswarn threshold */
if (dangerflag) goto getout;
/* bump to the next page (note: must be careful to
touch on the next page boundary and not in the
middle of the page */
q = (char *)(((int)q & (~(PAGESIZE-1))) + PAGESIZE);
}
printf("slots,size is %d %d",*numps,size);
/* ensure there is still enough backing storage */
if ((*numps * PAGESIZE) < (size + MAXMEMSIZE)) goto getout;
return(p);
getout: /* There isn't enough space available */
printf("slots,size is %d %d",*numps,size);
free(p);
return((char *)NULL);
}
/* ------------------------- cut here -----------------------------*/
Zippy says:
.. the MYSTERIANS are in here with my CORDUROY SOAP DISH!!
James Moody Adv Workstation Div
IBM Austin, 2502
aesnet: moody@moody.austin.ibm.com
vnet: MOODY at AUSVM6
[512] 823-3743 t/l 793-3743
[external mail here--->] cs.utexas.edu!ibmaus!auschs!moody!moody
P.S. I'm not sure the return mail address is correct because I'm
something of a novice at this.
--
Nick Simicich --- uunet!bywater!scifi!njs --- njs@ibm.com (Internet)
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads