Rishabh Pandita
BAN USERkannathal: Sure there is a break pointer but that signals the end of current heap(not necessary that the heap is maxed out, it just shows the current status of heap). when brk is called by malloc the break pointer is moved ahead by the amount of heap required.
- Rishabh Pandita October 13, 2013Malloc will allocate the memory size of 600MB because malloc calls sbrk and brk for getting the free chunk of memory. sbrk allocates free chunk from system memory, also malloc deals with paged virtual system and as rightly pointed out using lazy memory allocation it can be done.
stackoverflow.com/questions/5716100/what-happens-in-the-kernel-during-malloc
stackoverflow.com/questions/6988487/what-does-brk-system-call-do
:brk calls heap which is in VM so so problem allocating till VM is available :)
Heap is taken from VM.
- Rishabh Pandita October 13, 2013Swaping and paging are both used to free some memory location in main memory.
Swaping: it mainly occurs when there is heavy demand on the system memory. It uses swap files, swap files work by swaping the entire process into the swap file.
Paging: in paging virtual memory is freed by moving the pages of a program into the paging file, Not all the pages of the program are moved out, only those which the operating system thinks are not being used frequently or are left idle are moved out. The memory used by the paged out portions is not immediately freed. It is kept on stand by in case the paged out portions are re-activated (which are still stored in system menory)they reclaim it. But if some other application requires that memory it is given up to them.
1.Traverse the list till the end using pointer p,meanwhile update counter till p->next =NULL;
- Rishabh Pandita October 13, 20132. When p->next = null, create circular link list by p->next = head;
3.calculate diff = counter-n;
4.iterate from head till diff.
5.r= p->next
6.p->next=NULL;
7.r=head;
simple!!!