I've started to read something about memory issue. Firstly, I've looked for basic concepts for it. This link is pretty good for basic concepts.
MMU (Memory Management Unit) translates physical memory addresses to virtual addresses. It creates an interrupt when a page fault occured. When a process try to access an address and if the address is unknown for MMU then it creates page fault exception. In this case page fault exception handler examines current state of MMU and process. do_page_fault(...) function is page fault handler for Linux. It is processor specific function, I've studied for x86 based systems.
do_page_fault() function gets two arguments which are error code and registers of the process. The error code specifies the page fault whether because of read operation or write operation.
Firstly the function saves address of line which is cause of the exception (control register two), then saves prev state of process.
Page fault handler needs to detect whether the page fault is good or bad. Good page fault means the process needs more memory. Bad page fault can occur for different cases, in general it causes of terminate the process by the handler.
Actually do_page_fault calls __do_page_fault(...) function and it is main area to handle the page fault.
In Linux based systems every process has a page directory and page table. We can understand which pages used by which process with the data structures. If process needs more memory, the handler gets a page from pglist_data which is a global list and adds the page to page table of process.
The function using mm_struct can detect whether the process has permission access for the address. It uses find_vma function for this operation. If process has to access then the address assigned to the process else the process is terminated and segmentation fault occured.
Processes are created as instance of task_struct which includes mm_structs and keeps info about processes.
You can see process resources under /proc/pid/*. If you want to see process vma, then type "cat /proc/pid/maps" on bash. To understand memory issues better, I've read the chapter, this book is very good for kernel newbies.
Also this two links are very helpful for me, they are for kernel 2.6x series but very good to understand big picture of the topic.
Other sources:
http://www.stillhq.com/pdfdb/000446/data.pdf
http://duartes.org/gustavo/blog/post/how-the-kernel-manages-your-memory/
Daha önce blogunuza mesaj göndermemiş olmama rağmen yazdıklarınızı ve serüveninizi ilgiyle takip ediyorum. Eminim birçok kişi daha, ülkemizde bu konularla ilgili birilerinin olmasından ve yaptıklarınızdan mutluluk duyuyordur. Basari ve mutluluklar dilegiyle...
YanıtlaSilTeşekkür ederim :)
SilGelecekte Linux üzerine çalışmalar yapmak isteyen biri olarak,yaptıklarınız beni heyecanlandırıyor.Özellikle bir çekirdek geliştiricisi olmanızı çok istiyorum.Bu başta kadınlar olmak üzere bilimsel çalışmalarda başarılı olmak isteyen tüm gençlere önemli bir örnek teşkil edecektir.Kolay gelsin.
YanıtlaSilTeşekkürler :)
Sil