[haiku-appserver] Re: Shared Memory Allocation

  • From: "Axel Dörfler" <axeld@xxxxxxxxxxxxxxxx>
  • To: haiku-appserver@xxxxxxxxxxxxx
  • Date: Sun, 05 Sep 2004 18:11:56 +0200 CEST

Adi Oanca <adi-oanca@xxxxxxxxxxxxx> wrote:
>  > While shrinking an area is no problem, growing it usually is 
> > (using
>  > resize_area()).
>  > There is no guaranty that the address space after that area is 
> > still
>  > available in which case the function will fail.
>       I don't understand what you're saying here...
>       Why resize_area() is not reliable? and why do you say the address 
> space 
> might be unavailable - because resize_area() might fail? If that's 
> the 
> case, we still can protect ourselfs.

The address space usage of an application is not predictable. In a 
dynamic environment (such as an image processing app that may indeed a 
large BShape/whatever object) it's very likely that resize_area() will 
fail because the address range the growing area would need was already 
given away for other purposes.
I.e. an area spanning from 0x40000-0x50000 cannot grow to 0x60000 if 
this space is already occupied by another area - resize_area() will 
fail in that case.

Therefore, an algorithm that's based on resize_area() to behave 
properly (even with a code path in case resize_area() fails such as 
recreating another big area and copying the old one) is a suboptimal 
algorithm that shouldn't be used if speed is a concern.

Bye,
   Axel.


Other related posts: