JOS实验——lab2 exercise 5

  1. What entries (rows) in the page directory have been filled in at this point? What addresses do they map and where do they point? In other words, fill out this table as much as possible:
    EntryBase Virtual AddressPoints to (logically):
    1023?Page table for top 4MB of phys memory
    1022??
    .??
    .??
    .??
    20x00800000?
    10x00400000?
    00x00000000[see next question]
  2. (From Lecture 3) We have placed the kernel and user environment in the same address space. Why will user programs not be able to read or write the kernel's memory? What specific mechanisms protec tthe kernel memory?
  3. What is the maximum amount of physical memory that this operating system can support? Why?
  4. How much space overhead is there for managing memory, if we actually had the maximum amount of physical memory? How is this overhead broken down?
  5. Revisit the page table setup in kern/entry.S and kern/entrypgdir.c. Immediately after we turn on paging, EIP is still a low number (a little over 1MB). At what point do we transition to running at an EIP above KERNBASE? What makes it possible for us to continue executing at a low EIP between when we enable paging and when we begin running at an EIP above KERNBASE? Why is this transition necessary?

问题3:因为我们在初始化页目录项的时候,在目录项的低12位给内核设定了权限,但是并没有给用户相应的权限,见如下代码:

	boot_map_region(kern_pgdir, KERNBASE, 0xffffffff - KERNBASE, 0 , PTE_W | PTE_P);
采用了内存管理中的页保护机制。

问题4: 这个操作系统最大可以支持4G的内存,它在32位的i386上运行,并且实现了虚存管理,因此可以支持4G的内存,而且最多4G,因为超过4G时32的地址是无法寻址的。

问题5:在当前的情况下,为了支持虚存管理我们占用的页面情况是:分配一个页面作为全局页目录表,而且这一个页面已经足够管理4G的空间了,也就是说以后不用再申请页目录了;申请了npages * 8 / PGSIZE个页面来存储struct Page结构,将所有的物理内存对应到某个struct Page上;对于每个已经P标志位为1的页目录项,还分配了一个页面作为页表,总共是67个页面;将PTE_PS置位,使得页面大小由4K变为4M即可减少。

问题6:

	mov	$relocated, %eax
	jmp	*%eax
在jmp之后,eip的值是在KERNBASE以上的,因为relocated = 0xf010002f;在这之前eip=0x10002d,在这之后eip=0xf010002f;

pde_t entry_pgdir[NPDENTRIES] = {					//在页目录中只初始化了两项,第一项和第960项。
	// Map VA's [0, 4MB) to PA's [0, 4MB)
	[0]
		= ((uintptr_t)entry_pgtable - KERNBASE) + PTE_P,		
	// Map VA's [KERNBASE, KERNBASE+4MB) to PA's [0, 4MB)
	[KERNBASE>>PDXSHIFT]
		= ((uintptr_t)entry_pgtable - KERNBASE) + PTE_P + PTE_W
};
由上面的代码可以知道,在初始化页目录中第0项页目录项和和KERNBASE>>PDXSHIFT项页目录项指向相同的页表,因此在eip变为32位后,其指向的实际的物理地址是不变的。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
京东jos是京东提供的一种云服务,包括对象存储、CDN、视频转码等功能。如果想在ThinkPHP5中使用京东jos,可以按照以下步骤操作: 1. 安装京东jos SDK 可以通过 Composer 安装京东jos SDK: ``` composer require jingdong-union/jd-union-sdk-php ``` 2. 配置应用信息 在 `config` 目录下新建 `jos.php` 文件,填写如下内容: ```php <?php return [ 'app_key' => 'your app key', 'app_secret' => 'your app secret', 'access_token' => 'your access token', 'bucket_name' => 'your bucket name', ]; ``` 其中,`app_key` 和 `app_secret` 为京东jos的应用信息,`access_token` 是访问凭证,`bucket_name` 是对象存储的桶名。 3. 使用对象存储功能 ```php <?php namespace app\index\controller; use think\Controller; use Jdcloud\Credentials\Credentials; use Jdcloud\Result; use Jdcloud\Service\OSS\OSSClient; class Index extends Controller { public function index() { // 实例化OSSClient $credentials = new Credentials(config('jos.app_key'), config('jos.app_secret')); $ossClient = new OSSClient([ 'regionId' => 'cn-north-1', 'credentials' => $credentials, ]); // 上传文件 $file = request()->file('image'); $result = $ossClient->putObject([ 'Bucket' => config('jos.bucket_name'), 'Key' => $file->getOriginalName(), 'Body' => fopen($file->getRealPath(), 'r'), ]); // 打印上传结果 dump($result->toArray()); } } ``` 以上代码演示了在 ThinkPHP5 中使用京东jos的对象存储功能,实现了上传文件的功能。其他功能的使用方法类似,只需要根据 SDK 提供的 API 进行调用即可。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值