physical,virtual,malloc

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
xyjamepa

physical,virtual,malloc

Post by xyjamepa »

Hi
memory management system consist of three layers
physical,virtual and malloc/new,free/delete,
so... i never used malloc in my normal program,
i used to use new and delete but i don't know exactly
what malloc does.I read some articals
about its job and they said it puts a pointer at some continuous free pages and this pages may not be continuous in the physical memory but they are in the virtual one.
Is this the way the three layers work together?
thats it some explain about malloc,free and the three layers.
Thanx
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Re:physical,virtual,malloc

Post by Brynet-Inc »

Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
User avatar
ces_mohab
Member
Member
Posts: 77
Joined: Wed Oct 18, 2006 3:08 am

Re:physical,virtual,malloc

Post by ces_mohab »

for application development malloc() and free() differs from new and delete in the following:
1- malloc() and free() are library procedures while new and delete are operators.
2- malloc() and free() allocates and de-allocates memory of arbitrary size.
3- new and delete performs more than just allocation and deallocation. They call constructors of objects.
the following articles just describe the three layers.
http://www.osdever.net/tutorials/memory1.php?the_id=44
http://www.osdever.net/tutorials/memory2.php?the_id=45
or if you want pdf versions:
http://www.osdever.net/tutorials/pdf/memory1.pdf
http://www.osdever.net/tutorials/pdf/memory2.pdf
the main idea is having a system call more_memory() which increases the address space of a given process by amount of memory and having some management of this new area.
heap management.
There are many algorithms in the last level:
I used address-ordered first fit algorithm.
this pdf contains some description:
http://www.cs.northwestern.edu/~pdinda/ics-s05/doc/dsa.pdf
::) :)
To write an OS you need 2 minds one for coding and other for debugging.
User avatar
xyjamepa
Member
Member
Posts: 397
Joined: Fri Sep 29, 2006 8:59 am

Post by xyjamepa »

Thanx guys that was soooooo helpfull. :D
Post Reply