免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2694 | 回复: 7
打印 上一主题 下一主题

急求 虚拟内存管理 C++ 代码 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-07-16 10:09 |只看该作者 |倒序浏览
急用,没时间写了。想找现成的代码拿来修改

要求:
1)  Address Translation:  a simple TLB(Translation Lookaside Buffer ) that performs FIFO replacement.
2) Paging:
FIFO
Pure LRU — using virtual time for each access
LRU approximation — Second chance algorithm
3) Page Cleaning Daemon
4) Timing Details
5) Data Analysis

如果没有现成的代码,有人愿意帮忙写的话
有偿酬谢, 最好能在10个小时之内完成

论坛徽章:
1
CU十二周年纪念徽章
日期:2013-10-24 15:41:34
2 [报告]
发表于 2010-07-16 10:09 |只看该作者
10个小时,真强大,

论坛徽章:
0
3 [报告]
发表于 2010-07-16 10:10 |只看该作者
回复 2# ecjtubaowp

论坛徽章:
0
4 [报告]
发表于 2010-07-16 10:20 |只看该作者
本帖最后由 gtaww 于 2010-07-16 10:23 编辑

回复 1# gtaww

找到一段页面替换算法

http://wenwen.soso.com/z/q141494646.htm

论坛徽章:
0
5 [报告]
发表于 2010-07-16 14:28 |只看该作者
加我QQ277979760 免费,一起讨论,发给你

论坛徽章:
0
6 [报告]
发表于 2010-07-16 14:32 |只看该作者
虚拟内存管理需要CPU的支持!
再个,你觉得用C++写虚拟内存管理这样的代码合适吗?

论坛徽章:
0
7 [报告]
发表于 2010-07-16 14:52 |只看该作者
回复 6# unistd
用C++也不是不行,毕竟BeOS在1995年就用C++写出内核了。只不过楼主的意思显然是谁手里有现成代码他要买,真的10小时写一份谁敢用啊。

  1. struct VMKernelAddressSpace : VMAddressSpace {
  2.         public:
  3.                                         VMKernelAddressSpace(team_id id, addr_t base,
  4.                                             size_t size);
  5.             virtual                     ~VMKernelAddressSpace();
  6.        
  7.             virtual status_t            InitObject();
  8.        
  9.             virtual VMArea*             FirstArea() const;
  10.             virtual VMArea*             NextArea(VMArea* area) const;
  11.        
  12.             virtual VMArea*             LookupArea(addr_t address) const;
  13.             virtual VMArea*             CreateArea(const char* name, uint32 wiring,
  14.                                             uint32 protection, uint32 allocationFlags);
  15.             virtual void                DeleteArea(VMArea* area,
  16.                                             uint32 allocationFlags);
  17.             virtual status_t            InsertArea(VMArea* area, size_t size,
  18.                                             const virtual_address_restrictions*
  19.                                                 addressRestrictions,
  20.                                             uint32 allocationFlags, void** _address);
  21.             virtual void                RemoveArea(VMArea* area,
  22.                                             uint32 allocationFlags);
  23.        
  24.             virtual bool                CanResizeArea(VMArea* area, size_t newSize);
  25.             virtual status_t            ResizeArea(VMArea* area, size_t newSize,
  26.                                             uint32 allocationFlags);
  27.             virtual status_t            ShrinkAreaHead(VMArea* area, size_t newSize,
  28.                                             uint32 allocationFlags);
  29.             virtual status_t            ShrinkAreaTail(VMArea* area, size_t newSize,
  30.                                             uint32 allocationFlags);
  31.        
  32.             virtual status_t            ReserveAddressRange(size_t size,
  33.                                             const virtual_address_restrictions*
  34.                                                 addressRestrictions,
  35.                                             uint32 flags, uint32 allocationFlags,
  36.                                             void** _address);
  37.             virtual status_t            UnreserveAddressRange(addr_t address,
  38.                                             size_t size, uint32 allocationFlags);
  39.             virtual void                UnreserveAllAddressRanges(
  40.                                             uint32 allocationFlags);
  41.        
  42.             virtual void                Dump() const;
  43.        
  44.         private:
  45.                     typedef VMKernelAddressRange Range;
  46.                     typedef VMKernelAddressRangeTree RangeTree;
  47.                     typedef DoublyLinkedList<Range,
  48.                         DoublyLinkedListMemberGetLink<Range, &Range::listLink> >
  49.                             RangeList;
  50.                     typedef DoublyLinkedList<Range, VMKernelAddressRangeGetFreeListLink>
  51.                         RangeFreeList;
  52.        
  53.         private:
  54.             inline  void                _FreeListInsertRange(Range* range, size_t size);
  55.             inline  void                _FreeListRemoveRange(Range* range, size_t size);
  56.        
  57.                     void                _InsertRange(Range* range);
  58.                     void                _RemoveRange(Range* range);
  59.        
  60.                     status_t            _AllocateRange(
  61.                                             const virtual_address_restrictions*
  62.                                                 addressRestrictions,
  63.                                             size_t size, bool allowReservedRange,
  64.                                             uint32 allocationFlags, Range*& _range);
  65.                     Range*              _FindFreeRange(addr_t start, size_t size,
  66.                                             size_t alignment, uint32 addressSpec,
  67.                                             bool allowReservedRange,
  68.                                             addr_t& _foundAddress);
  69.                     void                _FreeRange(Range* range,
  70.                                             uint32 allocationFlags);
  71.        
  72.                     void                _CheckStructures() const;
  73.        
  74.         private:
  75.                     RangeTree           fRangeTree;
  76.                     RangeList           fRangeList;
  77.                     RangeFreeList*      fFreeLists;
  78.                     int                 fFreeListCount;
  79.         };
复制代码

论坛徽章:
2
技术图书徽章
日期:2013-09-04 15:21:51酉鸡
日期:2013-11-01 21:20:20
8 [报告]
发表于 2010-07-16 16:43 |只看该作者
10个小时,买代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP