Re: fragmentation



drop669@xxxxxxxxx said:

Hi.
I'm writting my own memory management functions.
While playing with different options, I feel necessity of
fragmentation counting algorithm.
For example, 1 is allocated block and 0 is not.
This is 0% fragmentation: 11111100000
This is 100% fragmentation: 101010101010
How can I build algorithm which will count this coefficient?

Try this and tell me why it doesn't work:

1) count the number of times "10" occurs. (If it's 0 or 1, stop right
there, and the fragmentation is 0%.)
2) subtract 1 (because one boundary is allowed).
3) multiply by 100 (because we want a percentage).
4) divide by whatever you consider appropriate - e.g. number of 1-bits
is a likely candidate.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
.