stack vs bitmap
Posted: Wed Dec 12, 2007 3:12 am
I know this has been asked many times before and I read many forum posts/guides on it but I wanted to gather my thoughts and ask so..
From what I read it seems that for physical memory managers a bitmap would be a better a choice to stack because of the "looseness" of allocation with stacks ( meaning whichever pages happen to get freed also happen to allocated next) - which is bad for continuous allocations and also you need multiple stacks for different address ( 0-16mb, 16mb-?? ) for isa dma and some pci "stuff" ( i didnt find many posts bring up the pci bits ). Also it seems you could make bitmap allocations as fast as stack allocations by keeping a pointer to the last allocated bit and then allocate from there.
thinking that the goal of my os is just to have ring3 multitasking and the ability to write drivers without having to learn another oses api for it ... does it make sense for me to fight with stacks? I know they can be useful if you are going to mess with the full numa and zones - thing I studied in linux previously, but it seems like alot of overhead for a very basic OS.
also I read posts where people knocked bitmaps and the method of keeping a pointer to the last allocated page because it causes alot of fragmentation and was thinking of ideas to reduce the fragmentation:
1) instead of keeping a pointer to the last allocated page - keep one say 5-10 bits back so that even if they are all still allocated "walking" past them will not be expensive .. if 5-10 is successfull maybe larger amounts could help more
2) (very expensive - made up as i was typing this ) ... make an idle task, running in ring0 that when the system was very inactive, that could walk the bitmap array from both ends and when it notices a gap in the bitmap it could swap the node of the highest used bitmap index with the gapped one ... I realize this would be very expensive (tlb flush for the one swapped, maybe other stuff? ) . The task would also have to watch for dma ranges or other areas that need contigous memory, but assuming it was dealing only with virtual addresses ranges it could help to clean up the bitmap alot.
I realize this was more of a ramble then a question but what I was hoping to get out of it was:
1) does a bitmap make more sense and were my reasons on target
2) did either of my proposed cleanups for the bitmap make any sense and/or are there other used ways to deal with the fragmentation?
thanks
From what I read it seems that for physical memory managers a bitmap would be a better a choice to stack because of the "looseness" of allocation with stacks ( meaning whichever pages happen to get freed also happen to allocated next) - which is bad for continuous allocations and also you need multiple stacks for different address ( 0-16mb, 16mb-?? ) for isa dma and some pci "stuff" ( i didnt find many posts bring up the pci bits ). Also it seems you could make bitmap allocations as fast as stack allocations by keeping a pointer to the last allocated bit and then allocate from there.
thinking that the goal of my os is just to have ring3 multitasking and the ability to write drivers without having to learn another oses api for it ... does it make sense for me to fight with stacks? I know they can be useful if you are going to mess with the full numa and zones - thing I studied in linux previously, but it seems like alot of overhead for a very basic OS.
also I read posts where people knocked bitmaps and the method of keeping a pointer to the last allocated page because it causes alot of fragmentation and was thinking of ideas to reduce the fragmentation:
1) instead of keeping a pointer to the last allocated page - keep one say 5-10 bits back so that even if they are all still allocated "walking" past them will not be expensive .. if 5-10 is successfull maybe larger amounts could help more
2) (very expensive - made up as i was typing this ) ... make an idle task, running in ring0 that when the system was very inactive, that could walk the bitmap array from both ends and when it notices a gap in the bitmap it could swap the node of the highest used bitmap index with the gapped one ... I realize this would be very expensive (tlb flush for the one swapped, maybe other stuff? ) . The task would also have to watch for dma ranges or other areas that need contigous memory, but assuming it was dealing only with virtual addresses ranges it could help to clean up the bitmap alot.
I realize this was more of a ramble then a question but what I was hoping to get out of it was:
1) does a bitmap make more sense and were my reasons on target
2) did either of my proposed cleanups for the bitmap make any sense and/or are there other used ways to deal with the fragmentation?
thanks