posts - 403, comments - 310, trackbacks - 0, articles - 7
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

          讀核筆記(6) - 虛擬存儲

          Posted on 2008-02-27 23:29 ZelluX 閱讀(704) 評論(4)  編輯  收藏 所屬分類: Linux 、System

          本來想看完pagefault的處理的,不過實驗室有事情了,只能先把這一半放上來了。

          頁面的分配與回收使用了一個叫做buddy allocator的機制,kernelnewbies上的解釋
          The memory allocation scheme used in the kernel. A vector of lists of free pages is kept, ordered by the size of the chunk (in powers of two). When a chunk is allocated, it is removed from the relevant list. When a chunk is freed back to the free pages pool, it is placed in the relevant list, starting from the top. If it is physically contiguous with a present chunk, they are merged and placed in the list above (i.e. where the chunks are twice the size), and this operation percolates up the vector. As regions are merged whenever possible, this design helps to reduce memory fragmentation.

          首先在zone_struct{} 中保存了一個free_area_t數組,這個數組記錄了各種大小的空閑內存塊的信息。
          include/linux/mmzone.h:


          free_area_struct {}

          頁面分配時,找到適合大小的free_area_struct{},然后從free_list中找有沒有空閑的內存塊,如果沒有就找更大的free_area_struct{},因為大小都是2^n,很容易把大塊內存拆開,一塊分配給請求,剩下的保存到對應大小的隊列中。
          頁面回收時主要的問題是如何解決過多的內存碎片。當頁面塊被釋放時,先檢查是否有相同大小的相鄰空閑塊存在,如果有的話就結合起來(遞歸過程)。

          評論

          # re: 讀核筆記(6) - 虛擬存儲  回復  更多評論   

          2008-03-13 13:49 by Kommit
          來踩踩~~~

          # re: 讀核筆記(6) - 虛擬存儲  回復  更多評論   

          2008-03-13 14:37 by ZelluX
          @Kommit
          哇,版大 @.@

          # re: 讀核筆記(6) - 虛擬存儲  回復  更多評論   

          2008-03-14 13:53 by luohandsome
          page fault很有意思。尤其是exception table和fix code
          土問,你看的是ULK?

          # re: 讀核筆記(6) - 虛擬存儲  回復  更多評論   

          2008-03-14 16:25 by ZelluX
          @luohandsome
          看的是那本邊干邊學,差不多兩星期沒看過了
          主站蜘蛛池模板: 扎赉特旗| 叶城县| 汝阳县| 平遥县| 临海市| 巴彦淖尔市| 昌吉市| 汨罗市| 大名县| 凌海市| 辰溪县| 绥江县| 木里| 马公市| 财经| 临潭县| 冀州市| 阿合奇县| 桦甸市| 虹口区| 桓台县| 乌拉特前旗| 连云港市| 平山县| 龙山县| 密山市| 乐山市| 拜泉县| 安西县| 德江县| 汾阳市| 芦山县| 岳普湖县| 和平县| 嘉黎县| 肇州县| 云和县| 竹溪县| 荣昌县| 云阳县| 洱源县|