Hi guys,
This day i have couple topics related to allocating -memory no matter on hard drive or RAM- to sharing with you
1)what is the best primary memory(RAM) allocation strategy e.g (first,best,worst),
and you choice depend on MFT(multiprogramming with fixed number of tasks) or MVT(multiprogramming with variable number of tasks),...for i'm using MFT
ok, my os now is look like DOS but with some multi-tasking
2)Single user contiguous memory like DOS, but UNIX systems use paging & virtual memory , why should i use virtual memory,and even windows use .swp file for this purpose.
CheerS,
a.T.d
memory allocating
memory allocating
Distance doesn't make you any smaller,
but it does make you part of a larger picture.
but it does make you part of a larger picture.
- NickJohnson
- Member
- Posts: 1249
- Joined: Tue Mar 24, 2009 8:11 pm
- Location: Sunnyvale, California
Re: memory allocating
There are many ways of allocating memory. I generally use an optimized bitmap for low level stuff (pages/frames) because it is simple, compact, and predictable. The heap is much more complex, and there are many algorithms out there - for example, Linux uses a "buddy allocator" which wastes a lot of address space but is very fast. The user heap and the kernel heap are also separate, so you can use different algorithms for different situations. I'm not sure why you want to use a fixed number of tasks though - it's not that hard to make a dynamically expanding set of tasks, and hugely more flexible. You should either go with the single tasking approach or the full multitasking approach.
Virtual memory is very very useful, at least if you're doing multitasking. It allows you to use memory efficiently, protect tasks from each other, and do things like swapping. Windows definitely uses virtual memory too (above 95, that is), which is why it can support a swapfile/pagefile/whatever you want to call it.
Virtual memory is very very useful, at least if you're doing multitasking. It allows you to use memory efficiently, protect tasks from each other, and do things like swapping. Windows definitely uses virtual memory too (above 95, that is), which is why it can support a swapfile/pagefile/whatever you want to call it.
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: memory allocating
Not true - Linux uses a zoned buddy allocator for physical memory management, and a more traditional slab allocator for heap management.
Re: memory allocating
OK, now i'm gonna to write my own malloc();
so whats your advice to use (first,worst,best)-strategy to implements malloc
CheerS,
a.T.d
so whats your advice to use (first,worst,best)-strategy to implements malloc
CheerS,
a.T.d
Distance doesn't make you any smaller,
but it does make you part of a larger picture.
but it does make you part of a larger picture.
Re: memory allocating
No easy answer on that.
Try the old standby "A memory allocator" by Doug Lea, which I consider a must-have-read before writing your own malloc(), and probably Hoard: A Scalable Memory Allocator for Multithreaded Applications by by Berger, McKinley, Blumofe and Wilson.
You'll know more about your options then.
Try the old standby "A memory allocator" by Doug Lea, which I consider a must-have-read before writing your own malloc(), and probably Hoard: A Scalable Memory Allocator for Multithreaded Applications by by Berger, McKinley, Blumofe and Wilson.
You'll know more about your options then.
Every good solution is obvious once you've found it.
Re: memory allocating
Thanx "Solar",.....
...,theory,theory, and theory that all i got from those documents, hehehe whatever
by chance i found this URL: http://www.delorie.com/djgpp/malloc/
talking about malloc() and has implementation, everything goes alright but that site
didn't mention any thing about fragmentation in malloc() algorithm,
so what do you think about malloc() in that URL good or !good
CheerS ,
a.T.d
...,theory,theory, and theory that all i got from those documents, hehehe whatever
by chance i found this URL: http://www.delorie.com/djgpp/malloc/
talking about malloc() and has implementation, everything goes alright but that site
didn't mention any thing about fragmentation in malloc() algorithm,
so what do you think about malloc() in that URL good or !good
CheerS ,
a.T.d
Distance doesn't make you any smaller,
but it does make you part of a larger picture.
but it does make you part of a larger picture.
Re: memory allocating
Which malloc are you referring to? There were a lot there. I think malloc0.c is definately the fastest malloc Ive ever seen, but I wouldnt recomment using it