已阅读5页,还剩5页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
10北京邮电大学2011-2012学年第一学期计算机科学与技术学院(09405-08408)“Operating Systems” Test(1)1. (10 points) Describe the principle of signals Answers: Unix、Linux等操作系统提供的一种基于事件驱动的进程间通信机制。当系统内发生某种特定事件时,OS将产生1个信号,并以信号方式通知特定进程;当进程收到信号后,将转入内核态下的信号处理程序,以响应所发生的事件,对其进行处理。2. (10 points) Describe the principle of pipe-based inter-process communications. Answer:是一种OS提供的基于共享文件的进程间通信方式。2个需要进行通信的进程共享1个称为管道的文件,发送方通过执行“写文件”系统调用向管道中写入数据,接收方通过“读文件”系统调用从管道中读取数据,传递的数据为无格式字节流,由此实现2个进程间数据量通信。OS提供了管道的创建/打开/关闭/读写等原语。或(书上):相互通信进程由1个共享文件管道连接。管道是用于连接读进程和写进程、实现它们之间通信的软件,向管道提供输入的发送进程以字符流形式将数据批量写入管道,接收进程从管道中读取数据。3. (25 points) In a computer system, the users submit to the system their computational tasks as jobs, and all these jobs are then stored as the standby jobs on the disk. The job scheduler (also known as long-term scheduler) selects the standby jobs on the disk, creates new processes in memory for them, and then starts executing these processes. Each jobs ID is the same as that of the process created for it, for example, Ji and Pi. When the number of concurrent processes in memory is lower than three, the job scheduler takes the FCFS algorithm to select a standby job on the disk to create a new process. Otherwise, the processes should wait in the disk.For the processes in memory, the process scheduler (also known as short-term scheduler) takes the non-preemptive priority-based algorithm to select a process and allocates the CPU to it. It is assumed the system costs resulting from job and process scheduling are omitted. Consider the following set of Jobs J1, J2, J3 , J4 and J5. For 1 i 5, the arrival time of each Ji , the length of the CPU burst time of each process Pi, and the priority number for each Ji/Pi are given as below, and a smaller priority number implies a higher priority. Job Arrival Time Burst Time Priority Number (minute) J1 14:00 40 4 J2 14:20 30.01 2 J3 14:30 50.01 3 J4 14:50 20.01 5 J5 15:05 10.01 5 (1) Illustrate the execution of each job/process by charts. (2) What is the turnaround time of each job?(3) What is the waiting time of each job? Note: The waiting time of a job includes the time it waits on the disk and that it waits in memory.Answer:答案:(1)注:图中Ji部分表示作业被调入内存,Pi表示进程被调度执行。J1到达时,并发进程数3,作业被直接调入内存,创建进程P1;P1被调度程序选中,开始执行。J2到达时,并发进程数3,作业被直接调入内存,创建进程P2;此时P1在执行,因此P2处于就绪等待状态。P1结束后,系统内有2个作业J1、J2对应的进程P1、P2,优先级高的进程P2开始执行。J3到达时,并发进程数=23,作业被直接调入内存,创建进程P3,等待P2执行完毕。P2执行完毕后,系统内有2个作业J3、J4对应的进程P3、P4,优先级高的进程P3被调度程序选中,开始执行。J4到达时,并发进程数=23,作业被直接调入内存,创建进程P4,等待P3执行完毕。P3执行完毕后,系统内有2个作业J4、J5对应的进程P4、P5,2者的优先级相同,按照FCFS原则,P4先执行。J5到达时,并发进程数=3,必须等到P2结束后,系统内并发进程数2) processes. . Answers:具体参见讲义第6章n Shared datan boolean choosingn; /* choosingi=true: Pi begins/wants to apply for ticket*/ n int numbern; /* numberi: ticket# for Pi , numberi0 表示Pi需要进入临界区: */n data structures are initialized to false and 0 respectivelyProcess Pi:do choosingi = true; /*begin to apply for ticket*/numberi = max(number0, number1, , numbern 1) + 1; /* a ticket whose number is maximum is given , first come first given, in non-decreasing order */choosingi = false; /* end application */ for (j = 0; j n; j+) /*考虑所有进程*/ while (choosingj) ; /*如有其它进程正在申请,等待Pj 申请完*/while (numberj != 0) & (numberj, j) P1 (2,3,2) P2 (4,6,4) P3 (5,6,5)or:P1 (
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026威海县医院面试题及答案
- 2026仙游招聘面试题目及答案
- 2026小区供电面试题目及答案
- 培训机构入股合同协议
- 2026-2031年中国MP3行业市场调查与发展前景预测研究报告
- 2025-2026学年河北省石家庄市井陉矿区四下数学期中试题(含答案)
- 汕尾市华侨管理区人民医院建设项目环境影响报告表
- 2025-2026学年河北省保定市安新县三年级数学第二学期期中教学质量检测试题含答案解析
- 费托烯烃制高碳醇项目可行性研究报告模板-申批备案
- 北京市朝阳区事业单位招聘笔试真题2025
- 2025年中考化学专项训练:实验题(含答案)
- 青少年体态管理课件
- 水利工程项目结算审核规范
- 2025河南许昌市襄城县深化自收自支事业单位转岗人员易考易错模拟试题(共500题)试卷后附参考答案
- 2025年宁波舟山港股份有限公司招聘笔试参考题库含答案解析
- 中小学教师教研活动现状问题及改善建议10000字【论文】
- 2024年国家公务员考试《行测》真题卷(地市卷)答案和解析
- 药物涂层球囊临床应用中国专家共识(第二版)2023年解读
- 油罐防腐工程技术方案
- LY/T 3315-2022森林立地质量评价技术规程
- CCC认证 3C认证 3C强制
评论
0/150
提交评论