OS MP2

In this machine problem, we need to implement frame pool manager to allocate and release the memory.

Design rule is kernel space is within 0-4 MB, process memory from 4MB to 32MB. So we have kernel frame pool below 4MB, process memory pool above 4MB. there are 3 stages to record the usage of memory pool. we use two bit 00 available, 01 head of sequence allocated, 10 allocated. Each bytes contains 8 bits, so we could store 4 frames usage status in 1 byte.

In the head file, in the class contFramePool, we define two ContFramePool objects, kernel memory pool and process memory pool. base frame no and nframes to record frame pool start in the physical memory, size of frame pool. info_frame_no and ninfo_frame where do we start to management information.

There are mainly 4 functions?

first one is initialized function

bitmap could fit in a single frame?

infoframno = 0, we keep managemnt info in first frame. else we use provided frame to store information.

innitialize bitmap to zero.

mark the first frame which is being used already.

get function we want a frame which could allocate the memory and return its index, also mark the frame as being used in bitmap.

frame_no initialized as base_frame_no


mark inaccessible,

mark all the frames in the range as being used.

first we check the range

update bitmap

Release function, here we have create a conframepool object temp.check if the _first_frame_no is the within the kernel pool.

first we release the first frame in these allocated frames and remove continuous part

Since 1 frame with 4096 bytes storage, we could store 4096 * 8 / 2 roughly 16000 frames information,up to manage 64MB memory

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi閱讀 7,825評(píng)論 0 10
  • 今天收到好友發(fā)我的信息: 微商跟三級(jí)分銷的區(qū)別: 微商需要交一定數(shù)額的代理費(fèi)用。 要進(jìn)貨,囤貨和發(fā)貨。三級(jí)分銷是廠...
    王莎莎2017閱讀 237評(píng)論 0 0
  • 人與人之間若沒有交出足夠的真誠,那么所謂的關(guān)系一定不會(huì)保持長久。別讓你的熱情被他人的冷漠所澆滅,想要對(duì)一個(gè)人好也不...
    420_c644閱讀 703評(píng)論 0 0
  • 大綱 1、表單提交的方式GET和POST的區(qū)別2、js無法對(duì)input的file類型的值進(jìn)行賦值3、js獲取inp...
    前端路上的小兵閱讀 969評(píng)論 0 2
  • 我覺得我家的荔枝樹,我叔家的荔枝樹,我現(xiàn)在才明白為什么是這么回事,從大鍋飯到個(gè)人承包
    海綿小凡閱讀 291評(píng)論 0 0

友情鏈接更多精彩內(nèi)容