EmbeddedRelated.com
Forums

xavail(NULL) function

Started by aintnoprobs November 23, 2004

Hi,
Is someone able to explain this function clearly.

When I use it on a RCM3700 module

printf("Free xmem: %ld\n",xavail(NULL));

i get the value 262144, which is 256 bytes always.

Even if I add #ximports, I still get the same value.

Does anyone see what I am doing wrong?

code used
------------------
main(){
while(1){
costate{
waitfor(DelayMs(1000));
printf("Free xmem: %ld\n",xavail(NULL));
}
}
}
-------------------



At 01:06 AM 11/23/2004, you wrote:
>Hi,
>Is someone able to explain this function clearly.
>
>When I use it on a RCM3700 module
>
>printf("Free xmem: %ld\n",xavail(NULL));
>
>i get the value 262144, which is 256 bytes always.
>
>Even if I add #ximports, I still get the same value.
>
>Does anyone see what I am doing wrong?
>
>code used
>------------------
>main(){
> while(1){
> costate{
> waitfor(DelayMs(1000));
> printf("Free xmem: %ld\n",xavail(NULL));
> }
> }
>}
>-------------------


xavail() report the amount of free xmem RAM.

#ximports go into flash so that would not effect the amount of RAM available.
------
| Scott G. Henion| shenion@shen... |
| Consultant | Stone Mountain, GA |
| SHDesigns | PGP Key 0xE98DDC48 |
| http://www.shdesigns.org/rabbit/ |
------



--- In rabbit-semi@rabb..., Scott Henion <shenion@s...>
wrote:
> At 01:06 AM 11/23/2004, you wrote:
> >Hi,
> >Is someone able to explain this function clearly.
> >
> >When I use it on a RCM3700 module
> >
> >printf("Free xmem: %ld\n",xavail(NULL));
> >
> >i get the value 262144, which is 256 bytes always.
> >
> >Even if I add #ximports, I still get the same value.
> >
> >Does anyone see what I am doing wrong?
> >
> >code used
> >------------------
> >main(){
> > while(1){
> > costate{
> > waitfor(DelayMs(1000));
> > printf("Free xmem: %ld\n",xavail(NULL));
> > }
> > }
> >}
> >------------------- > xavail() report the amount of free xmem RAM.
>
> #ximports go into flash so that would not effect the amount of RAM
available.

Also, remember that xavail report the LARGEST block that can be
allocated; not the amount that can be allocated. With a value of
262144, you obvioiusly have 512K ram, and ZWorld splits up your RAM
so it is not continuous. However, as Scott pointed out, #ximports
go into flash, not RAM. xalloc uses memory from RAM.