操作系统习地的题目
- 格式:doc
- 大小:201.50 KB
- 文档页数:46
操作系统试题及答案一、选择题1. 操作系统的主要功能是什么?A. 提供人机接口B. 管理计算机硬件资源C. 执行应用程序D. 实现文件管理答案:B. 管理计算机硬件资源2. 下列哪个不是操作系统的组成部分?A. 内存管理器B. 文件管理器C. 进程管理器D. 网络管理器答案:D. 网络管理器3. 进程是指什么?A. 程序的执行实例B. 程序的源代码C. 程序的编译结果D. 程序的运行环境答案:A. 程序的执行实例4. 下列关于多道程序设计的说法正确的是?A. 可以同时运行多个程序B. 只能运行一个程序C. 依次执行多个程序D. 只有操作系统才能运行多个程序答案:A. 可以同时运行多个程序5. 以下哪个是常见的作业调度算法?A. 先来先服务(FCFS)B. 最短作业优先(SJF)C. 最高响应比优先(HRRN)D. 所有选项都是答案:D. 所有选项都是二、填空题1. 在进程调度中,使用________算法可以保证公平调度。
答案:轮转法2. 资源的死锁是指进程之间由于竞争资源而造成的________问题。
答案:互斥三、判断题1. 操作系统是必须安装在计算机上才能使用的。
()答案:错误2. 虚拟内存是操作系统提供的一种管理物理内存的技术。
()答案:正确3. 操作系统通过中断机制来处理程序的执行顺序。
()答案:正确四、简答题1. 请简要解释进程和线程的概念,并说明它们之间的区别。
答案:进程是指计算机中正在运行的程序的实例,多个进程可以同时运行,每个进程都独立分配了资源和状态。
线程是进程的一部分,它是程序执行的最小单位,一个进程可以包含多个线程,它们共享进程的资源和状态。
进程间切换开销较大,而线程间切换开销较小。
2. 请简要解释死锁的原因以及预防策略。
答案:死锁的原因通常是由于进程之间相互等待对方占用的资源,形成了一个循环等待的闭环。
预防死锁的策略包括资源分配策略、环路剥夺策略和预防策略。
资源分配策略是通过破坏死锁的四个必要条件之一(互斥、占有并等待、不可抢占、循环等待)来预防死锁。
1、在操作系统中,进程与线程的主要区别是什么?A. 进程是资源分配的基本单位,线程是处理器调度的基本单位B. 进程和线程都是资源分配和处理器调度的基本单位C. 线程是资源分配的基本单位,进程是处理器调度的基本单位D. 进程和线程都不涉及资源分配问题(答案:A)2、以下哪种调度算法可能会导致饥饿问题?A. 先来先服务(FCFS)B. 短作业优先(SJF)C. 时间片轮转(Round Robin)D. 优先级调度(非抢占式)(答案:B)3、在操作系统的存储管理中,分段存储管理方式的主要目的是?A. 提高内存利用率B. 实现内存保护C. 方便用户编程D. 提高程序运行速度(答案:C)4、关于死锁,以下哪个说法是正确的?A. 死锁是指多个进程因竞争资源而无限期等待的现象B. 死锁只可能发生在多道批处理系统中C. 死锁发生时,系统中一定存在多个进程同时处于就绪状态D. 预防死锁的方法之一是破坏“请求和保持”条件,即要求进程一次性申请所有所需资源(答案:A,注:同时D也是预防死锁的一种方法,但题目要求选择正确说法,A更直接描述了死锁的定义)5、在操作系统的文件系统中,目录结构的主要作用是?A. 实现文件的按名存取B. 提高文件存储的效率C. 增强文件系统的安全性D. 便于用户对文件进行备份(答案:A)6、下列哪一项不是虚拟内存技术的优点?A. 扩大内存容量B. 提高内存利用率C. 简化内存管理D. 加快程序运行速度(在某些情况下可能因换页开销而减慢)(答案:D)7、在操作系统的设备管理中,缓冲区的设置主要是为了?A. 提高设备利用率B. 缓和CPU与I/O设备之间速度不匹配的矛盾C. 实现设备的即插即用D. 减少I/O操作的次数(答案:B)8、关于操作系统的中断机制,以下哪个说法是错误的?A. 中断是由硬件或软件发出的,用于请求CPU处理的事件B. 中断处理过程中,CPU会暂停当前程序的执行,转而执行中断处理程序C. 中断向量表是存储中断处理程序入口地址的表D. 在所有情况下,中断处理程序的执行优先级都高于当前正在运行的程序(答案:D,注:中断处理程序的优先级通常较高,但并非在所有情况下都绝对高于所有正在运行的程序,特别是在某些实时系统中可能有更复杂的优先级策略)。
操作系统试题及答案一、选择题1. 操作系统的主要功能是什么?A. 文件管理B. 设备管理C. 内存管理D. 所有选项都是答案:D2. 进程和程序有什么区别?A. 进程是程序的执行实例B. 程序是进程的代码C. 进程是程序的存储D. 程序是进程的输出答案:A3. 在现代操作系统中,虚拟内存的作用是什么?A. 提供额外的存储空间B. 允许程序使用更多的内存C. 允许操作系统管理内存D. 允许多个程序同时运行答案:B4. 死锁的四个必要条件是什么?A. 互斥、占有和请求、不可剥夺、循环等待B. 互斥、占有和请求、可剥夺、循环等待C. 互斥、释放和请求、不可剥夺、循环等待D. 互斥、占有和请求、不可剥夺、非循环等待答案:A5. 什么是分页和分段?A. 分页是内存管理的一种技术,分段是文件管理的一种技术B. 分页是文件管理的一种技术,分段是内存管理的一种技术C. 分页和分段都是内存管理的技术D. 分页和分段都是文件管理的技术答案:C二、简答题1. 简述操作系统的五大基本功能。
答:操作系统的五大基本功能包括:进程管理、内存管理、文件系统管理、设备管理以及用户接口。
2. 解释什么是进程和线程,并说明它们之间的关系。
答:进程是程序的执行实例,是操作系统进行资源分配和调度的一个独立单位。
线程是进程中的一个实体,是CPU调度和执行的单位,一个进程可以包含多个线程。
3. 描述死锁的四个必要条件,并给出一个死锁的实例。
答:死锁的四个必要条件包括:互斥条件(资源不能被多个进程同时使用)、占有和请求条件(进程正在占有某些资源,同时请求其他资源)、不可剥夺条件(已分配给进程的资源,在未使用完之前不能被强制夺走)、循环等待条件(存在一种进程资源的循环等待关系)。
实例:银行家算法中,如果多个客户同时请求资源,且每个客户都占有一些资源,同时请求其他资源,就可能发生死锁。
三、论述题1. 论述操作系统中进程调度的几种基本算法,并比较它们的优缺点。
计算机操作系统试题及答案一、选择题1、操作系统是一种()。
A 应用软件B 系统软件C 工具软件D 调试软件答案:B操作系统是管理计算机硬件与软件资源的程序,是直接运行在“裸机”上的最基本的系统软件,任何其他软件都必须在操作系统的支持下才能运行。
2、以下不属于操作系统主要功能的是()。
A 进程管理B 存储管理C 设备管理D 文字处理答案:D操作系统的主要功能包括进程管理、存储管理、设备管理、文件管理和作业管理等。
文字处理通常是由专门的文字处理软件来完成,不是操作系统的主要功能。
3、在多道程序设计环境中,操作系统分配资源以()为基本单位。
A 程序B 进程C 作业D 指令答案:B进程是操作系统进行资源分配和调度的基本单位。
4、下列进程状态的转换中,不正确的是()。
A 就绪→运行B 运行→就绪C 运行→阻塞D 阻塞→运行答案:D进程状态的转换中,阻塞状态不能直接转换为运行状态,必须先转换为就绪状态,然后再被调度为运行状态。
5、临界区是指()。
A 一段程序B 一段数据区C 一种同步机制D 访问共享资源的程序段答案:D临界区是指访问共享资源的程序段,在这段程序中,进程可能会改变共享变量的值。
6、采用时间片轮转调度算法时,时间片过大,系统的性能将会()。
A 降低B 提高C 不变D 不确定答案:A时间片过大,会使得每个进程都能在一个时间片内完成大部分工作,导致进程切换次数减少,系统的响应时间变长,性能降低。
7、下面关于死锁的论述中,正确的是()。
A 死锁是指系统中多个进程无限期地等待永远不会发生的条件B 死锁是指系统中多个进程竞争资源而产生的一种僵持状态C 死锁是指系统中多个进程同时被阻塞,并永远无法唤醒D 死锁是指系统中多个进程相互等待对方释放资源答案:D死锁是指多个进程在运行过程中因争夺资源而造成的一种僵局,若无外力作用,这些进程都将无法向前推进,即相互等待对方释放资源。
8、以下存储管理方式中,会产生内部碎片的是()。
操作系统试题及答案一、选择题1. 操作系统的主要功能是()A. 实现计算机与外部设备的交互B. 管理计算机的硬件资源C. 控制计算机的运行流程D. 以上答案都正确答案:D2. 下列哪个不属于操作系统的基本功能()A. 进程管理B. 文件管理C. 硬件管理D. 内存管理答案:C3. 操作系统的进程是指()A. 计算机运行的一个程序B. 计算机运行的多个程序C. 计算机运行的最核心程序D. 计算机运行的最后一个程序答案:B4. 下列哪个不是进程状态()A. 运行态B. 就绪态C. 阻塞态D. 结束态答案:D5. 操作系统的调度算法是指()A. 确定进程的执行顺序B. 操作系统的启动顺序C. 进程与外设的交互顺序D. 确定进程的创建顺序答案:A二、填空题1. 操作系统内核是指()。
答案:操作系统的核心部分,负责管理计算机的硬件资源和提供基本的系统调用接口。
2. 进程的状态包括()。
答案:运行态、就绪态、阻塞态。
3. 进程调度算法的目标是()。
答案:提高系统的吞吐量、减少响应时间、提高系统的公平性。
4. 死锁是指进程()。
答案:由于竞争有限的资源而陷入无法继续执行的状态。
5. 虚拟内存是一种()。
答案:将进程的部分或全部地址空间放在磁盘上,以此扩充实际内存的技术。
三、简答题1. 请简要说明进程和线程的区别。
答案:进程是计算机运行的一个程序,包括代码、数据和运行状态等;线程是进程的一部分,是程序执行的最小单位。
一个进程可以包含多个线程,它们共享进程的资源,但拥有各自的执行路径和栈空间。
线程之间的切换开销较小,可以提高系统的并发性。
2. 简述死锁的条件以及解决死锁的方法。
答案:死锁的条件包括互斥、持有并等待、不可剥夺和循环等待。
解决死锁的方法有预防、避免、检测和恢复等。
预防死锁可以通过破坏死锁条件来实现,如破坏循环等待;避免死锁可以通过资源分配策略来避免产生死锁;检测死锁可以通过资源分配图等方法来检测死锁的发生;恢复死锁可以通过资源抢占和进程终止等方式来解除死锁。
操作系统习题(附参考答案)一、单选题(共100题,每题1分,共100分)1、下列存储器中,速度最快的是()。
A、内存B、寄存器C、CacheD、磁盘正确答案:B2、时钟中断事件属于()中断事件。
A、程序B、自愿性C、外部D、输入/输出正确答案:C3、可变分区存储管理系统中,若采用最佳适应分配算法,“空闲区表”中的空闲区可按()顺序排列。
A、大小从大到小B、大小从小到大C、地址从大到小D、地址从小到大正确答案:B4、从静态的角度看,下列选项中哪一个是进程必须拥有而程序所没有的?()A、常量数据B、全局变量C、进程控制块D、代码正文正确答案:C5、()不是管程的组成部分。
A、对局部于管程内的数据结构设置初始值的语句B、对管程内数据结构进行操作的一组过程C、局部于管程的共享数据结构D、管程外过程调用管程内数据结构的说明正确答案:D6、下列关于父进程和子进程的叙述中,正确的是()。
A、子进程执行完了,父进程才能执行B、父进程创建了子进程,因此父进程执行完了,子进程才能执行C、撤销子进程时,应该同时撤销父进程D、撤销父进程时,应该同时撤销子进程正确答案:D7、某计算机系统中有8台打印机,有K个进程竞争使用,每个进程最多需要3台打印机。
该系统可能会发生死锁的K的最小值是()。
A、3B、4C、2D、5正确答案:B8、分页虚拟存储管理系统中,若采用FIFO页面置换算法,则当分配的物理页面数增加时,缺页中断的次数()。
A、减少B、可能增加也可能减少C、增加D、不变正确答案:B9、产生内存抖动的主要原因是()。
A、内存空间太小B、CPU运行速度太慢C、CPU调度算法不合理D、页面置换算法不合理正确答案:D10、()存储管理兼顾了段式在逻辑上清晰和页式在存储管理上方便的优点。
A、分页B、段页式C、可变分区D、分段正确答案:B11、发生死锁的必要条件有四个,要预防死锁的发生,可以破坏这四个必要条件,但破坏()条件是不太实际的。
计算机操作系统练习题库一填空:1.操作系统为用户提供三种类型的使用接口,它们是命令方式和系统调用和图形用户界面。
2.主存储器与外围设备之间的数据传送控制方式有程序直接控制、中断驱动方式、DMA方式和通道控制方式。
3.在响应比最高者优先的作业调度算法中,当各个作业等待时间相同时,运行时间短的作业将得到优先调度;当各个作业要求运行的时间相同时,等待时间长的作业得到优先调度。
4.当一个进程独占处理器顺序执行时,具有两个特性:封闭性和可再现性。
5.程序经编译或汇编以后形成目标程序,其指令的顺序都是以零作为参考地址,这些地址称为逻辑地址。
6.文件的逻辑结构分流式文件和记录式文件二种。
7.进程由程度、数据和PCB组成。
8.对信号量S的操作只能通过原语操作进行,对应每一个信号量设置了一个等待队列。
9.操作系统是运行在计算机裸机系统上的最基本的系统软件。
10.虚拟设备是指采用SPOOLING技术,将某个独享设备改进为供多个用户使用的的共享设备。
11.文件系统中,用于文件的描述和控制并与文件一一对应的是文件控制块。
12.段式管理中,以段为单位,每段分配一个连续区。
由于各段长度不同,所以这些存储区的大小不一,而且同一进程的各段之间不要求连续。
13.逻辑设备表(LUT)的主要功能是实现设备独立性。
14在采用请求分页式存储管理的系统中,地址变换过程可能会因为缺页和越界等原因而产生中断。
16. 段的共享是通过共享段表实现的。
17.文件的物理结构分为顺序文件、索引文件和索引顺序文件。
18.所谓设备控制器,是一块能控制一台或多台外围设备与CPU并行工作的硬件。
19. UNIX的文件系统空闲空间的管理是采用成组链接法。
20分页管理储管理方式能使存储碎片尽可能少,而且使内存利用率较高,管理开销小。
20.计算机操作系统是方便用户、管理和控制计算机软硬件资源的系统软件。
21.操作系统目前有五大类型:批处理操作系统、分时操作系统、实时操作系统、网络操作系统和分布式操作系统。
操作系统练习试卷6(题后含答案及解析)题型有:1. 选择题选择题(每小题1分,共60分)下列各题A、B、C、D四个选项中,只有一个选项是正确的,请将正确选项涂写在答题卡相应位置上。
1.以下有关强迫性中断事件的叙述中,哪一个是不正确的? ( )A.输入输出中断是来自通道或者各种外部设备的中断,用于反映通道或设备的工作情况B.硬件故障中断是机器发生错误时产生的中断C.时钟中断是软件时钟到时而引起的中断D.程序性中断是正在运行程序中有意安排而引起的中断正确答案:D 涉及知识点:操作系统2.文件的存取方式是由文件的性质和用户使用文件的情况而确定的,一般有两种存取方式,它们是( )。
A.直接存取和间接存取B.顺序存取和随机存取C.只读存取和读写存取D.顺序存取和链接存取正确答案:B 涉及知识点:操作系统3.文件系统的多级目录结构是一种( )。
A.线性结构B.树形结构C.散列结构D.双链表结构正确答案:B 涉及知识点:操作系统4.若构成文件的基本单位是字符,这一类文件称为( )。
A.流式文件B.记录式文件C.顺序文件D.索引文件正确答案:A 涉及知识点:操作系统5.操作系统是计算机系统的一种系统软件,是配置在计算机硬件上的第一层软件,为用户与计算机硬件系统之间提供接口,同时管理着系统的( )。
A.硬件B.软件C.设备D.资源正确答案:D 涉及知识点:操作系统6.分时操作系统在系统性能方面希望达到的目标是( )。
A.高吞吐率B.充分利用内存C.及时响应D.减少系统开销正确答案:C 涉及知识点:操作系统7.CPU状态分为目态和管态两种,从目态转换到管态的惟一途径是( )。
A.运行进程修改程序状态字B.中断屏蔽C.中断D.进程调度程序正确答案:C解析:可以将CPU设置两种状态,管态是指程序执行时可使用包括特权指令在内的一切指令。
目态是指程序执行时不可使用特权指令。
目态转换为管态是依赖于中断机制,管态转换为目态可通过修改程序状态字实现。
操作系统练习题+参考答案一、单选题(共100题,每题1分,共100分)1、若系统中有5个并发进程涉及某个相同的变量A,则变量A的相关临界区由()个临界区构成。
A、1B、3C、5D、6正确答案:C2、在分页虚拟存储管理系统中,采用某些页面置换算法,会出现Belady 异常现象,即进程的缺页次数会随着分配给该进程的页面数量的增加而增加。
下列算法中,可能出现Belady现象的是()。
①LRU算法②FIFO 算法③OPT算法A、仅2B、仅1、2C、仅1、3D、仅2、3正确答案:A3、下列关于管道通信的叙述中,正确的是()。
A、一个管道可以实现双向数据传输B、管道的容量仅受磁盘容量大小的限制C、进程对管道进行读操作和写操作都可能被阻塞D、一个管道只能有一个读进程或一个写进程对其操作正确答案:C4、不属于基本操作系统的是()。
A、网络操作系统B、实时操作系统C、分时操作系统D、批处理操作系统正确答案:A5、采用SPOOLing技术的目的是()。
A、提高独占设备的利用率B、提高程序的运行速度C、提高主机的效率D、减轻用户的编程负担正确答案:A6、在()的控制下,计算机系统能及时处理由过程控制反馈的数据,并作出响应。
A、分时操作系统B、实时操作系统C、批处理操作系统D、多处理机操作系统正确答案:B7、在分页虚拟存储管理中,当发现要访问的页面不在主存时,则由硬件发出()。
A、输入输出中断B、时钟中断C、缺页中断D、越界中断正确答案:C8、()可以用来解决临界区问题。
A、时间片轮转算法B、银行家算法C、LRU算法D、Test正确答案:D9、可变分区存储管理系统中,若采用最佳适应分配算法,“空闲分区表”中的空闲区应该按()顺序排列。
A、地址从大到小B、大小从大到小C、地址从小到大D、大小从小到大正确答案:D10、进程从运行状态转换到阻塞状态可能是由于()。
A、现运行进程执行了signal操作B、现运行进程时间片用完C、现运行进程执行了wait操作D、进程调度程序的调度正确答案:C11、()不是进程的特征。
1.1 What are the three main purposes of an operating system?Answer:•To provide an environment for a computer user to execute programs on computer hardware in a convenient and efficient manner.•To allocate the separate resources of the computer as needed to solve the problem given. The allocation process should be as fair and efficient as possible.•As a control program it serves two major functions: (1) supervision of the execution of user programs to prevent errors and improper use of the computer, and (2) management of the operation and control of I/O devices.1.2 What are the main differences between operating systems for mainframe computers and personal computers?Answer: Generally, operating systems for batch systems have simpler requirements than for personal computers. Batch systems do not have to be concerned with interacting with a user as much as a personal computer. As a result, an operating system for a PC must be concerned with response time for an interactive user. Batch systems do not have such requirements. A pure batch system also may have not to handletime sharing, whereas an operating system must switch rapidly between different jobs.1.3 List the four steps that are necessary to run a program on a completely dedicated machine. Answer:a. Reserve machine time.b. Manually load program into memory.c. Load starting address and begin execution.d. Monitor and control execution of program from console.1.4 We have stressed the need for an operating system to make efficient use of the computing hardware. When is it appropriate for the operating system to forsake this principle and to “waste”resources? Why is such a system not really wasteful?Answer: Single-user systems should maximize use of the system for the user. A GUI might “waste”CPU cycles, but it optimizes the user’s interaction with the system.1.5 What is themain difficulty that a programmer must overcome in writing an operating system for a real-time environment?Answer: The main difficulty is keeping the operating system within the fixed time constraints of a real-time system. If the system does not complete a task in a certain time frame, it may cause a breakdown of the entire system it is running. Therefore when writing an operating system for a real-time system, the writer must be sure that his scheduling schemes don’t allow response time to exceed the time constraint.1.6 Consider the various definitions of operating system. Consider whether the operating system should include applications such as Web browsers And mail programs. Argue both that it should and that it should not, and support your answer.Answer: Point. Applications such as web browsers and email tools are performing an increasingly important role inmodern desktop computer systems. To fulfill this role, they should be incorporated as part of the operating system. By doing so, they can provide better performance and better integration with the rest of the system. In addition, theseimportant applications can have the same look-and-feel as the operating system software. Counterpoint. The fundamental role of the operating system is to manage system resources suchas the CPU, memory, I/O devices, etc. In addition, it’s role is to run software applications such as web browsers and email applications. By incorporating such applications into the operating system, we burden the operating system with additional functionality. Such a burden may result in the operating system performing a less-than satis factory job at managing system resources. In addition, we increase the size of the operating system thereby increasing the likelihood of system crashes and security violations.1.7 How does the distinction between kernel mode and user mode function as a rudimentary form of protection (security) system?Answer: The distinction between kernel mode and user mode provides a rudimentary form of protection in the following manner. Certain instructions could be executed only when the CPU is in kernel mode. Similarly, hardware devices could be accessed only when the programis executing in kernel mode. Control over when interrupts could be en abled or disabled is also possible only when the CPU is in kernel mode. Consequently, the CPU has very limited capability when executing in user mode, thereby enforcing protection of critical resources.1.8 Which of the following instructions should be privileged?a. Set value of timer.b. Read the clock.c. Clear memory.d. Issue a trap instruction.e. Turn off interrupts.f. Modify entries in device-status table.g. Switch from user to kernel mode.h. Access I/O device.Answer: The following operations need to be privileged: Set value of timer, clear memory, turn off interrupts, modify entries in device-status table, access I/O device. The rest can be performed in user mode.1.9 Some early computers protected the operating system by placing it in a memory partition that could not be modified by either the user job or the operating system itself. Describe two difficulties that you think could arise with such a scheme.Answer: The data required by the operating system (passwords, access controls, accounting information, and so on) would have to be stored in or passed through unprotected memory and thus be accessible to unauthorized users.1.10 Some CPU provide for more than two modes of operation. What are two possible uses of these multiple modes?Answer: Although most systems only distinguish between user and kernel modes, some CPUs have supported multiple modes. Multiple modes could be used to provide a finer-grained security policy. For example, rather than distinguishing between just user and kernel-mode,you could distinguish between different types of user mode. Perhaps users belonging to the same group could execute each other’s code. The machine would go into a specified mode when one of these users was running code. When the machine was in this mode, a member of the group could run code belonging to anyone else in the group. Another possibility would be to provide different distinctions within kernel code. For example, a specific mode could allow USB device drivers to run. This would mean that USB devices could be serviced withouthaving to switch to kernel mode, thereby essentially allowing USB device drivers to run in aquasi-user/kernel mode.1.11 Timers could be used to compute the current time. Provide a short descriptionof how this could be accomplished.Answer: A program could use the following approach to compute the current time using timer interrupts. The program could set a timer for some time in the future and go to sleep. When it is awakened by the interrupt, it could update its local state, which it is using to keep track of the number of interrupts it has received thus far. It could then repeat this process of continually setting timer interrupts and updating its local state when the interrupts are actually raised.1.12 Is the Internet a LAN or a WAN?Answer: The Internet is a WAN as the various computers are located at geographically different places and are connected by long-distance network links.2.1 What is the purpose of system calls?Answer: System calls allow user-level processes to request services of the operating system.2.2 What are the five major activities of an operating system in regard to process management? Answer:a. The creation and deletion of both user and system processesb. The suspension and resumption of processesc. The provision of mechanisms for process synchronizationd. The provision of mechanisms for process communicatione. The provision of mechanisms for deadlock handling2.3 What are the three major activities of an operating system in regard to memory management?Answer: a. Keep track of which parts of memory are currently being usedand by whom.b. Decide which processes are to be loaded into memory when memoryspace becomes available.c. Allocate and deallocate memory space as needed.2.4 What are the three major activities of an operating system in regard to secondary-storage management?Answer: •Free-space management.•Storage allocation.•Disk scheduling.2.5 What is the purpose of the command interpreter? Why is it usually separate from the kernel? Answer: It reads commands from the user or from a file of commands and executes them, usually by turning them into one or more system calls. It is usually not part of the kernel since the command interpreter is subject to changes.2.6 What system calls have to be executed by a command interpreter or shellin order to start a new process?Answer: In Unix systems, a fork system call followed by an exec systemcall need to be performed to start a new process. The fork call clones thecurrently executing process, while the exec call overlays a new processbased on a different executable over the calling process.2.7 What is the purpose of system programs?Answer: System programs can be thought of as bundles of usefulsystem calls. They provide basic functionality to users so that users donot need to write their own programs to solve common problems.2.8 What is the main advantage of the layered approach to system design? What are the disadvantages of using the layered approach?Answer: As in all cases of modular design, designing an operating system in a modular way has several advantages. The system is easierto debug and modify because changes affect only limited sections ofthe system rather than touching all sections of the operating system. Information is kept only where it is needed and is accessible only withina defined and restricted area, so any bugs affecting that data must be limited to a specific module or layer.2.9 List five services provided by an operating system. Explain how each provides convenience to the users. Explain also in which cases it wouldbe impossible for user-level programs to provide these services. Answer:a. Program execution. The operating system loads the contents (or sections) of a file into memory and begins its execution. A userlevel program could not be trusted to properly allocate CPU time.b. I/O operations. Disks, tapes, serial lines, and other devices mustbe communicated with at a very low level. The user need onlyspecify the device and the operation to perform on it, while thesystem converts that request into device- or controller-specific commands. User-level programs cannot be trusted to access only devices they should have access to and to access them only whenthey are otherwise unused.c. File-systemmanipulation. There aremany details in file creation, deletion, allocation, and naming that users should not have to perform. Blocks of disk space are used by files and must be tracked.Deleting a file requires removing the name file information andfreeing the allocated blocks. Protections must also be checked toassure proper file access. User programs could neither ensure adherence to protection methods nor be trusted to allocate only freeblocks and deallocate blocks on file deletion.d. Communications. Message passing between systems requires messages to be turned into packets of information, sent to the network controller, transmitted across a communications medium,and reassembled by the destination system. Packet ordering anddata correction must take place. Again, user programs might not coordinate access to the network device, or they might receivepackets destined for other processes.e. Error detection. Error detection occurs at both the hardware and software levels. At the hardware level, all data transfers must be inspected to ensure that data have not been corrupted in transit.All data on media must be checked to be sure they have notchanged since they were written to the media. At the softwarelevel, media must be checked for data consistency; for instance,whether the number of allocated and unallocated blocks of storagematch the total number on the device. There, errors are frequentlyprocess-independent (for instance, the corruption of data on adisk), so there must be a global program (the operating system)that handles all types of errors. Also, by having errors processedby the operating system, processes need not contain code to catchand correct all the errors possible on a system.2.10 What is the purpose of system calls?Answer: System calls allow user-level processes to request services ofthe operating system.2.11 What are the main advantages of the microkernel approach to system design?Answer: Benefits typically include the following (a) adding a newservice does not require modifying the kernel, (b) it is more secure asmore operations are done in user mode than in kernel mode, and (c)a simpler kernel design and functionality typically results in a morereliable operating system.2.12 Whydo some systems store the operating system in firmware, and others on disk?Answer: For certain devices, such as handheld PDAs and cellular telephones, a disk with a file system may be not be available for the device.In this situation, the operating system must be stored in firmware.2.13 How could a system be designed to allow a choice of operating systems to boot from? What would the bootstrap program need to do?Answer: Consider a system that would like to run both WindowsXP and three different distributions of Linux (e.g., RedHat, Debian, and Mandrake). Each operating system will be stored on disk. During system boot-up, a special program (which we will call the boot manager) will determine which operating system to boot into. This means that rather initially booting to an operating system, the boot manager will first run during system startup. It is this boot manager that is responsible for determining which system to boot into. Typically boot managers mustbe stored at certain locations of the hard disk to be recognized during system startup. Boot managers often provide the userwith a selection of systems to boot into; boot managers are also typically designed to bootinto a default operating system if no choice is selected by the user.3.1 Palm OS provides no means of concurrent processing. Discuss three major complications that concurrent processing adds to an operating system.Answer:a. A method of time sharing must be implemented to allow eachof several processes to have access to the system. This methodinvolves the preemption of processes that do not voluntarily giveup the CPU (by using a system call, for instance) and the kernelbeing reentrant (so more than one processmaybe executing kernelcode concurrently).b. Processes and system resources must have protections and mustbe protected from each other. Any given process must be limitedin the amount of memory it can use and the operations it canperform on devices like disks.c. Care must be taken in the kernel to prevent deadlocks betweenprocesses, so processes aren’t waiting for each other’s allocatedresources.3.2 The Sun UltraSPARC processor has multiple register sets. Describe theactions of a context switch if the new context is already loaded intoone of the register sets. What else must happen if the new context is inmemory rather than in a register set and all the register sets are in use?Answer: The CPU current-register-set pointer is changed to point to theset containing the new context,which takes very little time. If the contextis in memory, one of the contexts in a register set must be chosen and bemoved to memory, and the new context must be loaded from memory into the set. This process takes a little more time than on systems withone set of registers, depending on how a replacement victim is selected.3.3 When a process creates a new process using the fork() operation, whichof the following state is shared between the parent process and the childprocess?a. Stackb. Heapc. Shared memory segmentsAnswer: Only the shared memory segments are shared between theparent process and the newly forked child process. Copies of the stackand the heap are made for the newly created process.3.4 Again considering the RPC mechanism, consider the “exactly once”semantic.Does the algorithm for implementing this semantic execute correctlyeven if the “ACK”message back to the client is lost due to a networkproblem? Describe the sequence ofmessages andwhether "exactly once"is still preserved.Answer: The “exactly once”semantics ensure that a remore procedurewill be executed exactly once and only once. The general algorithm forensuring this combines an acknowledgment (ACK) scheme combinedwith timestamps (or some other incremental counter that allows theserver to distinguish between duplicate messages).The general strategy is for the client to send the RPC to the server alongwith a timestamp. The client will also start a timeout clock. The clientwill then wait for one of two occurrences: (1) it will receive an ACK fromthe server indicating that the remote procedure was performed, or (2) itwill time out. If the client times out, it assumes the server was unableto perform the remote procedure so the client invokes the RPC a second time, sending a later timestamp. The client may not receive the ACK forone of two reasons: (1) the original RPCwas never received by the server,or (2) the RPC was correctly received—and performed—by the serverbut the ACK was lost. In situation (1), the use of ACKs allows the server ultimately to receive and perform the RPC. In situation (2), the serverwill receive a duplicate RPC and it will use the timestamp to identify it as a duplicate so as not to perform the RPC a second time. It is important tonote that the server must send a second ACK back to the client to informthe client the RPC has been performed.3.5 Assume that a distributed system is susceptible to server failure. What mechanisms would be required to guarantee the “exactly once”semantics for execution of RPCs?Answer: The server should keep track in stable storage (such as adisk log) information regarding what RPC operations were received,whether they were successfully performed, and the results associatedwith the operations. When a server crash takes place and a RPC messageis received, the server can check whether the RPC had been previously performed and therefore guarantee “exactly once”semanctics for the execution of RPCs.4.1 Provide two programming examples in which multithreading provides better performance than a single-threaded solution.Answer: (1)AWeb server that services each request in a separate thread.2) (A parallelized application such as matrix multiplication where (different parts of the matrix may be worked on in parallel. (3) An (interactiveGUI program such as a debugger where a thread is used (to monitoruser input, another thread represents the running (application, and athird thread monitors performance.4.2 What are two differences between user-level threads and kernel-level threads? Under what circumstances is one type better than the other? Answer: (1) User-level threads are unknown by the kernel,whereas thekernel is aware of kernel threads. (2) On systems using either M:1 orM:N mapping, user threads are scheduled by the thread library and the kernel schedules kernel threads. (3) Kernel threads need not be associated witha processwhereas every user thread belongs to a process. Kernel threadsare generally more expensive tomaintain than user threads as they mustbe represented with a kernel data structure.4.3 Describe the actions taken by a kernel to context switch between kernellevel threads.Answer: Context switching between kernel threads typically requiressaving the value of the CPU registers fromthe thread being switched outand restoring the CPU registers of the new thread being scheduled.4.4 What resources are used when a thread is created? How do they differfrom those used when a process is created?Answer: Because a thread is smaller than a process, thread creationtypically uses fewer resources than process creation. Creating a process requires allocating a process control block (PCB), a rather large data structure.The PCB includes a memory map, list of open files, and environmentvariables. Allocating and managing the memory map is typicallythemost time-consuming activity. Creating either a user or kernel threadinvolves allocating a small data structure to hold a register set, stack, andpriority.4.5 Assume an operating system maps user-level threads to the kernel usingthe many-to-many model and the mapping is done through LWPs.Furthermore, the system allows developers to create real-time threads.Is it necessary to bind a real-time thread to an LWP? Explain.Answer: Yes. Timing is crucial to real-time applications. If a thread ismarked as real-time but is not bound to an LWP, the thread may haveto wait to be attached to an LWP before running. Consider if a real-timethread is running (is attached to an LWP) and then proceeds to block (i.e.must perform I/O, has been preempted by a higher-priority real-timethread, is waiting for a mutual exclusion lock, etc.) While the real-timethread is blocked, the LWP itwas attached to has been assigned to anotherthread. When the real-time thread has been scheduled to run again, itmust first wait to be attached to an LWP. By binding an LWP to a realtimethread you are ensuring the threadwill be able to runwithminimaldelay once it is scheduled.4.6 APthread program that performs the summation function was providedin Section 4.3.1. Rewrite this program in Java.Answer: Please refer to the supportingWeb site for source code solution.5.1 A CPU scheduling algorithm determines an order for the execution of itsscheduled processes. Given n processes to be scheduled on one processor,how many possible different schedules are there? Give a formula interms of n.Answer: n! (n factorial = n ×n –1 ×n –2 × ... ×2 ×1).5.2 Define the difference between preemptive and nonpreemptive scheduling.Answer: Preemptive scheduling allows a process to be interruptedin the midst of its execution, taking the CPU away and allocating itto another process. Nonpreemptive scheduling ensures that a processrelinquishes control of the CPU only when it finishes with its currentCPU burst.5.3 Suppose that the following processes arrive for execution at the timesindicated. Each process will run the listed amount of time. In answeringthe questions, use nonpreemptive scheduling and base all decisions onthe information you have at the time the decision must be made.Process Arrival Time Burst TimeP1 0.0 8P2 0.4 4P3 1.0 1a. What is the average turnaround time for these processes with theFCFS scheduling algorithm?b. What is the average turnaround time for these processeswith theSJF scheduling algorithm?c. The SJF algorithm is supposed to improve performance, but noticethat we chose to run process P1 at time 0 because we did not knowthat two shorter processes would arrive soon. Compute what theaverage turnaround timewill be if the CPU is left idle for the first 1unit and then SJF scheduling is used. Remember that processes P1and P2 arewaiting during this idle time, so their waiting timemayincrease. This algorithm could be known as future-knowledgescheduling.Answer:a. 10.53b. 9.53c. 6.86Remember that turnaround time is finishing time minus arrival time, soyou have to subtract the arrival times to compute the turnaround times. FCFS is 11 if you forget to subtract arrival time.5.4 What advantage is there in having different time-quantum sizes on different levels of a multilevel queueing system?Answer: Processes that need more frequent servicing, for instance, interactive processes such as editors, can be in a queue with a small time quantum. Processeswith no need for frequent servicing can be in a queuewith a larger quantum, requiring fewer context switches to complete the processing, and thus making more efficient use of the computer.5.5 Many CPU-scheduling algorithms are parameterized. For example, theRR algorithm requires a parameter to indicate the time slice. Multilevel feedback queues require parameters to define the number of queues,the scheduling algorithms for each queue, the criteria used to move processes between queues, and so on.These algorithms are thus really sets of algorithms (for example, theset of RR algorithms for all time slices, and so on). One set of algorithmsmay include another (for example, the FCFS algorithm is the RR algorithmwith an infinite time quantum).What (if any) relation holds between the following pairs of sets of algorithms?a. Priority and SJFb. Multilevel feedback queues and FCFSc. Priority and FCFSd. RR and SJFAnswer:a. The shortest job has the highest priority.b. The lowest level of MLFQ is FCFS.c. FCFS gives the highest priority to the job having been in existencethe longest.d. None.5.6 Suppose that a scheduling algorithm (at the level of short-term CPU scheduling) favors those processes that have used the least processortime in the recent past. Why will this algorithm favor I/O-bound programsand yet not permanently starve CPU-bound programs?Answer: It will favor the I/O-bound programs because of the relativelyshort CPU burst request by them; however, the CPU-bound programswill not starve because the I/O-bound programs will relinquish the CPUrelatively often to do their I/O.5.7 Distinguish between PCS and SCS scheduling.Answer: PCS scheduling is done local to the process. It is how thethread library schedules threads onto available LWPs. SCS scheduling isthe situation where the operating system schedules kernel threads. Onsystems using either many-to-one ormany-to-many, the two schedulingmodels are fundamentally different. On systems using one-to-one, PCSand SCS are the same.5.8 Assume an operating system maps user-level threads to the kernel usingthe many-to-many model where the mapping is done through the useof LWPs. Furthermore, the system allows program developers to createreal-time threads. Is it necessary to bind a real-time thread to an LWP?Answer: Yes, otherwise a user thread may have to compete for anavailable LWP prior to being actually scheduled. By binding the userthread to an LWP, there is no latency while waiting for an available LWP;the real-time user thread can be scheduled immediately.6.1 In Section 6.4 we mentioned that disabling interrupts frequently couldaffect the system’s clock. Explain why it could and how such effectscould be minimized.Answer: The system clock is updated at every clock interrupt. If interruptswere disabled—particularly for a long period of time—it ispossible the system clock could easily lose the correct time. The systemclock is also used for scheduling purposes. For example, the timequantum for a process is expressed as a number of clock ticks. At everyclock interrupt, the scheduler determines if the time quantum for thecurrently running process has expired. If clock interruptswere disabled,the scheduler could not accurately assign time quantums. This effect canbe minimized by disabling clock interrupts for only very short periods.6.2 The Cigarette-Smokers Problem. Consider a system with three smoker processes and one agent process. Each smoker continuously rolls a cigaretteand then smokes it. But to roll and smoke a cigarette, the smoker needsthree ingredients: tobacco, paper, and matches. One of the smoker processeshas paper, another has tobacco, and the third has matches. The。