[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: more question about porting/gcc



On Sat, 21 Mar 1998, Mario Becroft wrote:

> On Fri, 20 Mar 1998, Jo Even Skarstein wrote:
> 
> > I can understand that a process is given the largest available block
> > at startup, but is it possible to modify Malloc() so it uses the
> > *smallest* possible block? Theoretically this is just as bad (if not
> > worse) as using the largest block, but if possible it should be tested
> > and see if things improves. 
> 
> But that would be even worse, since it's impossible to prevent some
> fragmentation, and so programs would always get the smallest possible
> amount of memory. If there was a 10MB block and a 100KB block, the
> programs would get only 100K! Really the amount of memory required by a

What I was trying to say was that programs should get the largest
possible block, but in all other cases Malloc() should use the
*smallest* possible block. Theoretically this will not prevent
fragmentation at all, but it will probably lead to smaller fragments
and a larger largest block.

Hmm... When I look in Tanenbaum's "Modern operating systems" it looks
like best fit (smallest possible block) isn't a very good idea after
all:

"Somewhat surprisingly, it [best fit] also results in more wasted
memory than first fit or next fit because it tends to fill up memory
with tiny, useless holes."

And this is what he says about worst fit (largest possible block):

"Simulation has shown that worst fit is not a very good idea either."

It actually looks like a simple first fit algorithm would be the best
choice for MiNT, as it doesn't grab the largest block every time, and
doesn't create as small fragments as best fit.

Anyway, the best it can do is to postpone the inevitable, the only way
to really solve this problem is to page all memory.


/*
** Jo Even Skarstein    http://www.stud.ntnu.no/~josk/
**
**    beer - maria mckee - atari falcon - babylon 5
*/