首页 > 其他分享 >CITS2002 simulation of virtual memory

CITS2002 simulation of virtual memory

时间:2024-10-08 12:22:00浏览次数:11  
标签:process RAM virtual simulation memory page

CITS2002 - Second Project

A simple simulation of virtual memory

  • This project is worth 10% of the marks in the unit.
  • The project can be done in groups of two.
  • The due date of the project is October 17, 11:59 pm.
  • The project description is long, but the coding is simple. We will

discuss the project in the workshops on Fridays.

1 A simple simulation of virtual memory

The aim of this project is to simulate a simple virtual memory system usingan array as the RAM of a hypothetical machine. The project will also require

some C programming skills of using structures and pointers.We have a computer whose RAM is an array of size 16. It is an array

of pointers. There are 8 page frames in the RAM, each consisting of twocontiguous locations in the array. Hence, the page size of this computer is 2.The virtual memory of this computer is an array of pointers of size 32(We will pretend it is on disc, but actually it is an array in the RAM ofour computer). There are 4 processes in this computer, and each proces canhave 4 pages, and obviously all the pages of all the processes cannot be inthe main memory at the same time. Some pages will be in the main memoryand some pages will be in the virtual memory at any time. The processes arenumbered 0 . . . 3. Each process has a page table, which is an integer array,entry of a process page table indicates whether the page is in RAM or in the

virtual memory (on disc), k if the page is in RAM (k is the frame number,between 0 . . . 7), and 99 if the page is in disc (99 cannot be a frame number).You have to define a structure that will consist of three fields, a processid, a page number of the process, and the last time this page was accessedif it is in the RAM. Time in the simulation is not real time, rather a timestep. Time increases in simulation steps, as explained below. The simulationstarts (at time 0) by initializing the virtual memory with all the 4 pages ofeach process. You have to do the following steps before the simulation starts:

1• Define a structure whose pointer will be stored in each array locationof the RAM and the virtual memory. The structure may look like this:

struct {

int process_id;

int page_num;

int last_accessed;

} memory;

Initialise the process id and page num with the id of the process (anumber between 0 . . . 3) and a page number of that process (a numberbetween 0 . . . 3). Initialise all last access to 0.

  • Create each page and store pointers in the array for the virtual memory. Note that the process id and page num of two consecutive arraylocations will be the same since each page occupies two array locations.The simulation starts by reading a file where there is a single line ofintegers separated by blanks, for example:

0 2 1 3 3 2 2 0 2 1 0 2 3 0

Each integer indicates a process id. For example, the first number 0 indicates that the next page of process 0 has to be brought in from virtualmemory to the RAM. The process table of process 0 and the RAM have tobe代 写CITS2002   simulation of virtual memory  updated accordingly. You can keep the content of the virtual memoryunchanged, as that s how virtual memory systems work. Our processes donot do any computation, they just request the next page and later may writea page back to virtual memory. You can assume for simplicity that all thepages are always in the virtual memory and nothing needs to be writtenback, as no pageisupdated by doing any computation. The last accessedtime of a page will be the time step when you brought the page to RAM.

For example, after reading this file, the first (or 0th page of process 0 willbe brought to RAM), the last accessed time of this page will be 0, as theimulation starts now and time is 0. Time will increase by 1 for each entryin the file.The RAM may become full sometime, you have to use the local Least

Recently Used (LRU) algorithm for evicting a page and bringing a new page.2local means you have to evict the least recently used page of the sameprocess for accommodating the new page. If there is no page of the processwhose page you want to bring in, use a global LRU policy, evict the page

that is least recently used among all pages in the RAM.

2 Submission

You have to write a C program in a single file called simulation.c, andcompiled as an executable called simulation. It will read two file names fromthe command line, in.txt and out.txt. The first file is the one mentionedabove, for reading process ids. The second file is an output file where youshould print the following information at the end of the simulation. Yoursubmission will be executed as:simulation in.txt out.txt

  • The page tables of the four processes in separate lines. For example,the page table for process 0 may look like this:3, 2, 1, 99This means there are three pages of process 0 in the RAM, pages 0, 1and 2, in frames 3, 2 and 1, and page 3 is in the disc.You have to also print the content of the RAM, each location separated

by a ’;’. For example, the RAM may look like this:0,0,5; 0,0,5; 2,0,1; 2,0,1; etc. (16 entries)Note that, the first two locations of the RAM stores page 0 of process0, as each page occupies two array locations of the RAM. Also, thispage was brought to RAM at time step 5.Amitava Datta

September 2024

标签:process,RAM,virtual,simulation,memory,page
From: https://www.cnblogs.com/comp9313/p/18451411

相关文章

  • 论文分享-《GPU Memory Exploitation for Fun and Profit》
    1.研究问题该论文对NVIDIAGPU上不同内存空间(globalmemory,localmemory,sharedmemory)中存在的bufferoverflow问题进行了深入的研究,并成功对在GPU上运行的DNN应用实现了ROP攻击。以往的研究局限于单一内存空间中bufferoverflow的影响,没有对不同内存空间的跨......
  • MemoryAnalyzer指定JDK版本
    小手追梦于2021-06-2809:56:24发布阅读量2w收藏20点赞数21分类专栏:java版权java专栏收录该内容171篇文章4订阅订阅专栏问题描述MemoryAnalyzer启动时报错看了日志,提示需要jdk11才可以运行,但是我的环境变量配置的是jdk8,这咋整?不想更改环境变量中的jdk配置信息,因为......
  • WPF VirtualizingPanel.CacheLength="1" VirtualizingPanel.CacheLengthUnit="Item" c
    <ListBoxItemsSource="{BindingBooksCollection,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"SelectedIndex="{BindingImgIdx,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"VirtualizingPanel.IsVirtualizing=......
  • Oracle VM VirtualBox安装俄文win10系统
    1. 下载win10俄文版ISO官网地址:https://www.microsoft.com/zh-cn/software-download/windows10/ 双击运行后选择【我接收】进入下面界面 选择【为另一台电脑创建安装介质U盘、DVD或ISO文件】 取消勾选【对这台电脑使用推荐的选项】后,选择语言为俄语(参照本机“安装语言......
  • 设置virtualBox开机无界面启动
    前言virtualBox中部署了centos,里面运行着docker跑着测试服务。服务器是一台windows。想着怎么设置开启启动且没有界面启动。方式有很多种方式,最终决定,使用windows自带的计划任务。我们新建一个任务并设置是不是登录都要执行,开机启动后30秒(必须设置)把启动的exe和执行的......
  • PlantSimulation的socket交互之TCP
    PlantSimulation的socket交互之TCP 1.python的socketTCP客户端建立其实可以任选python或plantsimulation作为客户端,博主因研究需要,将python设为客户端。plant设为服务器。1"""2CreatedonSatDecember1421:00:0020213@author:ZhangLitong-NanjingUniversity......
  • Bad or missing usercopy whitelist? Kernel memory overwrite attempt detected to S
    Linux内核有一个usercopywhitelist机制,只允许这里面的region来做usercopy。如果是用kmem_cache_create申请的kmem_cache申请的内存空间来copytouser或者copyfromuser,那么就会报这个错。这时要用kmem_cache_create_usercopy,来将申请的区域加入到usercopywhitelist中。/***......
  • 易优CMS出现:Allowed memory size of 134217728 bytes exhausted (tried to allocate 2
    当你遇到“Allowedmemorysizeof134217728bytesexhausted(triedtoallocate20480bytes)”的错误时,这意味着PHP的内存限制已经耗尽。这种错误通常发生在处理大量数据或执行复杂计算时。为了解决这个问题,可以采取以下几种方法:方法1:修改 php.ini 文件(推荐)找到 php......
  • 易优CMS登录后台报Allowed memory size of 134217728 bytes ex hausted (tried to alo
    当你在登录后台时遇到“Allowedmemorysizeof134217728bytesexhausted(triedtoallocate20480bytes)”的错误提示时,通常是由于PHP的内存限制不足导致的。以下是一些具体的解决步骤:步骤1:检查PHP配置登录宝塔面板登录宝塔面板。在左侧菜单栏选择“软件商店”。......
  • 大数据-136 - ClickHouse 集群 表引擎详解1 - 日志、Log、Memory、Merge
    点一下关注吧!!!非常感谢!!持续更新!!!目前已经更新到了:Hadoop(已更完)HDFS(已更完)MapReduce(已更完)Hive(已更完)Flume(已更完)Sqoop(已更完)Zookeeper(已更完)HBase(已更完)Redis(已更完)Kafka(已更完)Spark(已更完)Flink(已更完)ClickHouse(正在更新···)章节内容上节我们完成了如下的内容:测试连接集群数据类型......