A4: Virtual MemoryR

3天干完6个月的活,Claude把模型搬上AMD 一条挺刺激的消息:Anthropic 给投资人的材料里有一张幻灯片,写着它的 Claude Mythos Preview 只花了大约​,就摸清了怎么让另一个 Claude 模型在 AMD 的 MI355X 上跑起来。同一处还写了个对照数字:过去给一块新芯片做推理适配,通常要几十名工程师、​。3 天对 6 个月,这个比值太扎眼,当天中文互联网上就冒出一堆「英伟达的护城河塌了」的说法。我把能翻到的材料都翻了一遍,越看越觉得,塌掉的那一小块是真的,可塌的位置和很多人想的不一样。 阅读详情

Java Python A4: Virtual Memory

Due Nov 12 by 11:59p.m.

Points 90

Available after Oct 23 at 12a.m.

Introduction

In this assignment, you will investigate memory access patterns, simulate the operation of page tables and implement several page replacement algorithms. This will give you some practice working with the algorithms we have been talking about in class.

This assignment is based on a virtual memory simulator that uses the simvaddr-*.ref memory reference traces located at /u/csc369h/fall/pub/a4/traces. The first task is to implement virtual-to-physical address translation and demand paging using a page table design of your choice. Then you will implement two different page replacement algorithms: simplified 2Q and Clock.

Before you start work, you should complete the set of readings about memory, if you haven't done so already:

Paging: Introduction (http://pages.cs.wisc.edu/~remzi/OSTEP/vm-paging.pdf)

Background

Valgrind has an option that will allow you to print out the memory reference trace of a running program (using the lackey tool), which we are using to generate traces for the virtual memory simulator in Assignment 4.

There are five different C programs that we've created address traces, and they are used in the virtual memory simulator for this assignment. The programs are:

simpleloop - loops over an array allocated in the heap (You can also modify the code to run the same loop using stack memory)

repeatloop - loops over a heap-allocated array multiple times

matmul - naive matrix multiply with the ability to change the element size to change the memory access behaviour

blocked - a more memory-aware matrix multiply that should exhibit a better hit rate under some page replacement algorithms

reuse_scan - repeatedly accesses a smaller array while sequentially accessing every page in a very large array (should showcase the benefits of a scan-resistant algorithm like simplified 2Q)

We have provided the half-processed traces from Valgrind in the addr-*.ref memory reference traces files in case you are interested. These files are not used by your simulator.

Part 1: Virtual to physical translation

Fall 2023 Intro Video (https://utoronto-my.sharepoint.com/:v:/g/personal/angela_demkebrown_utoronto_ca/EbKyHJpzWPxPhps-NQ2_Y4sBnQPBOPBgaYVQEC8edO06Bg?e=GTXGbm)

Setup

Log into MarkUs to create or update your repo and get the starter code. Remember that you cannot manually create a new a4 directory in your repo or MarkUs won't see it.

The traces from our sample programs at /u/csc369h/fall/pub/a4/traces will be interesting to run once you have some confidence that your program is working, but you will definitely want to create small traces by hand for testing.

The format of the traces is reftype vaddr value as shown in the sample below. Note that the page offset part of the addresses are all between 0 and 15 (0xf) to fit in the reduced simulated physical page frames. For a write reference type (S or M), the value will be written to the virtual address. For a read reference type (L or I) the value is the expected value that should be read from the virtual address. It should always be the same as the value in the most recent preceding write reference to the same virtual address. We use this to check that the address translations and pagein/pageout operations are working correctly. A sample trace snippet is shown below:

S 309001 182

S 1fff000000 55

I 108005 0

S 308008 122

L 1fff000000 55

L 308008 122

I 4cc5000 0

L 5018008 0

Note that in our traces, the Instruction reference type is likely to always have a value of 0 because these addresses are not written to after the program starts executing. You will also see Load references with a value of 0 when the trimmed trace includes a Load from an address that has not yet been written to.

malloc369

We have provided a custom malloc library named malloc369 which can help you with detecting memory leaks, and also ensure that you do not use too much memory for your page table implementation. Make sure you only allocate memory using malloc369() and free dynamically allocated memory using free369(). Do not use the C library malloc function directly, as it bypasses our dynamic memory tracker.

Task 1 - Address Translation and Paging

Implement virtual-to-physical address translation and demand paging using a pagetable design of your choice.

The main driver for the memory simulator, sim.c, reads memory reference traces in the format shown above, from trimmed, reduced valgrind memory traces. For each line in the trace, the program asks for the simulated physical page frame. that corresponds to the given virtual address by calling find_physpage, and then reads from the simulated physical memory at the location given by the physical frame. number and the page offset. If the access type is a write ('M' for modify or 'S' for store), it will also write the value from the trace to the location. You should read sim.c so that you understand how it works but you should not modify it.

The simulator is executed as ./sim -f <tracefile> -m <memory size> -s <swapfile size> -a <replacement algorithm> where memory size and swapfile size are the number of frames of simulated physical memory and the number of pages that can be stored in the swapfile, respectively. The swapfile size should be as large as the number of unique virtual pages in the trace.

There are four main data structures that are used:

1. unsigned char *physmem: This is the space for our simulated physical memory. We define a simulated page frame. size of SIMPAGESIZE and allocate SIMPAGESIZE * "memory size" bytes for physmem.

2. struct frame. *coremap: The coremap array represents the state of (simulated) physical memory. Each element of the array represents a physical page frame. It records if the physical frame. is in use and, if so, a pointer to the page table entry for the virtual page that is using it.

3 A4: Virtual MemoryR . struct pt_entry - a page table entry. The format of a page table entry is up to you, but at a minimum it must record the frame. number if the virtual page is in (simulated) physical memory and an offset into the swap file if the page has been written out to swap. It must also contain flags to represent whether the entry is Valid, Dirty, and Referenced.

4. swap.c: The swapfile functions are all implemented in this file, along with bitmap functions to track free and used space in the swap file, and to move virtual pages between the swapfile and (simulated) physical memory. The swap_pagein and swap_pageout functions take a frame. number and a swap offset as arguments. The simulator code creates a temporary file in the current directory where it is executed to use as the swapfile, and removes this file as part of the cleanup when it completes. It does not, however, remove the temporary file if the simulator crashes or exits early due to a detected error. You must manually remove the swapfile.XXXXXX files in this case.

To complete this task, you will have to write code in pagetable.c and pagetable.h. Read the code and comments in this file -- it should be clear where implementation work is needed and what it needs to do. Basic round-robin and random replacement algorithms are already implemented for you, so you can test your translation and paging functionality independently of implementing the replacement algorithms.

Efficiency: In a real operating system implementation, the memory space taken up for your page tables reduces the memory space available to store the pages of processes' virtual address spaces. Hence, keeping page tables small is desirable. Reducing the time complexity of page table lookups is also important. Your solution will be evaluated on correctness as well as space and time efficiency.

Task 2 - Replacement Algorithms

Using the starter code, implement CLOCK (with one ref-bit) and simplified 2Q replacement algorithms.

Note: to test your page replacement algorithms, we will replace your pagetable.c with a solution version, so your page replacement algorithm must be contained to the provided functions.

Once you are done implementing the algorithms you can use the provided simvaddr-*.ref traces and the autotester to check the results. For each algorithm, the tester will run the programs on memory sizes 50 and 100 and check the output against the expected results.

Efficiency: Page replacement algorithms must be fast, since page replacement operations can be critical to performance. Consequently, you must implement these policies with efficiency in mind. For example, we will give you the expected complexities for some of the policies:

RR: init, evict, ref: O(1) in time and space

CLOCK: init, ref: O(1) in time and space; evict: O(M) in time, O(1) in space, where M = size of memory

simplified 2Q: init, evict, ref: O(1) in time and space

Important notes

When we run the autotests on your code, your page replacement algorithms will be compiled with a different pagetable.c file (the one from the solution). All the code of the page replacement algorithms must be in their separate .c files, not in pagetable.c.

When a page is being evicted, there should be only 2 possibilities: (i) the page is dirty and needs to be written to the swap; and (ii) the page is clean and already has a copy in the swap. A newly initialized page (zero-filled) should be marked dirty on the very first access.

CLOCK must use the "Referenced" flag stored in the page table entry. All the algorithms must utilize their ref() functions (if necessary) instead of adding any algorithm-specific code to pagetable.c. There are functions in pagetable.c to get the values of the Valid, Dirty, and Referenced flags given a page table entry, which you should implement. Use these functions in your replacement algorithm implementations if you need to check any of these flags -- do not assume a particular format for page table entries, or your replacement algorithms are unlikely to work with our solution version of pagetable.c.

The simulator and the page replacement algorithms must not produce any additional or different (from starter code) output (except for errors that should be printed to stderr), otherwise the tests will fail.

The simulator writes a value into the simulated physical memory pages for Store or Modify references, and checks that simulated physical memory contains the last written value on Load or Instruction references. If there is a mismatch, the simulator prints an error message. These errors indicate that there is something wrong with the address translation implementation.

For debugging, you will find it useful to implement the print_pagetable() function in pagetable.c. The function should print (at least) one line for each in-use page in the pagetable (valid in memory, or currently evicted to swap). Other than that, what information it displays is up to you -- we will only be testing that it produces at least the expected number of outputs lines.

You can use the debug variable in sim.c to control extra output during development (you can use the -d <level> option to sim.c to selectively print different levels of detail in your debug output, e.g. './sim -d 1 -f ...'). During grading, we will run sim with debug = 0.

Submission

Once you have tested your code and verified that it works according to specification, and committed it locally (check that by running git status), you can git push it back to MarkUs. We will collect and grade the last version pushed to MarkUs after the assignment deadline. Note that whatever you get from the autotester will be your final mark, therefore, you are recommended to run it before your final submission.

You must only modify the following files:

pagetable.c

pagetable.h

clock.c

s2q.c

In addition, you may modify list.h, if you do not want to use the provided linked list implementation. Read the comments in that file before making any changes.

You may push other code to the repository, but the tester will ignore them. Lastly, please do not push tester output files into the repository         

如何处理动态语言(Python / JS)的“隐形”调用链? 本文揭示动态语言(Python/JS)中静态AST解析导致调用链“断链”的核心问题,提出通过运行时追踪补全图谱的解决方案。基于Code-Graph-RAG的cgr trace机制,分别利用pytest插件与V8 Profiler捕获真实调用路径,将动态边合并至静态图谱,并在权重体系中提升动态边优先级。实践表明,该方法可显著提升图谱覆盖率,实现“结构+行为”双视角理解代码,为MCP与Rerank系统提供可靠支持。 阅读详情

相关推荐

Playwright: Pytest vs Library vs LibraryAsync:三者如何选?

Python中Playwright的3个Target:Pytest(推荐用于E2E自动化测试,支持报告、并行、重试)、Library(同步脚本,适合爬虫与简单任务,需手动管理浏览器)、LibraryAsync(异步脚本,适用于高并发批量操作)。选择依据:测试项目选Pytest,轻量脚本选Library,高并发场景选LibraryAsync。

SmallBull的博客 228

本地化部署 DeepSeek,构建单细胞与空间转录组 AI 分析平台

本地化部署 DeepSeek,构建单细胞与空间转录组 AI 分析平台

weixin_53637133的博客 187

基于AR和SLAM技术的商场智能导视系统技术原理详解

本文针对智慧商场室内导航需求,提出基于AR和SLAM技术的商场智能导视系统技术方案,实现了沉浸式导览体验并促进消费转化,助力商场运营升级。

维小帮定位导航的博客 1244

【第 009 讲】全面掌握 Python 注释:注释的定义与作用 | 单行注释 | 三引号与多行注释 | 注释使用的最佳实践

本文系统讲解 Python 注释的完整知识体系:从注释的定义与作用讲起,梳理单行注释的书写位置、临时屏蔽用法与 PEP 8 排版规范,剖析注释被忽略的底层机制;进而说明三引号字符串的本质与嵌套问题;最后给出注释使用的三条实践原则,帮助读者写好可读性高的注释。

大模型全栈工程师 · Thanks_ks 1164

Spark Graphx 项目实战(航班飞行网图分析)

航班飞行网图分析一.需要的技能点二.任务描述三.数据探索1.下载数据2.数据格式四.航班飞行网图问题分析1.构建航班飞行网图2.统计航班飞行网图中机场与航线的数量3.计算最长的飞行航线4.找出最繁忙的机场5.找出最重要的飞行航线6.找出最便宜的飞行航线五.代码实现 一.需要的技能点 Spark GraphX API Spark GraphX PageRank Spark GraphX Pregel 二.任务描述 需求概述: 探索航班飞行网图数据 构建航班飞行网图 使用Spark GraphX完成下列任

May_J_Oldhu的博客 1542

用示波器抓取同步Buck自举电容波形:从充电回路到SW节点振铃的完整分析

本文通过实测TI TPS54561和MPS MPQ4572同步Buck芯片,详细解析了自举电容在充电、维持和放电三个工作阶段的波形特征。重点揭示了电感泄放回路与充电回路重叠时,在SW节点引发的振铃现象及其产生机理,并提供了串联阻尼电阻等有效的工程抑制方法。文章结合示波器实测,为硬件工程师提供了从波形观测到问题调试的完整实践指南。

weixin_29276847的博客 374

AI全栈实战 | 3.9-01 爬虫入门:requests 加 BeautifulSoup 三分钟跑通,但 90% 的人栽在这 4 个“礼貌“问题上

⚠️:本文内容仅用于。请遵守目标站点的服务条款与相关法律法规,不得对目标服务造成负担,不得采集、传播个人隐私数据。技术是中性的,边界在你手里。爬虫的入门技术(requests 发请求 + BeautifulSoup 解析)三分钟就能学会。真正区分"会用爬虫"和"会做爬虫的人"的,是这篇我们跑通"请求→解析→存储"的最小闭环,然后重点把"合规与礼貌"这根弦给你绷上。

源码获取 | 运行部署 | 定制二开修改,如果回复不及时请耐心等待,请见谅。 442

UVM概述及uvm_component和uvm_object(一)

UVM:Universal Verification Methodology(通用验证方法学) UVM:是建立在systemverilog平台上的一个库,提供了一系列的接口,让我们能够更方便的进行验证。验证平台组成: Driver:用来把不同的激励施加给DUT; Monitor:用来检测DUT的输出; Scoreboard:专门用来比较期望值与monitor检测到的DUT输出; Refer

南国之邱 1万+

Python 的 yield from 到底转发了什么:拆开 send、throw 和那个 return 值

很多人把yield from记成「省一层 for 循环的语法糖」。写和写,结果看着一样,于是就当它只是少敲几个字。这个理解会在三个地方翻车:调用方.send()的值送不进去、子生成器return的值拿不到、异常和close()传不下去。yield from真正做的事是,外层生成器退成一个透明通道。本文所有输出来自本机 CPython 3.13.14 实测。yield from不是循环,是委托——nextsendthrowclose四个方向的流量全部直通子生成器,并且子生成器return。

小小张说故事的博客 163

在abaqus中利用point-based 来快捷定义螺栓连接

abaqus中可以通过point-based方式定义连接点的位置,并对连接方式进行定义,可以进行螺栓连接的模拟。 可以通过逐点输入坐标或导入外部的坐标位置 也可以通过阵列的方式定义点 定义完点后就利用create fasteners,选择point-based,选取刚才创建好的点阵列,然后定义连接的属性,如下图 定义connector section时,类型选择translator,相当于只有1方向可以动,定义弹性模量以及破坏准则。 案例操作 假如有两个板,通过...

fiber_tape的博客 7353

飞塔防火墙认证绕过漏洞(CVE-2022-40684)深度剖析与实战复现

本文深度剖析了Fortinet飞塔防火墙高危认证绕过漏洞CVE-2022-40684的原理与影响。该漏洞允许攻击者通过构造包含特定Forwarded头和User-Agent的HTTP请求,无需凭证即可绕过认证,以管理员身份访问设备。文章详细演示了从环境搭建到实战复现,最终植入SSH密钥获取控制权的完整过程,并提供了漏洞挖掘技巧与关键防御建议。

d6e7f8g9h的博客 709

从一段视频到可漫游的 4D 有声场景:思路拆解与最小复现手记

只需一段手机视频,你就能生成可"走进去"的 4D 有声场景:转头时狗叫声方向随之变化,走近时声音更清晰。本文拆解 Video-to-4DAVScene 的核心思路,手把手带你用几十行 Python 搭出最小管线,把视频中的运动物体变成带空间位置的声源,并附上三个真实踩坑的排障经验,代码可直接跑。🎧

helloagent的博客 246

YOLOv11模型改进:利用注意力机制实现小目标检测精度跃升

如果你在实操中遇到精度提升不明显或速度下降过多的问题,不妨尝试调整注意力模块的类型(如替换为CA)或插入层级,或针对性优化小目标的数据集增强策略。记住,小目标检测的核心是“特征强化与空间定位”,只要结合业务场景灵活调整注意力模块的组合,你也能让YOLOv11在小目标识别任务中脱颖而出。接下来,我们从模块选型到代码落地,一步步带你打造“小目标检测专精版”YOLOv11,真正帮你解决工业场景中(如安防、质检)的小目标识别痛点。在城市安防场景中,改进后的YOLOv11对远处行人、车辆(小目标)的识别准确率提升。

m0_71589036的博客 456

【每天一个 Python 小案例30】Python 基础知识综合小项目:我的工具盒

作为系列收官,本篇把前 29 篇的知识点合成一个能直接用的命令行工具"我的工具盒":计算器(用 ast 解析表达式,不碰 eval)、单位换算与温度转换(一张换算表 + 特例分支)、记账与分类统计(Decimal + JSON 持久化)、以及用"字典当命令表"把菜单和业务逻辑解耦的主循环。文中对比了 eval 的安全隐患与 ast 白名单的做法,解释了 lambda 闭包在字典里的写法与晚绑定陷阱,并在最后给出整个系列的知识地图,把变量、数据结构、控制流、函数、类、异常、文件、标准库八块内容对应到具体篇目。

xinjiyaya的博客 432

基于Simulink的转向控制系统仿真建模示例

本文完成了基于 Simulink 的 EPS 转向控制系统仿真,实现了:✅掌握 EPS 助力控制基本原理✅构建车速敏感的可变助力策略✅在 Simulink 中验证低速轻便、高速沉稳的手感✅达成“安全、舒适、高效”的现代转向系统。

xiaoheshang_123的博客 88

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

双路径优化+双容差校准

默认使用向量化路径处理常规数据,当检测到内存非连续或需要极致短路性能时,自动切换至 Numba JIT 路径。“当 CI 宽度中位数为 $W$ 时,实际判定容差为 $10^{-12} + 10^{-9} \times W$"针对表征谱算子 2 的实际输出量纲(例如 $10^{-3}$ 至 $10^3$),调整。准确标记了哪些数组被复制。非短路、静默拷贝风险、量纲耦合容差),本方案重构了核心逻辑。,并完善审计元数据以记录内存拷贝状态。, 确保在不同量纲下判定标准的一致性。,否则需排查上游数据生成逻辑。

2301_77211362的博客 202

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

yolo 和 deft 算法的区别

你应该是打错了:是,不是 defrat;

曾大强博客 274

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

蓝桥杯·全国青少年信息素养大赛·电子学会Python/C++考级 备考:莫队算法离线区间查询详解

备赛进行时:第十八届蓝桥杯软件赛报名已于 2026-10-08 10:00 开启、12-18 14:00 截止,省赛定在 2027-04-10(C/C++·Python 程序设计 9:00–13:00);中国电子学会 2026 年 12 月软件编程(C/C++ 一级至十级、Python 一级至六级)考级报名 9/23–12/2 16:00、统考 12-12;全国青少年信息素养大赛 2026—2027 赛季算法应用主题赛也已进入复盘练兵窗口。

IT_Scratch的博客 184

两张表合并之后,行数悄悄多了一倍

pandas merge 行数异常膨胀源于右表键不唯一,导致数据静默复制。实测显示,未聚合的右表(756行)与左表合并后行数增至504行,合计膨胀3.5倍,但无报错。validate 参数仅在检查键唯一性时有效,one_to_one 和 many_to_one 可拦截问题,但需结合 duplicated() 前置检查。正确做法为先按键聚合右表,再合并,避免重复。建议合并前后核对行数、合计,并使用 indicator=True 排查匹配情况,确保数据一致性。

patrickstar231的博客 251

我用 200 行代码写了个“代码屎山检测器“,扫完公司的老项目后我沉默了

这个工具不能帮你把屎山铲平,但至少能让你知道自己面对的是多大的山,也能在代码评审时用数据说话——“这个 PR 把圈复杂度从 12 推到了 18,能不能拆一下?毕竟,不能量化的东西,就没法改进。

xixiaoyunya的博客 272

智慧农业实战:育秧车间秧盘计数与苗情分级的Python实现

首先,建立统一的数据结构,保存每盘秧苗的编号、批次、覆盖度、叶色得分和播种天数。A = "壮苗"B = "合格苗"C = "弱苗"@dataclassdays: int。

荆棘鸟智能的博客 138

Java Arrays.asList 常见坑详解|UnsupportedOperationException、数组联动、基本类型 bug

解析 Arrays.asList 常见开发陷阱,演示 UnsupportedOperationException、底层数组引用共享、基本类型数组问题,区分 Arrays 内部 ArrayList 与 java.util.ArrayList,给出数组转 List 的各种场景正确代码。

weixin_42617033的博客 511

【每天一个 Python 小案例29】Python 实现商品购物车

本篇实现一个购物车:商品目录、加入商品、修改数量、移除商品、查看小计、计算满减与 VIP 折扣、结算扣库存。核心设计是"目录与购物车分离"——目录存商品主数据,购物车只存 {商品编号: 数量};金额一律用 Decimal 并做 ROUND_HALF_UP 舍入。折扣部分讲清阶梯满减的匹配顺序(阈值从高到低、命中即停)与叠加顺序(先满减、后打折),并用一次完整结算演示 706 元如何变成 613.70 元。

xinjiyaya的博客 219

Python的字典

Python字典是存储键值对的数据结构,通过键(key)快速查找对应的值(value)。可使用{}定义,支持增删改查操作:通过dict[key]查询或修改值,get()方法安全获取并设置默认值,del dict[key]删除键值对,keys()、values()和items()用于遍历。items()结合双变量循环可高效遍历所有键值对,提升代码可读性与灵活性。

qq_43010954的博客 199

黄仁勋走了,护城河留下了什么

11 月 12 日,英伟达董事会批准黄仁勋辞去总裁、CEO 和董事职务,即刻生效,CFO 克雷斯出任临时 CEO;股价开盘一度跌 14.35%,收盘只跌 4.34%,市值单日蒸发 1820 亿美元;本文把「创始人走了护城河就没了」这个流行说法拆开——CUDA 还在,但 CUDA 正在被 Claude 三天凿穿,真正决定下一段路的是三个可以核对的东西:治理结构、决策机制、以及下一个百亿美元由谁拍板。

领码SPARK - 以无代码之星火,燎原数字之未来! 187
上一篇: DAT561: Midterm Project: Smart Logistic Warehouse System in AmazonPython
下一篇: ECX2630-ECX5630 Chinese Economy and Global Business Sample Final Exam PaperSQL
priorityqueue2
博客等级 码龄2年 175粉丝 30原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值