-----Original Message----- From: ext hacker hacker [mailto:likeha@rediffmail.com] Sent: Monday, November 17, 2003 4:02 AM To: kernelnewbies@nl.linux.org Cc: Bezerra Allan (EXT-INdT/Manaus) Subject: Re: Physical memory size allocated for each process! >> Hi; >> The way I had implemented on 2.4 was: >> 1) the vm_area structures basically hold the information for each contigous virtual area for a process. The list of all these structures are held in the mm_struct. So from the task structure index into the mm struct and then to the vm_area structure >> 2) next you find the nature of the vm struct. It can be code, data section readable only, data section read write, heap and stack. Using the vm_area_struct flags and the vm_file pointer you can deduce the above: if vm_file_pointer exists and not mapped to /dev/NULL - it means code or data section if flags & VM_EXECUTABLE - it is code else it is data if vm_file_pointer does not exist or it is mapped to /dev/NULL(non anonymous allocation of heap): if flags & VM_GROWSDOWN - it is stack else it is heap ------------------------------------------------------------------------------------------------------------ This code is different from the kernel 2.6. If you take a look in /usr/src/linux/fs/proc/task_mmu.c file, you wil see something like: for (vma = mm->mmap; vma; vma = vma->vm_next) { unsigned long len = (vma->vm_end - vma->vm_start) >> 10; if (!vma->vm_file) { /* if vm_file does not exist*/ data += len; if (vma->vm_flags & VM_GROWSDOWN) { /* it is stack */ stack += len; } continue; } /* if vm_file exists */ if (vma->vm_flags & VM_WRITE) continue; if (vma->vm_flags & VM_EXEC) { exec += len; if (vma->vm_flags & VM_EXECUTABLE) continue; lib += len; } } -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/