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

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,418评论 0 10
  • 今天收到好友发我的信息: 微商跟三级分销的区别: 微商需要交一定数额的代理费用。 要进货,囤货和发货。三级分销是厂...
    王莎莎2017阅读 220评论 0 0
  • 人与人之间若没有交出足够的真诚,那么所谓的关系一定不会保持长久。别让你的热情被他人的冷漠所浇灭,想要对一个人好也不...
    420_c644阅读 637评论 0 0
  • 大纲 1、表单提交的方式GET和POST的区别2、js无法对input的file类型的值进行赋值3、js获取inp...
    前端路上的小兵阅读 924评论 0 2
  • 我觉得我家的荔枝树,我叔家的荔枝树,我现在才明白为什么是这么回事,从大锅饭到个人承包
    海绵小凡阅读 249评论 0 0