[ECOS] problem with memory allcoation

Andrew Lunn andrew.lunn@ascom.ch
Tue Aug 6 03:10:00 GMT 2002


There could be something going on with alignment. When you allocate
the stack memory, do you align the address before passing it to
cyg_thread_create? I think the alignment requirements depends on your
platform.

        Andrew

On Tue, Aug 06, 2002 at 03:31:51PM +0530, Mayank Sharma wrote:
> ok after creating the pool mentioned earlier i do the following 
> >  int *a;
> >  a = (int *)cyg_mempool_var_alloc(pool,sizeof(int));
> >  *a = 32;
> >  <some_instruction>;
> 
> when i am running the above code thru GDB, after the <some_instruction> the
> value of *a is not 32 but some corrupted value.
> remember the above code is running in a thread and not in the
> cyg_user_start(), the memory pool was created in cyg_user_start().
> 
> any clues ?
> 
> Rgds,
> Mayank
> 
> 
> > -----Original Message-----
> > From: Andrew Lunn [mailto:andrew.lunn@ascom.ch]
> > Sent: Tuesday, August 06, 2002 3:31 PM
> > To: Mayank Sharma
> > Cc: ecos-discuss@sources.redhat.com
> > Subject: Re: [ECOS] problem with memory allcoation
> > 
> > 
> > On Tue, Aug 06, 2002 at 03:21:49PM +0530, Mayank Sharma wrote:
> > > Hi Listers,
> > > 	I am facing a peculiar problem with respent to 
> > allocating memory. I
> > > am creating a memory pool using the following code 
> > > 
> > > >   static cyg_mempool_var memobj;
> > > >   static cyg_uint8 mem[4096];
> > > >   cyg_mempool_var_create(mem, 4096, 
> > &(rtosPool.memHandle), &memobj);
> > 
> > This looks OK.
> > 
> > > 
> > > 	Then i start a thread (allocate the stack memory from the above
> > > pool). In the thread i am allocating memory to a variable.
> > 
> > How do you allocate the memory? 
> > 
> > We need more details. My guess is that your stack is on top of *a.
> > 
> >    Andrew
> > 

-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss



More information about the Ecos-discuss mailing list