操作系统 CH3 Process Description and Control
- 格式:pdf
- 大小:509.13 KB
- 文档页数:58


3
CHAPTER
Processes
PracticeExercises
3.1UsingtheprogramshowninFigure3.30,explainwhattheoutputwill
beatLineA.
Answer:
Theresultisstill5asthechildupdatesitscopyofvalue.Whencontrol
returnstotheparent,itsvalueremainsat5.
3.2Includingtheinitialparentprocess,howmanyprocessesarecreatedby
theprogramshowninFigure3.31?
Answer:
Thereare8processescreated.
3.3OriginalversionsofApple’smobileiOSoperatingsystemprovidedno
meansofconcurrentprocessing.Discussthreemajorcomplicationsthat
concurrentprocessingaddstoanoperatingsystem.
Answer:FILL
3.4TheSunUltraSPARCprocessorhasmultipleregistersets.Describewhat
happenswhenacontextswitchoccursifthenewcontextisalready
loadedintooneoftheregistersets.Whathappensifthenewcontextis
inmemoryratherthaninaregistersetandalltheregistersetsarein
use?
Answer:
TheCPUcurrent-register-setpointerischangedtopointtotheset
2.5经典进程的同步问题
在多道程序环境下,进程同步问题十分重荽,出现一系
列经典的进程同步问题,其中有代表性有:
-生产者一消费者问题
-哲学家进餐问题
-读者一写者问题
■"生产者一消费者〃问题
•问题描述
P1 cl
c2
pm cm
L记录型信号量解决“生产者一消费者"问题
设置两个同步信号量及一互斥信号量
empty :说明空缓冲单元的数目,其初值为有界缓冲区的大小n。
Full :说明满缓冲单元的数目(即产品数目),其初值为0.
Mutex:说明该有界缓冲区是一临界资源,必须互斥使用,
其初值为1。
int in=0,out=0; item buffer[n]; semaphore
mutex=1 , empty =n , full=O ; void
proceducerO {
do { producer an item nextp ;
• • •
wait (empty);
wait(mutex);
buffer[in] = nextp ;
in = (in + l) % n ;
signal(mutex); signal(full);
}while(TRUE); } void consumerO { do{ wait(full);
wait(mutex);
nextc = buffer[out];
out = (out+l)%n; signal
(mutex); signal(empty);
consumer the item in nextc ;
• • •
}while(TRUE); } void mainO
{ cobegin proceducerQ;
consumerQ;coend}
1. 互斥信号量的RV操作在每一程序中必须成对岀现.
2. 资源信号量(full,empty)也必须成对出现,但可分别处于不同的程序中. "生产者-消费者〃问题中应注意
实验2:进程的描述与控制
Windows 2000进程的一生
(实验学时:2学时)
2.1 背景知识
Windows 2000 所创建的每个进程都从调用CreateProcess() API函数开始,该函数的任务是在对象管理器子系统内初始化进程对象。每一进程都以调用ExitProcess()或TerminateProcess() API函数终止。通常应用程序的框架负责调用ExitProcess()函数,对于C++运行库来说,这一调用发生在应用程序的main()函数返回之后。
1. 创建进程
CreateProcess()调用的核心参数是可执行文件运行时的文件名及其命令行。表2-1详细地列出了每个参数的类型和名称。
表2-1 实验记录
参数名称 使用目的
LPCTSTR lpApplivationName 全部或部分地指明包括可执行代码的EXE文件的文件名
LPCTSTR lpCommandLine 向可执行文件发送的参数
LPSECURIITY_ATTRIBUTES
lpProcessAttributes 返回进程句柄的安全属性,主要指明这一句柄是否应该由其他子进程所继承。
LPSECURIITY_ATTRIBUTES
lpThreadAttributes 返回进程的主线程的句柄的安全属性
BOOL bInheritHandle 一种标志,告诉系统允许新进程继承创建者进程的句柄
DWORD dwCreationFlage 特殊的创建标志(如CREATE_SUSPENDED)的位标记
LPVOID lpEnvironment 向新进程发送的一套环境变量;如为null值则发送调用者环境
LPCTSTR lpCurrentDirectory 新进程的启动目录
STARTUPINFO lpStartupInfo STARTUPINFO结构,包括新进程的输入和输出配置的详情
LPPROCESS_INFORMATION
操作系统常用英语词汇
1. 操作系统 (Operating System)
2. 进程 (Process)
A process refers to an instance of a running program. It includes the
program code, data, and resources required to execute the program.
3. 线程 (Thread)
A thread ___.
4. 内存 (Memory)
5. 文件系统 (File System)
A file system is a method used by an operating system to organize
and store files on a storage device. It provides a ___ data.
6. 输入/输出 (Input/Output)
7. 锁 (Lock) A lock ___ access to shared resources. It helps ___.
8. 调度 (ling)
___ used by an operating system to ___.
9. 异常处理 (n Handling)
n ___ of the program when errors occur.
10. 系统调用 (System Call)
11. 虚拟内存 (Virtual Memory)
Virtual memory is a memory management technique that allows the
operating system to use disk storage as an n of physical memory. It
provides a larger address ___.
12. 设备驱动程序 (Device Driver)