-
[Chapter 3 Process]Practice 3.12 Including the initial parent process, how many processes are created by the program shown in Figure 3.32?
摘要:3.12Including the initial parent process, how many processes are created bythe program shown in Figure 3.32?答案: 共16个进程。解析: 根据之前所学到的关于fork的知识去画进程图, 要注意的一点就是, fork的子进程的程序计数器里的指令和父进程的相同, 所以每次fork之后, 子进程里i的值都会继续增加。例如, 第一个进程, i=0时, fork的子进程的i会继续++, 从1开始。 下面是此题的进程图。jk红色的数字是进程的PID, PID是我当时写的一个程序得到的, 代码如下:.
阅读全文
-
[Chapter 3 Process]Practice 3.9 Describe the actions token by a kernel to content-switch between processes.
摘要:3.9Describe the actions token by a kernel to content-switch between processes.答案: 内核在进行进程上下文切换时, 首先将当前进程的上下文保存在内存中的PCB中, 然后再将下一个进程在内存中的PCB里的上下文读取出来。 上下文包含CPU寄存器里的内容, 堆, 用户栈, 内存管理信息, 数据, 文本。
阅读全文
-
[Chapter 3 Process]Practice 3.8: Describe the differences among short-term, medium-term, long-term scheduling
摘要:3.8Describe the differences among short-term, medium-term, and longterm scheduling.答案: 长期调度决定哪些进程进入到系统中,。 中期调度决定进入到系统中的进程哪些可以竞争处理器, 即哪些进程可以进入到就绪队列。 短期调度决定将处理器分配给就绪队列中的哪些进程。扩展: 长期调度(long-term scheduling)又叫做高级调度(High-level scheduling)或作业调度(job scheduling), 负责决定在系统中, 允许哪些进程主动竞争系统资源。 这个级别有时也称为准入调度, ...
阅读全文
-
[Chapter 3 Process]Practice 3.5 When a process creates a new process using the fork() operation
摘要:3.5 When a process creates a new process using the fork() operation, which of the following state is shared between the parent process and the child process? a. Stack b.Heap c.Shared memory segments答案:c.Shared memory segments.解析:fork一个新的子进程时, 子进程会得到和父进程用户级虚拟地址空间相同的一份拷贝, 包括文本, 数据和bss段, 堆以及用户栈。 所以他...
阅读全文
-
[Chapter 3 Process]Practice 3.4 Describe what happens when a context switch occurs if the new context is already loaded into one of the register sets.
摘要:3.4The Sun UltraSPARC processor has multiple register sets. Describe whathappens when a context switch occurs if the new context is alreadyloaded into one of the register sets. What happens if the new context isin memory rather than in a register set and all the register sets are inuse?答案: 因为暂时还没找到多
阅读全文
-
[Chapter 3 Process]Practice 3.3 Discuss three major complications that concurrent processing adds to an operating system.
摘要:3.3 Original version of Apple's mobile iOS operating system provied no means of concurrent processing. Discuss three major complications that concurrent processing adds to an operating system.答案:此问题不太熟悉, 应该是问向操作系统中加入并发处理后的三个主要并发症是什么。 在网上搜索了一下, 得到了一个答案。 1. The OS has to keep track of the main mem
阅读全文
-
[Chapter 3 Process]Practice 3.2 Including the initial parent process, how many processes are created by the program shown in Figure?
摘要:3.2 Including the initial parent process, how many processes are created by the program shown in Figure?答案: 会创建8个进程。解析:相关知识: fork函数的执行原理 fork函数执行一次, 返回两次,父进程返回子进程的PID, 子进程返回0(至于返回值为什么不同, 这与do_fork函数有关,具体是怎么一回事我还不太清楚)。程序中可利用此性质来区别程序的父进程和子进程。 当一个进程执行fork函数时, 其新建的子进程得到一份父进程用户级虚拟内存空间的拷贝, 包括文本、数据和bbs段、..
阅读全文
-
[Chapter 3 Process]Practice 3.1 相关知识:进程创建、fork函数
摘要:3.1Using the program shown in the Figure3.30, explain what the output will be at LINE A答案:LINE A 处的输出是PARENT: value = 5。解析: 此问题的相关知识有进程创建、fork函数。 当父进程调用fork函数时, 新创建的子进程几乎但不完全与父进程相同, 子进程会获得一份父进程用户级虚拟地址空间的拷贝, 但是此拷贝是独立的, 拷贝内容包括文本、数据和bss段、堆以及用户栈。 所以在图中程序执行时, 子进程有一份自己的虚拟地址空间, 里面存放着和父进程相同的一份代码、数据、用户栈的拷贝..
阅读全文
|