实际操作系统实验第四讲物理存储器与进程逻辑地址空间的管理计划.doc

上传人:小** 文档编号:2875822 上传时间:2020-05-13 格式:DOC 页数:21 大小:675KB
返回 下载 相关 举报
实际操作系统实验第四讲物理存储器与进程逻辑地址空间的管理计划.doc_第1页
第1页 / 共21页
实际操作系统实验第四讲物理存储器与进程逻辑地址空间的管理计划.doc_第2页
第2页 / 共21页
点击查看更多>>
资源描述

《实际操作系统实验第四讲物理存储器与进程逻辑地址空间的管理计划.doc》由会员分享,可在线阅读,更多相关《实际操作系统实验第四讲物理存储器与进程逻辑地址空间的管理计划.doc(21页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、操作系统实 验 报 告课程名称操作系统实验实验项目名称物理存储器与进程逻辑地址空间的管理学号班级20120616姓名专业计算机科学与技术学生所在学院计算机科学与技术学院指导教师初妍实验室名称地点21#428 哈尔滨工程大学计算机科学与技术学院一、实验概述1. 实验名称物理存储器与进程逻辑地址空间的管理2. 实验目的通过查看物理存储器的使用情况,并练习分配和回收物理内存,从而掌握物理存储器的管理方法。通过查看进程逻辑地址空间的使用情况,并练习分配和回收虚拟内存, 从而掌握进程逻辑地址空间的管理方法。3. 实验类型验证+设计4. 实验内容3.1 准备实验3.2 阅读控制台命令“pm”相关的源代码,

2、并查看其执行的结果3.3 分配物理页和释放物理页3.4 阅读控制台命令“vm”相关的源代码,并查看其执行的结果3.5 在系统进程中分配虚拟页和释放虚拟页3.6 在应用程序进程中分配虚拟页和释放虚拟页3.6.1 要求3.6.2 测试方法3.6.3 提示二、实验环境操作系统 windos xp编译器 OS Lab语言 c语言三、实验过程1. 设计思路和流程图MiAllocateAnyPages函数的流程图 MiFreePages函数的流程图2. 需要解决的问题及解答(1)在实验指导的P160-4.和5.按F10单步调试MmAllocateVirtualMemory函数的执行过程,要求给出监视窗口B

3、aseAddress和RegionSize个变量前后变化截图界面。截图见3.5。在实验指导的P160-1.和2. 按F10单步调试MmFreeVirtualMemory函数的执行过程,要求给出监视窗口BaseAddress和RegionSize个变量前后变化截图界面。 截图见3.5。(2)按照实验指导的P160-3.6 在应用程序进程中分配虚拟页和释放虚拟页,编写代码。要求至少给出源代码及其解释。程序见3.6.2。 (3)按F10单步调试MiAllocateAnyPages函数的执行过程,尝试回答下面的问题:本次分配的物理页的数量是多少?分配的物理页的页框号是多少?物理页是从空闲页链表中分配的

4、?还是从零页链表中分配的?哪一行语句减少了空闲页的数量?哪一行语句将刚刚分配的物理页由空闲状态修改为忙状态?答:本次分配的物理页的数量是1,分配的物理页的页框号是0x409;物理页是从空闲页链表中分配的第226行MiFreePageListHead=MiGetPfnDatabaseEntry(Pfn)-Next;和第227行MiFreePageCount-;减少了空闲页的数量,第229行将刚刚分配的物理页由空闲状态修改为忙状态;(4)按F10单步调试MiFreePages函数的执行过程,尝试回答下面的问题:本次释放的物理页的数量是多少?释放的物理页的页框号是多少?释放的物理页是之前分配的物理页

5、吗?释放的物理页是被放入了空闲页链表中?还是零页链表中?绘制MiFreePages函数的流程图。答:本次释放的物理页的数量是1,释放的物理页的页框号0x409,释放的物理页是之前分配的物理页;释放的物理页被放入了空闲页链表中;见实验过程开头流程图部分。(5)按F10单步调试MmAllocateVirtualMemory函数的执行过程,尝试回答下面的问题:分配的虚拟页的起始地址是多少?分配的虚拟页的数量是多少?它们和参数BaseAddress和RegionSize初始化的值有什么样的关系?分配虚拟页的同时有为虚拟页映射实际的物理页吗?这是由哪个参数决定的?分配的虚拟页是在系统地址空间(高2G)还

6、是在用户地址空间(低2G)?这是由哪个参数决定的?参考MiReserveAddressRegion函数的定义和注释,说明该函数的功能。答:分配的虚拟页的起始地址是0xa0003000,分配的虚拟页的数量是1,BaseAddress和RegionSize初始化的值是期望保留或者提交的地址区域的起始地址和大小;分配虚拟页的同时有为虚拟页映射实际的物理页,这是由第三个参数AllocationType决定的;分配的虚拟页是在系统地址空间(高2G),这是由第四个参数SystemVirtual决定的;MiReserveAddressRegion函数的功能是保留一段虚拟地址区域。(6)按F10单步调试MmF

7、reeVirtualMemory函数的执行过程,尝试回答下面的问题:本次释放的虚拟地址是多少?释放的虚拟页是之前分配的虚拟页吗?参考MiFindReservedAddressRegion函数、MiFreeAddressRegion函数和MiDecommitPages函数的定义和注释,说明这些函数的功能。答:本次释放的虚拟地址是0xa0003000,是之前分配的虚拟页;MiFindReservedAddressRegion函数用于查找已保留地址区域,如果目标区域非已保留区域则返回失败,MiFreeAddressRegion函数用于释放已保留地址区域和MiDecommitPages函数用于释放映射

8、在连续虚拟页框上的物理页框。(7)在本实验3.3中,如果分配了物理页后,没有回收,会对EOS操作系统造成什么样的影响?目前EOS操作系统内核函数MiAllocateAnyPages能处理所有物理页被分配完毕的情况吗?例如在没有可分配的物理页的情况下调用该内核函数,是否会返回失败?如果内核函数MiAllocateAnyPages还不能处理这种极端情况,尝试修改代码解决这个问题。答:如果分配了物理页后,没有回收,将会使可分配自由页和零页越来越少,最终导致内存溢出,系统无法运行。目前EOS操作系统内核函数MiAllocateAnyPages不能处理所有物理页被分配完毕的情况,在没有可分配的物理页的情

9、况下,不会分配物理页,但仍然会返回成功,添加以下代码即可:ElsereturnSTATUS_MEMORY_NOT_ALLOCATED;(8) 在本实验3.3中,在分配物理页时是调用的内核函数MiAllocateAnyPages,该函数会优先分配空闲页,尝试修改代码,调用内核函数MiAllocateZeroedPages优先分配零页,并调试分配零页的情况。尝试从性能的角7度分析内核函数MiAllocateAnyPages和MiAllocateZeroedPages。尝试从安全性的角度分析分配零页的必要性。答:将MiAllocateAnyPages(1,PfnArray);修改为MiAllocat

10、eZeroedPages(1,PfnArray);即可。系统启动时,所有空闲物理页都是未初始化的,此时零页链表为空,MiAllocateAnyPages函数可以直接从自由页链表分配,而MiAllocateZeroedPages函数会对从自由页链表中分配的每一页进行零初始化,确保所有分配页都是被零初始化的,再进行分配,因此MiAllocateZeroedPages函数效率较低。但因为MiAllocateZeroedPages函数对自由页进行了初始化,减小了出错的可能性,从而安全性较高。3.主要数据结构、实现代码及其说明typedefstruct_MMPFNULONGUnused:9; /未用UL

11、ONGPageState:3;/物理页的状态ULONGNext:20; /下一个物理页的页框号MMPFN,*PMMPFN;typedefenum_PAGE_STATEZEROED_PAGE,/零页FREE_PAGE,/自由页BUSY_PAGE,/占用页PAGE_STATE;/虚拟地址描述符typedefstruct_MMVADULONG_PTRStartingVpn; /被使用区域的开始虚页框号ULONG_PTREndVpn; /被使用区域的结束虚页框号LIST_ENTRYVadListEntry;/链表项,用于将描述同一地址空间的所有VAD串/成链表MMVAD,*PMMVAD;/虚拟地址表t

12、ypedefstruct_MMVAD_LISTULONG_PTRStartingVpn; /记录的进程地址空间的开始虚页号ULONG_PTREndVpn; /记录的进程地址空间的结束虚页号LIST_ENTRYVadListHead;/VAD链表头MMVAD_LIST,*PMMVAD_LIST;4.程序运行时的初值和运行结果3.1准备实验1. 启动 OS Lab。2. 新建一个 EOS Kernel 项目。3.2阅读控制台命令“pm”相关的源代码,并查看其执行的结果执行控制台命令“ pm”,查看物理存储器的信息:3.3分配物理页和释放物理页使用 pm.c 文件中 ConsoleCmdPhysic

13、alMemory 函数的 函数体替换 ke/sysproc.c 文件中ConsoleCmdPhysicalMemory 函数的函数体。调试并执行控制台命令“ pm”,查看物理存储器的信息:分配和释放多个物理页调用 MiAllocateAnyPages 函数时分配多个物理页,然后在调用 MiFreePages 函数时将分配的多个物理页释放。3.4阅读控制台命令“vm”相关的源代码,并查看其执行的结果执行控制台命令“ vm”,查看系统进程的虚拟地址描述符信息:按 F5 启动调试。待 EOS 启动完毕,在 EOS 控制台中输入命令“pt”后按回车。“pt”命令可以输出当前系统中的进程列表,其中系统进

14、程的 ID 为 1。在 EOS 控制台中输入命令“ vm 1”后按回车得到虚拟地址描述符信息。执行控制台命令“ vm”,查看当创建了一个应用程序进程后,系统进程和应用程序进程中虚拟地址描述符的信息:切换到“Console-2”, 然后输入命令“ pt”后按回车。 输出的信息:输入命令“ vm 1”后按回车,可以查看系统进程中虚拟地址描述符的信息输入命令“ vm 31”后按回车,可以查看应用程序进程中虚拟地址描述符的信息3.5在系统进程中分配虚拟页和释放虚拟页使用 vm.c 文件中 ConsoleCmdVM 函数的函数体替换 ke/sysproc.c 文件中 ConsoleCmdVM 函数的函数

15、体。在 EOS 控制台中输入命令“vm 1”后按回车调试分配虚拟页和释放虚拟页的过程:vm 命令开始执行后,会在调用 MmAllocateVirtualMemory 函数的代码行处中断。 此时要注意参数BaseAddress 和 RegionSize 初始化的值。分配虚拟页的调试过程中BaseAddress 和RegionSize 的值的变化:进入函数之前BaseAddress 和RegionSize 的值退出函数以后BaseAddress 和RegionSize 的值释放虚拟页的调试过程中BaseAddress 和RegionSize 的值的变化:进入函数前BaseAddress 和Regi

16、onSize 的值刚退出函数时BaseAddress 和RegionSize 的值在调用 MmAllocateVirtualMemory 函数时将 RegionSize 参数的值设置为 PAGE_SIZE+1时“输出”窗口中转储的信息:Total Vpn from 655360 to 657407. (0xA0000000 - 0xA07FFFFF)1# Vad Include 1 Vpn From 655360 to 655360. (0xA0000000 - 0xA0000FFF)2# Vad Include 2 Vpn From 655361 to 655362. (0xA0001000

17、 - 0xA0002FFF)3# Vad Include 2 Vpn From 655365 to 655366. (0xA0005000 - 0xA0006FFF)4# Vad Include 2 Vpn From 655367 to 655368. (0xA0007000 - 0xA0008FFF)5# Vad Include 2 Vpn From 655369 to 655370. (0xA0009000 - 0xA000AFFF)6# Vad Include 2 Vpn From 655371 to 655372. (0xA000B000 - 0xA000CFFF)7# Vad Inc

18、lude 2 Vpn From 655373 to 655374. (0xA000D000 - 0xA000EFFF)8# Vad Include 2 Vpn From 655375 to 655376. (0xA000F000 - 0xA0010FFF)9# Vad Include 2 Vpn From 655377 to 655378. (0xA0011000 - 0xA0012FFF)10# Vad Include 2 Vpn From 655379 to 655380. (0xA0013000 - 0xA0014FFF)11# Vad Include 2 Vpn From 655381

19、 to 655382. (0xA0015000 - 0xA0016FFF)Total Vpn Count: 2048.Allocated Vpn Count: 21.Free Vpn Count: 2027.Zeroed Physical Page Count: 0.Free Physical Page Count: 7126.New VMs base address: 0xA0017000. Size: 0x3000.1# Vad Include 1 Vpn From 655360 to 655360. (0xA0000000 - 0xA0000FFF)2# Vad Include 2 Vp

20、n From 655361 to 655362. (0xA0001000 - 0xA0002FFF)3# Vad Include 2 Vpn From 655365 to 655366. (0xA0005000 - 0xA0006FFF)4# Vad Include 2 Vpn From 655367 to 655368. (0xA0007000 - 0xA0008FFF)5# Vad Include 2 Vpn From 655369 to 655370. (0xA0009000 - 0xA000AFFF)6# Vad Include 2 Vpn From 655371 to 655372.

21、 (0xA000B000 - 0xA000CFFF)7# Vad Include 2 Vpn From 655373 to 655374. (0xA000D000 - 0xA000EFFF)8# Vad Include 2 Vpn From 655375 to 655376. (0xA000F000 - 0xA0010FFF)9# Vad Include 2 Vpn From 655377 to 655378. (0xA0011000 - 0xA0012FFF)10# Vad Include 2 Vpn From 655379 to 655380. (0xA0013000 - 0xA0014F

22、FF)11# Vad Include 2 Vpn From 655381 to 655382. (0xA0015000 - 0xA0016FFF)12# Vad Include 3 Vpn From 655383 to 655385. (0xA0017000 - 0xA0019FFF)Allocated Vpn Count: 24.Free Vpn Count: 2024.Zeroed Physical Page Count: 0.Free Physical Page Count: 7126.Free VMs base address: 0xA0017000. Size: 0x3000.1#

23、Vad Include 1 Vpn From 655360 to 655360. (0xA0000000 - 0xA0000FFF)2# Vad Include 2 Vpn From 655361 to 655362. (0xA0001000 - 0xA0002FFF)3# Vad Include 2 Vpn From 655365 to 655366. (0xA0005000 - 0xA0006FFF)4# Vad Include 2 Vpn From 655367 to 655368. (0xA0007000 - 0xA0008FFF)5# Vad Include 2 Vpn From 6

24、55369 to 655370. (0xA0009000 - 0xA000AFFF)6# Vad Include 2 Vpn From 655371 to 655372. (0xA000B000 - 0xA000CFFF)7# Vad Include 2 Vpn From 655373 to 655374. (0xA000D000 - 0xA000EFFF)8# Vad Include 2 Vpn From 655375 to 655376. (0xA000F000 - 0xA0010FFF)9# Vad Include 2 Vpn From 655377 to 655378. (0xA001

25、1000 - 0xA0012FFF)10# Vad Include 2 Vpn From 655379 to 655380. (0xA0013000 - 0xA0014FFF)11# Vad Include 2 Vpn From 655381 to 655382. (0xA0015000 - 0xA0016FFF)Allocated Vpn Count: 21.Free Vpn Count: 2027.Zeroed Physical Page Count: 0.Free Physical Page Count: 7126.在调用 MmAllocateVirtualMemory 函数时将 Bas

26、eAddress 参数的值设置为已经被占用的虚拟内存,例如 0xA0000000, “输出”窗口中转储的信息:Total Vpn from 655360 to 657407. (0xA0000000 - 0xA07FFFFF)1# Vad Include 1 Vpn From 655360 to 655360. (0xA0000000 - 0xA0000FFF)2# Vad Include 2 Vpn From 655361 to 655362. (0xA0001000 - 0xA0002FFF)3# Vad Include 2 Vpn From 655365 to 655366. (0xA0

27、005000 - 0xA0006FFF)4# Vad Include 2 Vpn From 655367 to 655368. (0xA0007000 - 0xA0008FFF)5# Vad Include 2 Vpn From 655369 to 655370. (0xA0009000 - 0xA000AFFF)6# Vad Include 2 Vpn From 655371 to 655372. (0xA000B000 - 0xA000CFFF)7# Vad Include 2 Vpn From 655373 to 655374. (0xA000D000 - 0xA000EFFF)8# V

28、ad Include 2 Vpn From 655375 to 655376. (0xA000F000 - 0xA0010FFF)9# Vad Include 2 Vpn From 655377 to 655378. (0xA0011000 - 0xA0012FFF)10# Vad Include 2 Vpn From 655379 to 655380. (0xA0013000 - 0xA0014FFF)11# Vad Include 2 Vpn From 655381 to 655382. (0xA0015000 - 0xA0016FFF)Total Vpn Count: 2048.Free

29、 Vpn Count: 2027.Zeroed Physical Page Count: 0.Free Physical Page Count: 7126.New VMs base address: 0xA0003000. Size: 0x1000.1# Vad Include 1 Vpn From 655360 to 655360. (0xA0000000 - 0xA0000FFF)2# Vad Include 2 Vpn From 655361 to 655362. (0xA0001000 - 0xA0002FFF)3# Vad Include 1 Vpn From 655363 to 6

30、55363. (0xA0003000 - 0xA0003FFF)4# Vad Include 2 Vpn From 655365 to 655366. (0xA0005000 - 0xA0006FFF)5# Vad Include 2 Vpn From 655367 to 655368. (0xA0007000 - 0xA0008FFF)6# Vad Include 2 Vpn From 655369 to 655370. (0xA0009000 - 0xA000AFFF)7# Vad Include 2 Vpn From 655371 to 655372. (0xA000B000 - 0xA

31、000CFFF)8# Vad Include 2 Vpn From 655373 to 655374. (0xA000D000 - 0xA000EFFF)9# Vad Include 2 Vpn From 655375 to 655376. (0xA000F000 - 0xA0010FFF)10# Vad Include 2 Vpn From 655377 to 655378. (0xA0011000 - 0xA0012FFF)11# Vad Include 2 Vpn From 655379 to 655380. (0xA0013000 - 0xA0014FFF)12# Vad Includ

32、e 2 Vpn From 655381 to 655382. (0xA0015000 - 0xA0016FFF)Free Vpn Count: 2026.Zeroed Physical Page Count: 0.Free Physical Page Count: 7126.Free VMs base address: 0xA0003000. Size: 0x1000.1# Vad Include 1 Vpn From 655360 to 655360. (0xA0000000 - 0xA0000FFF)2# Vad Include 2 Vpn From 655361 to 655362. (

33、0xA0001000 - 0xA0002FFF)3# Vad Include 2 Vpn From 655365 to 655366. (0xA0005000 - 0xA0006FFF)4# Vad Include 2 Vpn From 655367 to 655368. (0xA0007000 - 0xA0008FFF)5# Vad Include 2 Vpn From 655369 to 655370. (0xA0009000 - 0xA000AFFF)6# Vad Include 2 Vpn From 655371 to 655372. (0xA000B000 - 0xA000CFFF)

34、7# Vad Include 2 Vpn From 655373 to 655374. (0xA000D000 - 0xA000EFFF)8# Vad Include 2 Vpn From 655375 to 655376. (0xA000F000 - 0xA0010FFF)9# Vad Include 2 Vpn From 655377 to 655378. (0xA0011000 - 0xA0012FFF)10# Vad Include 2 Vpn From 655379 to 655380. (0xA0013000 - 0xA0014FFF)11# Vad Include 2 Vpn F

35、rom 655381 to 655382. (0xA0015000 - 0xA0016FFF)Free Vpn Count: 2027.Free Physical Page Count: 7126.在调用 MmAllocateVirtualMemory 函数时将 RegionSize 参数的值设置为 PAGE_SIZE*2, 将BaseAddress 参数的值设置为 0xA0017004,“输出”窗口中转储的信息:Total Vpn from 655360 to 657407. (0xA0000000 - 0xA07FFFFF)1# Vad Include 1 Vpn From 655360

36、to 655360. (0xA0000000 - 0xA0000FFF)2# Vad Include 2 Vpn From 655361 to 655362. (0xA0001000 - 0xA0002FFF)3# Vad Include 2 Vpn From 655365 to 655366. (0xA0005000 - 0xA0006FFF)4# Vad Include 2 Vpn From 655367 to 655368. (0xA0007000 - 0xA0008FFF)5# Vad Include 2 Vpn From 655369 to 655370. (0xA0009000 -

37、 0xA000AFFF)6# Vad Include 2 Vpn From 655371 to 655372. (0xA000B000 - 0xA000CFFF)7# Vad Include 2 Vpn From 655373 to 655374. (0xA000D000 - 0xA000EFFF)8# Vad Include 2 Vpn From 655375 to 655376. (0xA000F000 - 0xA0010FFF)9# Vad Include 2 Vpn From 655377 to 655378. (0xA0011000 - 0xA0012FFF)10# Vad Incl

38、ude 2 Vpn From 655379 to 655380. (0xA0013000 - 0xA0014FFF)11# Vad Include 2 Vpn From 655381 to 655382. (0xA0015000 - 0xA0016FFF)Total Vpn Count: 2048.Allocated Vpn Count: 21.Free Vpn Count: 2027.Zeroed Physical Page Count: 0.Free Physical Page Count: 7126.New VMs base address: 0xA0017000. Size: 0x30

39、00.1# Vad Include 1 Vpn From 655360 to 655360. (0xA0000000 - 0xA0000FFF)2# Vad Include 2 Vpn From 655361 to 655362. (0xA0001000 - 0xA0002FFF)3# Vad Include 2 Vpn From 655365 to 655366. (0xA0005000 - 0xA0006FFF)4# Vad Include 2 Vpn From 655367 to 655368. (0xA0007000 - 0xA0008FFF)5# Vad Include 2 Vpn

40、From 655369 to 655370. (0xA0009000 - 0xA000AFFF)6# Vad Include 2 Vpn From 655371 to 655372. (0xA000B000 - 0xA000CFFF)7# Vad Include 2 Vpn From 655373 to 655374. (0xA000D000 - 0xA000EFFF)8# Vad Include 2 Vpn From 655375 to 655376. (0xA000F000 - 0xA0010FFF)9# Vad Include 2 Vpn From 655377 to 655378. (

41、0xA0011000 - 0xA0012FFF)10# Vad Include 2 Vpn From 655379 to 655380. (0xA0013000 - 0xA0014FFF)11# Vad Include 2 Vpn From 655381 to 655382. (0xA0015000 - 0xA0016FFF)12# Vad Include 3 Vpn From 655383 to 655385. (0xA0017000 - 0xA0019FFF)Free Vpn Count: 2024.Zeroed Physical Page Count: 0.Free Physical P

42、age Count: 7126.Free VMs base address: 0xA0017000. Size: 0x3000.1# Vad Include 1 Vpn From 655360 to 655360. (0xA0000000 - 0xA0000FFF)2# Vad Include 2 Vpn From 655361 to 655362. (0xA0001000 - 0xA0002FFF)3# Vad Include 2 Vpn From 655365 to 655366. (0xA0005000 - 0xA0006FFF)4# Vad Include 2 Vpn From 655

43、367 to 655368. (0xA0007000 - 0xA0008FFF)5# Vad Include 2 Vpn From 655369 to 655370. (0xA0009000 - 0xA000AFFF)6# Vad Include 2 Vpn From 655371 to 655372. (0xA000B000 - 0xA000CFFF)7# Vad Include 2 Vpn From 655373 to 655374. (0xA000D000 - 0xA000EFFF)8# Vad Include 2 Vpn From 655375 to 655376. (0xA000F0

44、00 - 0xA0010FFF)9# Vad Include 2 Vpn From 655377 to 655378. (0xA0011000 - 0xA0012FFF)10# Vad Include 2 Vpn From 655379 to 655380. (0xA0013000 - 0xA0014FFF)11# Vad Include 2 Vpn From 655381 to 655382. (0xA0015000 - 0xA0016FFF)Free Vpn Count: 2027.Zeroed Physical Page Count: 0.3.6在应用程序进程中分配虚拟页和释放虚拟页3.

45、6.1要求创建一个 EOS 应用程序,并编写代码完成下列功能:1. 调用 API 函数 VirtualAlloc,分配一个整型变量所需的空间,并使用一个整型变量的指针指向这个空间。2. 修改整型变量的值为 0xFFFFFFFF。在修改前输出整型变量的值,在修改后再输出整型变量的值。3. 调用 API 函数 Sleep, 等待 10 秒钟。4. 调用 API 函数 VirtualFree,释放之前分配的整型变量的空间。5. 进入死循环,这样应用程序就不会结束。3.6.2编写的代码:#include EOSApp.h int main(int argc, char* argv) #ifdef _D

46、EBUG _asm(int $3n nop); #endif INT *d; /*调用API 函数 VirtualAlloc,分配一个整型变量所需的空间,并使用一个整型变量的指针指向这个空间。*/ if(d=VirtualAlloc(0,sizeof(int),MEM_RESERVE|MEM_COMMIT) printf(Allocated %d bytes virtual memory of 0x%xnn,*d); /*修改整型变量的值为0xFFFFFFFF。在修改前输出整型变量的值,在修改后再输出整型变量的值*/ printf(virtual memory original value :0x%x nn,*d); *d=0xFFFFFFFF;printf(a new virtual memory value :0x%x nn,*d); printf(nWait for 10 secondsn

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 教案示例

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁