[PLUG] Malloc and Glibc

Mathew, Tisson K tisson.k.mathew at intel.com
Tue Nov 26 22:43:32 UTC 2002


Here is the code; I'm running glibc 2.2.2 on XScale iq80320. 

-------------------------- 
#define MYSIZE                          (1*1024)
#define SLEEP_TIME                      (100*1000) // usec

void *AllocThread(void *pvArg);

int main(int argc, char **argv)
{
  pthread_t hThread;
  int       ii;
  int       iLimit=12;

  for(ii=0;ii<iLimit;ii++)
    pthread_create(&hThread,NULL,AllocThread,NULL);

  AllocThread(NULL);

  return 0;
}

void *AllocThread(void *pvArg)
{
  struct timeval tv;
  char          *pBuff=NULL;

  for(;;)
    {
      if((pBuff=(char *)malloc(MYSIZE))==NULL)
        printf("Could not alloc in parent!\n");
      else
        memset(pBuff,0x05,MYSIZE);

      tv.tv_sec=0;
      tv.tv_usec=SLEEP_TIME;
      select(0,NULL,NULL,NULL,&tv);
      if(pBuff)
        free(pBuff);
    }

  return NULL;
}
------------------------------------------------------------

thanks
_tisson

-----Original Message-----
From: Mathew, Tisson K [mailto:tisson.k.mathew at intel.com] 
Sent: Tuesday, November 26, 2002 1:46 PM
To: 'plug at lists.pdxlinux.org'
Subject: RE: [PLUG] Malloc and Glibc

Sure. Browse http://www.arm.linux.org.uk/ 

Thanks 
-tisson

-----Original Message-----
From: Kyle Hayes [mailto:kyle_hayes at speakeasy.net] 
Sent: Tuesday, November 26, 2002 1:35 PM
To: plug at lists.pdxlinux.org
Subject: Re: [PLUG] Malloc and Glibc

On Tuesday 26 November 2002 13:16, Mathew, Tisson K wrote:
> I'm running glibc 2.2.2 on ARM/XScale with pthreads

Try the -D_REENTRANT trick others have mentioned.  It is possible that the 
ARM version does not support pthreads as well I suppose.  Not likely, but 
possible.

Can I play with and ARM too? :-)  I've thought the ARM architecture was 
amazingly nice when I got the first brochures in 1987...  Sigh.  I've 
never even been able to use a computer with an ARM.

Best,
Kyle


_______________________________________________
PLUG mailing list
PLUG at lists.pdxlinux.org
http://lists.pdxlinux.org/mailman/listinfo/plug

_______________________________________________
PLUG mailing list
PLUG at lists.pdxlinux.org
http://lists.pdxlinux.org/mailman/listinfo/plug




More information about the PLUG mailing list