操作系统精髓与设计原理第11章IO管理和磁盘调度第12章文件管理.doc

合集下载

操作系统精髓与设计原理

操作系统精髓与设计原理

操作系统精髓与设计原理在我们日常使用电脑、手机等电子设备时,操作系统是那个默默工作但又至关重要的幕后英雄。

它管理着设备的硬件资源,为我们运行的各种应用程序提供了一个稳定、高效的环境。

那么,操作系统的精髓究竟是什么?它的设计原理又包含哪些关键要素呢?要理解操作系统的精髓,首先得明白它的核心任务——资源管理。

操作系统就像是一个大管家,负责合理地分配和调度计算机的各种资源,包括处理器、内存、存储设备、输入输出设备等等。

想象一下,如果没有操作系统来协调这些资源,各个程序就会像一群没有指挥的士兵,争抢有限的资源,导致整个系统陷入混乱。

以处理器资源为例,操作系统通过进程调度算法,决定哪个程序在什么时候获得处理器的使用权。

这样可以确保每个程序都能得到公平的机会运行,同时避免某个程序长时间独占处理器而导致其他程序无法响应。

常见的进程调度算法有先来先服务、短作业优先、时间片轮转等。

这些算法根据不同的需求和场景,权衡了公平性、响应时间和系统效率等因素。

内存管理也是操作系统的重要职责之一。

它要确保程序能够安全、高效地使用内存。

操作系统通过虚拟内存技术,让程序以为自己拥有了大片连续的内存空间,实际上是在物理内存和磁盘之间进行灵活的页面交换。

这样,即使物理内存有限,也能运行大型的程序。

同时,操作系统还负责内存的分配和回收,避免内存泄漏和碎片问题。

除了资源管理,操作系统还提供了一个抽象的接口,让用户和应用程序能够更方便地与硬件进行交互。

比如,我们不需要了解磁盘的具体读写机制,只需要通过操作系统提供的文件系统来进行文件的创建、读取和删除操作。

这种抽象化大大降低了使用计算机的难度,提高了开发效率。

在操作系统的设计原理中,并发和并行是两个关键概念。

并发是指多个程序在同一时间段内交替执行,而并行则是指多个程序在同一时刻同时执行。

操作系统通过进程和线程机制来实现并发和并行。

进程是程序的一次执行过程,而线程是进程中的执行单元。

通过合理地创建和管理进程和线程,操作系统能够充分利用多核处理器的优势,提高系统的性能。

操作系统原理与设计

操作系统原理与设计

操作系统原理与设计操作系统是计算机系统中的核心软件之一,负责协调和管理硬件资源,为用户提供良好的使用体验。

操作系统的原理与设计是其开发与实现的基础,本文将对操作系统的原理与设计进行探讨。

一、操作系统的基本原理操作系统的基本原理可以归纳为以下几个方面:进程管理、存储管理、文件系统和输入输出管理。

通过合理地实现这些原理,操作系统能够有效地管理计算机系统的各个方面。

1. 进程管理进程是指计算机中正在运行的程序的实例。

操作系统通过进程管理来分配和控制计算机系统的资源,如CPU时间、内存空间和外部设备等。

它负责进程的创建、调度和终止,保障各个进程的正常运行,避免资源的竞争和冲突。

2. 存储管理存储管理是操作系统中的重要部分,它负责管理计算机系统的内存空间。

操作系统通过内存管理来为进程分配内存区域,并进行地址转换。

此外,存储管理还负责内存的分配与回收,以充分利用有限的内存资源。

3. 文件系统文件系统是操作系统中用于管理磁盘存储器上的文件和文件夹的机制。

它提供了文件的创建、读取、写入和删除等操作,使用户能够方便地操作文件。

文件系统还负责文件的存储空间分配和数据的存储安排。

4. 输入输出管理输入输出管理是操作系统中的关键部分,它负责管理计算机系统与外部设备的数据交换。

操作系统通过输入输出管理来协调计算机系统与外部设备的通信,提供高效的输入输出服务,为用户提供良好的使用体验。

二、操作系统的设计操作系统的设计需要考虑多个方面,如兼容性、可扩展性、可靠性和安全性等。

以下是操作系统设计的几个重要方面,包括系统结构、调度算法以及用户界面。

1. 系统结构操作系统的设计可以采用不同的系统结构,如单体系统、层次系统和客户-服务器系统等。

不同的系统结构对操作系统设计的灵活性和性能有所影响,需要根据具体需求进行选择。

2. 调度算法调度算法决定了进程如何被分配CPU时间。

操作系统的设计需要选择适当的调度算法,以提高系统的吞吐量和响应时间。

原版的操作系统_精髓与设计原理_第5版Chapter12

原版的操作系统_精髓与设计原理_第5版Chapter12

File ManagementChapter 12Chapter121File ManagementFile Management•File management system consists of Fil i f system utility programs that run as privileged applications•Input to applications is by means of a Input to applications is by means of a file•Output is saved in a file for long-term storage g2File System PropertiesFile System Properties •Long-term existenceL ip•Sharable between processes •Structure3File OperationsFile Operations •CreateC•Delete•Open•Close•Read•Write4Terms Used with FilesTerms Used with Files •FieldFi ld–Basic element of data–Contains a single value–Characterized by its length and data typeCharacterized by its length and data type •Record–Collection of related fields–Treated as a unit•Example: employee record5Terms Used with FilesTerms Used with Files •FileFil–Collection of similar records–Treated as a single entity–Have file namesHave file names–May restrict access•Database–Collection of related data–Relationships exist among elements6Typical OperationsTypical Operations •Retrieve_AllR t i All•Retrieve_One•Retrieve_Next•Retrieve_PreviousRetrieve Previous•Insert_One•Delete_One•Update Onep_•Retrieve_Few7File Management Systems File Management Systems •The way a user of application mayTh f li iaccess files•Programmer does not need to develop file management softwarefile management software8File Management System•Meet the data management needs and M h d d d requirements of the user•Guarantee that the data in the file are valid•Optimize performance•Provide I/O support for a variety of storage device typesstorage device types9File Management System•Minimize or eliminate the potential for Mi i i li i h i l f lost or destroyed data•Provide a standardized set of I/O interface routinesinterface routines•Provide I/O support for multiple users10Minimal Set of Requirements Minimal Set of Requirements •Each user should be able to create,E h h ld b bl t t delete, read, write and modify files•Each user may have controlled access to other users’ files•Each user may control what type of accesses are allowed to the users’files accesses are allowed to the users files•Each user should be able to restructure the user s files in a form appropriate to the user’s files in a form appropriate tothe problem11Minimal Set of Requirements Minimal Set of Requirements •Each user should be able to move data E h h ld b bl dbetween files•Each user should be able to back up andrecover the user s files in case of recover the user’s files in case ofdamage•Each user should be able to access they g yuser’s files by using symbolic names1213Device DriversDevice Drivers •Lowest levelL l ly p p •Communicates directly with peripheral devices•Responsible for starting I/O operations R ibl f t ti I/O tion a device•Processes the completion of an I/O request14Basic File SystemBasic File System •Physical I/OPh i l I/Og g•Deals with exchanging blocks of data •Concerned with the placement of blocks •Concerned with buffering blocks in main memory y15Basic I/O SupervisorBasic I/O Supervisor •Responsible for file I/O initiation and R ibl f fil I/O i i i i d termination•Control structures are maintained •Concerned with selection of the device C d ith l ti f th d i on which file I/O is to be performed •Concerned with scheduling access to optimize performanceoptimize performance•Part of the operating system16Logical I/OLogical I/O•Enables users and applications to access E bl d li irecords•Provides general-purpose record I/O capability•Maintains basic data about file17Access MethodAccess Method •Reflect different file structuresR fl diff fily p •Different ways to access and process data1819File Management Functions File Management Functions •Identify and locate a selected fileId if d l l d fily•Use a directory to describe the location of all files plus their attributes•On a shared system describe user access O h d t d ibcontrol•Blocking for access to files•Allocate files to free blocksAllocate files to free blocks •Manage free storage for available blocks20Criteria for File Organization Criteria for File Organization •Short access timeSh i–Needed when accessing a single record–Not needed for batch mode•Ease of updateEase of update–File on CD-ROM will not be updated, so hi ithis is not a concern21Criteria for File Organization Criteria for File Organization •Economy of storageE f–Should be minimum redundancy in the data –Redundancy can be used to speed accesssuc s desuch as an index•Simple maintenance•Reliability22File OrganizationFile Organization•The PileTh Pil–Data are collected in the order they arrive–Purpose is to accumulate a mass of data ands vesave it–Records may have different fields–No structureNo str ct re–Record access is by exhaustive search23Pile24File OrganizationFile Organization•The Sequential FileTh S i l Fil–Fixed format used for records–Records are the same length–All fields the same (order and length)All fields the same(order and length)–Field names and lengths are attributes of thefile–One field is the key filed•Uniquely identifies the record•Records are stored in key sequence25File OrganizationFile Organization•The Sequential FileTh S i l Fil–New records are placed in a log file ortransaction filec upde s pe o ed o e ge e og–Batch update is performed to merge the logfile with the master file26Sequential File Sequential File27File OrganizationFile Organization •Indexed Sequential FileI d d S i l Fil–Index provides a lookup capability toquickly reach the vicinity of the desiredrecord•Contains key field and a pointer to the main fileg y•Indexed is searched to find highest key valuethat is equal to or precedes the desired key value•Search continues in the main file at the locationindicated by the pointer28File OrganizationFile Organization •Comparison of sequential and indexed C i f i l d i d d sequential–Example: a file contains 1 million recordsOn average 500,00 accesses are required to –On average50000accesses are required tofind a record in a sequential file–If an index contains 1000 entries, it willIf an index contains1000entries it willtake on average 500 accesses to find thekey followed by500accesses in the mainkey, followed by 500 accesses in the mainfile. Now on average it is 1000 accesses29File OrganizationFile Organization •Indexed Sequential FileI d d S i l Fil–New records are added to an overflow file–Record in main file that precedes it isupd ed o co po e o e ewupdated to contain a pointer to the newrecordThe overflow is merged with the main file –The overflow is merged with the main fileduring a batch updateM ltiple inde es for the same ke field can –Multiple indexes for the same key field canbe set up to increase efficiency30Indexed Sequential File Indexed Sequential File31File OrganizationFile Organization •Indexed FileI d d Fil–Uses multiple indexes for different keyfieldsy co e us ve de–May contain an exhaustive index thatcontains one entry for every record in themain file–May contain a partial index32Indexed File Indexed File33File OrganizationFile Organization•The Direct or Hashed FileTh Di H h d Fil–Directly access a block at a known address –Key field required for each record3435File DirectoriesFile Directories •Contains information about filesC i i f i b fil–Attributes–Location–Ownership•Directory itself is a file owned by the operating systemProvides mapping between file names •Provides mapping between file names and the files themselves36Simple Structure for aDirectory•List of entries, one for each fileLi f i f h filq•Sequential file with the name of the file serving as the key•Provides no help in organizing the files P id h l i i i th fil •Forces user to be careful not to use the same name for two different files37383940Two-level Scheme for aDirectory•One directory for each user and a masterO di t f h d t directory•Master directory contains entry for each user –Provides address and access control information •Each user directory is a simple list of files for that user•Still provides no help in structuring collections of filesof files41Hierarchical, or Tree-Structured Directory•Master directory with user directories M di i h di i underneath it•Each user directory may have subdirectories and files as entries subdirectories and files as entries424344Structured Directory •Files can be located by following a path Fil b l d b f ll i hfrom the root, or master, directory downvarious branchesThis is the pathname for the file–This is the pathname for the file•Can have several files with the same filename as long as they have unique pathl th h i thnames45Structured Directory •Current directory is the workingC di i h ki directory•Files are referenced relative to the working directoryworking directory46File SharingFile Sharing•In multiuser system, allow files to be I l i ll fil b shared among users•Two issues–Access rightsAccess rights–Management of simultaneous access47Access RightsAccess Rights•NoneN–User may not know of the existence of thefileUse s o owed o e d e use–User is not allowed to read the userdirectory that includes the file •Knowledge–User can only determine that the file existsd h i iand who its owner is48Access RightsAccess Rights •ExecutionE i–The user can load and execute a programbut cannot copy it•Reading–The user can read the file for any purpose,including copying and executionincluding copying and execution •Appending–The user can add data to the file but cannotmodify or delete any of the file’s contentsy y49Access RightsAccess Rights •UpdatingU d ti–The user can modify, deleted, and add to thefile’s data. This includes creating the file,fil’d t Thi i l d ti th filrewriting it, and removing all or part of thedata•Changing protection–User can change access rights granted toother users•Deletion–User can delete the file50。

《操作系统精髓与设计原理·第五版》习题答案

《操作系统精髓与设计原理·第五版》习题答案

第1章计算机系统概述1.1、图1.3中的理想机器还有两条I/O指令:0011 = 从I/O中载入AC0111 = 把AC保存到I/O中在这种情况下,12位地址标识一个特殊的外部设备。

请给出以下程序的执行过程(按照图1.4的格式):1.从设备5中载入AC。

2.加上存储器单元940的内容。

3.把AC保存到设备6中。

假设从设备5中取到的下一个值为3940单元中的值为2。

答案:存储器(16进制内容):300:3005;301:5940;302:7006步骤1:3005->IR;步骤2:3->AC步骤3:5940->IR;步骤4:3+2=5->AC步骤5:7006->IR:步骤6:AC->设备61.2、本章中用6步来描述图1.4中的程序执行情况,请使用MAR和MBR扩充这个描述。

答案:1. a. PC中包含第一条指令的地址300,该指令的内容被送入MAR中。

b. 地址为300的指令的内容(值为十六进制数1940)被送入MBR,并且PC增1。

这两个步骤是并行完成的。

c. MBR中的值被送入指令寄存器IR中。

2. a. 指令寄存器IR中的地址部分(940)被送入MAR中。

b. 地址940中的值被送入MBR中。

c. MBR中的值被送入AC中。

3. a. PC中的值(301)被送入MAR中。

b. 地址为301的指令的内容(值为十六进制数5941)被送入MBR,并且PC增1。

c. MBR中的值被送入指令寄存器IR中。

4. a. 指令寄存器IR中的地址部分(941)被送入MAR中。

b. 地址941中的值被送入MBR中。

c. AC中以前的内容和地址为941的存储单元中的内容相加,结果保存到AC中。

5. a. PC中的值(302)被送入MAR中。

b. 地址为302的指令的内容(值为十六进制数2941)被送入MBR,并且PC增1。

c. MBR中的值被送入指令寄存器IR中。

6. a. 指令寄存器IR中的地址部分(941)被送入MAR中。

《操作系统精髓与设计原理·第八版》中文版

《操作系统精髓与设计原理·第八版》中文版

操作系统精髓与设计原理·第八版中文版导言《操作系统精髓与设计原理·第八版》是一本经典的操作系统教材,详细介绍了操作系统的核心概念、基础算法和设计原理。

本文将对这本书进行简要的介绍,并概述其中涵盖的一些重要主题。

操作系统的重要性操作系统是计算机系统的核心组成部分,它负责管理计算机的硬件和软件资源,为用户和应用程序提供接口和服务。

操作系统的设计和实现对于计算机系统的性能、可靠性和安全性都具有重要影响。

书籍概览《操作系统精髓与设计原理·第八版》由Abraham Silberschatz、Peter B. Galvin和Greg Gagne合著。

本书分为六个部分,共计十五章。

第一部分:引论第一部分主要介绍操作系统的基本概念和演化历史。

内容包括操作系统的定义和功能、计算机系统结构、进程和线程、CPU调度等。

第二部分:进程管理第二部分着重介绍进程管理的相关概念和技术,包括进程状态、进程调度、死锁等内容。

此外,还介绍了多线程编程和并发控制的原理。

第三部分:存储管理第三部分讲解了内存管理的相关知识,包括虚拟内存、页面置换算法、分段和分页等。

此外,还介绍了文件系统的设计原理和实现。

第四部分:设备管理第四部分详细介绍了设备管理的概念和技术,包括IO系统、磁盘调度算法和文件系统等内容。

此外,还介绍了RAID技术和磁盘存储管理。

第五部分:文件系统第五部分主要是对文件系统的深入介绍和讨论,包括文件系统的组织结构、文件描述符、文件访问控制等内容。

此外,还介绍了分布式文件系统和虚拟文件系统。

第六部分:安全和保护第六部分探讨了操作系统的安全和保护机制,包括安全性概念、加密技术、防御和攻击等内容。

此外,还介绍了操作系统的审计和审计安全等相关主题。

关键主题概述进程管理进程管理是操作系统的核心功能之一。

本书介绍了进程的状态和转换、进程调度算法、进程同步与通信、死锁以及多线程编程。

深入理解进程管理的原理和技术,可以帮助开发者编写高效、可靠的并发程序。

操作系统精髓与设计原理-第11章-IO管理和磁盘调度-第12章-文件管理

操作系统精髓与设计原理-第11章-IO管理和磁盘调度-第12章-文件管理

第十一章 I/O管理和磁盘调度复习题11.1列出并简单定义执行I/O的三种技术。

·可编程I/O:处理器代表进程给I/O模块发送给一个I/O命令,该进程进入忙等待,等待操作的完成,然后才可以继续执行。

·中断驱动I/O:处理器代表进程向I/O模块发送一个I/O命令,然后继续执行后续指令,当I/O模块完成工作后,处理器被该模块中断。

如果该进程不需要等待I/O完成,则后续指令可以仍是该进程中的指令,否则,该进程在这个中断上被挂起,处理器执行其他工作。

·直接存储器访问(DMA):一个DMA模块控制主存和I/O模块之间的数据交换。

为传送一块数据,处理器给DMA模块发送请求,只有当整个数据块传送完成后,处理器才被中断。

11.2逻辑I/O和设备I/O有什么区别?·逻辑I/O:逻辑I/O模块把设备当作一个逻辑资源来处理,它并不关心实际控制设备的细节。

逻辑I/O模块代表用户进程管理的一般I/O功能,允许它们根据设备标识符以及诸如打开、关闭、读、写之类的简单命令与设备打交道。

·设备I/O:请求的操作和数据(缓冲的数据、记录等)被转换成适当的I/O指令序列、通道命令和控制器命令。

可以使用缓冲技术,以提高使用率。

11.3面向块的设备和面向流的设备有什么区别?请举例说明。

面向块的设备将信息保存在块中,块的大小通常是固定的,传输过程中一次传送一块。

通常可以通过块号访问数据。

磁盘和磁带都是面向块的设备。

面向流的设备以字节流的方式输入输出数据,其末使用块结构。

终端、打印机通信端口、鼠标和其他指示设备以及大多数非辅存的其他设备,都属于面向流的设备。

11.4为什么希望用双缓冲区而不是单缓冲区来提高I/O的性能?双缓冲允许两个操作并行处理,而不是依次处理。

典型的,在一个进程往一个缓冲区中传送数据(从这个缓冲区中取数据)的同时,操作系统正在清空(或者填充)另一个缓冲区。

11.5在磁盘读或写时有哪些延迟因素?寻道时间,旋转延迟,传送时间11.6简单定义图11.7中描述的磁盘调度策略。

操作系统精髓与设计原理第五版习题与答案

第1章计算机系统概述1.1 列出并简要地定义计算机的四个主要组成部分。

主存储器,存储数据和程序;算术逻辑单元,能处理二进制数据;控制单元,解读存储器中的指令并且使他们得到执行;输入/输出设备,由控制单元管理。

1.2 定义处理器寄存器的两种主要类别。

用户可见寄存器:优先使用这些寄存器,可以使机器语言或者汇编语言的程序员减少对主存储器的访问次数。

对高级语言而言,由优化编译器负责决定把哪些变量应该分配给主存储器。

一些高级语言,如C语言,允许程序言建议编译器把哪些变量保存在寄存器中。

控制和状态寄存器:用以控制处理器的操作,且主要被具有特权的操作系统例程使用,以控制程序的执行。

1.3 一般而言,一条机器指令能指定的四种不同操作是什么?处理器-寄存器:数据可以从处理器传送到存储器,或者从存储器传送到处理器。

处理器-I/O:通过处理器和I/O模块间的数据传送,数据可以输出到外部设备,或者从外部设备输入数据。

数据处理:处理器可以执行很多关于数据的算术操作或逻辑操作。

控制:某些指令可以改变执行顺序。

1.4 什么是中断?中断:其他模块(I/O,存储器)中断处理器正常处理过程的机制。

1.5 多中断的处理方式是什么?处理多中断有两种方法。

第一种方法是当正在处理一个中断时,禁止再发生中断。

第二种方法是定义中断优先级,允许高优先级的中断打断低优先级的中断处理器的运行。

1.6 存层次的各个元素间的特征是什么?存储器的三个重要特性是:价格,容量和访问时间。

1.7 什么是高速缓冲存储器?高速缓冲存储器是比主存小而快的存储器,用以协调主存跟处理器,作为最近储存地址的缓冲区。

1.8 列出并简要地定义I/O操作的三种技术。

可编程I/O:当处理器正在执行程序并遇到与I/O相关的指令时,它给相应的I/O模块发布命令(用以执行这个指令);在进一步的动作之前,处理器处于繁忙的等待中,直到该操作已经完成。

中断驱动I/O:当处理器正在执行程序并遇到与I/O相关的指令时,它给相应的I/O模块发布命令,并继续执行后续指令,直到后者完成,它将被I/O 模块中断。

操作系统的原理与设计

操作系统的原理与设计操作系统是计算机系统中最为核心的软件之一,它承担着管理计算机硬件资源和提供用户与计算机之间的接口的重要任务。

本文将介绍操作系统的原理与设计,并探讨其在计算机系统中的作用。

一、操作系统的定义和功能操作系统是一种控制和管理计算机硬件和软件资源的系统软件。

它在计算机系统中起到了多个重要功能,包括:1. 资源管理:操作系统负责管理计算机的硬件资源,如中央处理器(CPU)、内存、磁盘、网络等,以提供给用户和应用程序使用。

它通过分配资源、调度任务和控制访问等方式,实现资源的高效利用。

2. 进程管理:操作系统将任务划分为多个进程,并负责进程的创建、调度和终止等操作。

它确保各个进程按照一定的优先级和调度算法有序地执行,实现多任务的并发执行。

3. 内存管理:操作系统负责管理计算机的内存空间,包括内存分配和回收、内存保护和虚拟内存等功能。

它确保不同进程之间的内存空间隔离,并在有限的内存资源下提供更大的地址空间。

4. 文件系统:操作系统将硬盘等存储介质组织为文件系统,实现对文件的管理和存取。

它提供了文件的逻辑结构和物理结构的映射,确保用户和应用程序能够方便地读写文件。

5. 设备管理:操作系统管理计算机的各种输入输出设备,包括键盘、鼠标、打印机、显示器等。

它负责设备的分配、调度和控制,以确保设备的高效使用和用户程序的正确运行。

二、操作系统的设计原理操作系统的设计需要考虑多个方面的因素,包括:1. 封装:操作系统通过封装底层硬件和软件资源,提供简洁的接口供用户和应用程序使用。

这种封装能够隐藏底层的复杂性,提高系统的易用性和可维护性。

2. 中断处理:操作系统需要能够及时响应硬件设备的中断请求,并进行适当的处理。

中断处理机制可以保证不同设备之间的并发性,提高计算机系统的响应速度。

3. 进程管理:操作系统采用进程管理机制将任务划分为多个进程,并通过调度算法实现进程的有序执行。

这种机制能够提高计算机系统的并发性和吞吐量。

《操作系统原理》习题库及参考答案05文件管理

第5章文件管理习题一、填空1.一个文件的文件名是在时给出的。

2.所谓“文件系统”,由与文件管理有关的、被管理的文件以及管理所需要的数据结构三部分组成。

3.是辅助存储器与内存之间进行信息传输的单位。

4.在用位示图管理磁盘存储空间时,位示图的尺寸由磁盘的决定。

5.采用空闲区表法管理磁盘存储空间,类似于存储管理中采用方法管理内存储器。

6.操作系统是通过感知一个文件的存在的。

7.按用户对文件的存取权限将用户分成若干组,规定每一组用户对文件的访问权限。

这样,所有用户组存取权限的集合称为该文件的。

8.根据在辅存上的不同存储方式,文件可以有顺序、和索引三种不同的物理结构。

9.如果把文件视为有序的字符集合,在其内部不再对信息进行组织划分,那么这种文件的逻辑结构被称为“”。

10.如果用户把文件信息划分成一个个记录,存取时以记录为单位进行,那么这种文件的逻辑结构称为“”。

11. 操作系统应该提供一个环境,保证信息使用的私密和共享,这是系统的安全问题;另一方面,操作系统还需要提供各种手段,防止来自各方的有意或无意的入侵和攻击,这是系统的安全问题。

12. “文件备份”的含义,就是为系统中的文件建立相应的副本。

它通常有两种方法,一是所谓的“转储”,一是所谓的“转储”。

13. 用户总是从使用的角度出发去组织文件,系统则总是从的角度出发去组织文件的。

14. 在记录式文件中,总要有一个数据项能够唯一地标识记录,以便对记录加以区分。

文件中的这种数据项被称为或。

二、选择1.下面的不是文件的存储结构。

A.索引文件B.记录式文件C.串联文件D.连续文件2.有一磁盘,共有10个柱面,每个柱面20个磁道,每个盘面分成16个扇区。

采用位示图对其存储空间进行管理。

如果字长是16个二进制位,那么位示图共需字。

A.200 B.128 C.256 D.1003.操作系统为每一个文件开辟一个存储区,在它的里面记录着该文件的有关信息。

这就是所谓的。

A.进程控制块B.文件控制块C.设备控制块D.作业控制块4.文件控制块的英文缩写符号是。

操作系统一精髓与设计原理第五版选择题与答案英文版第一到第十一章

操作系统一精髓与设计原理第五版选择题与答案英文版第一到第十一章第一章The general role of an operating system is to: da. None of the aboveb. Manage files for application programsc. Act as an interface between various computersd. Provide a set of services to system usersInformation that must be saved prior to the processor transferring control to theinterrupt handler routine includes:ba. None of the aboveb. Processor Status Word (PSW) & Location of next instructionc. Processor Status Word (PSW)d. Processor Status Word (PSW) & Contents of processor registersOne accepted method of dealing with multiple interrupts is to: 选择一个答案aa. Define priorities for the interruptsb. None of the abovec. Disable all interrupts except those of highest priorityd. Service them in round-robin fashionIn a uniprocessor system, multiprogramming increases processor efficiencyby:选择一个答案da. Increasing processor speedb. Eliminating all idle processor cyclesc. All of the aboved. Taking advantage of time wasted by long wait interrupt handlingAs one proceeds down the memory hierarchy (i.e., from inboard memory to offlinestorage), the following condition(s) apply: c选择一个答案a. Decreasing capacityb. Increasing cost per bitc. Increasing access timed. All of the aboveSmall, fast memory located between the processor and main memory is called 选择一个答案ba. None of the aboveb. Cache memoryc. WORM memoryd. CD-RW memoryWhen a new block of data is written into cache memory, the following determines whichcache location the block will occupy: 选择一个答案aa. None of the aboveb. Write policyc. Cache sized. Block sizeThe four main structural elements of a computer system are:选择一个答案ba. Processor, Registers, I/O Modules & Main Memoryb. Processor, Main Memory, I/O Modules & System Busc. None of the aboved. Processor, Registers, Main Memory & System BusThe two basic types of processor registers are:选择一个答案aa. User-visible and Control/Status registersb. User-visible and user-invisible registersc. None of the aboved. Control and Status registersAddress registers may contain选择一个答案ca. Memory addresses of datab. Memory addresses of instructionsc. All of the aboved. Partial memory addressesA Control/Status register that contains the address of the next instruction to be fetched iscalled the:选择一个答案ca. All of the aboveb. Program Status Word (PSW)c. Program Counter (PC)d. Instruction Register (IR)The two basic steps used by the processor in instruction processing are:选择一个答案ca. Instruction and Execute cyclesb. Fetch and Instruction cyclesc. Fetch and Execute cyclesd. None of the aboveA fetched instruction is normally loaded into the:选择一个答案ca. Program Counter (PC)b. None of the abovec. Instruction Register (IR)d. Accumulator (AC)A common class of interrupts is选择一个答案da. Programb. I/Oc. Timerd. All of the aboveWhen an external device becomes ready to be serviced by the processor, the devicesends this type of signal to the processor:选择一个答案ba. None of the aboveb. Interrupt signalc. Halt signald. Handler signal第二章A primary objective of an operating system is:选择一个答案aa. All of the aboveb. Conveniencec. Ability to evolved. EfficiencyThe paging system in a memory management system provides for dynamic mappingbetween a virtual address used in a program and:选择一个答案aa. A real address in main memoryb. None of the abovec. A virtual address in main memoryd. A real address in a programRelative to information protection and security in computer systems, accesscontrol typically refers to:选择一个答案da. Proving that security mechanisms perform according to specificationb. None of the abovec. The flow of data within the systemd. Regulating user and process access to various aspects of the systemA common problem with full-featured operating systems, due to their size anddifficulty of the tasks they address, is:选择一个答案da. Latent bugs that show up in the fieldb. Chronically late in deliveryc. Sub-par performanced. All of the aboveA technique in which a process, executing an application, is divided intothreads that can run concurrently is called:选择一个答案da. None of the aboveb. Symmetric multiprocessing (SMP)c. Multiprocessingd. MultithreadingWIN2K supports several types of user applications, including: 选择一个答案ca. None of the aboveb. Linuxc. WIN32d. System 10Key to the success of Linux has been it’s character as a free software packageavailable under the auspices of the:选择一个答案ca. None of the aboveb. Berkeley Software Distributionc. Free Software Foundationd. World Wide Web ConsortiumThe operating system provides many types of services to end-users, programmers andsystem designers, including:选择一个答案ba. Built-in user applicationsb. Error detection and responsec. All of the aboved. Relational database capabilities with the internal file systemThe operating system is unusual in it’s role as a control mechanism, in that:选择一个答案ca. None of the aboveb. It runs on a special processor, completely separated from therest of thesystemc. It frequently relinquishes control of the system processor and mustdepend on the processor to regain control of the systemd. It never relinquishes control of the system processorOperating systems must evolve over time because选择一个答案aa. New hardware is designed and implemented in the computer systemb. Hardware must be replaced when it failsc. All of the aboved. Users will only purchase software that has a current copyright dateA major problem with early serial processing systems was:选择一个答案aa. Setup timeb. Inability to get hardcopy outputc. All of the aboved. Lack of input devicesAn example of a hardware feature that is desirable in a batch-processingsystem is选择一个答案aa. Privileged instructionsb. None of the abovec. A completely accessible memory aread. Large clock cyclesA computer hardware feature that is vital to the effective operation of a multiprogrammingoperating system is:选择一个答案ba. All of the aboveb. I/O interrupts and DMAc. Very large memoryd. Multiple processorsThe principle objective of a time sharing, multiprogramming system is to 选择一个答案ca. Maximize processor useb. Maximize response timec. None of the aboved. Provide exclusive access to hardwareWhich of the following major line of computer system development created problems intiming and synchronization that contributed to the development of the concept of theprocess?选择一个答案ca. Multiprogramming batch operation systemsb. Real time transaction systemsc. All of the aboved. Time sharing systems第三章The behavior of a processor can be characterized by examining: 选择一个答案ba. Multiple process tracesb. The interleaving of the process tracesc. All of the aboved. A single process traceThe Process Image element that contains the modifiable part of the user space is calledthe:a进程镜像=PCB+程序+STACK+可修改的DATAa. None of the aboveb. Process Control Blockc. System Stackd. User Program分数: 7/7The processor execution mode that user programs typically execute in is referred to as:a选择一个答案a. User modeb. None of the abovec. Kernel moded. System modeOne step in the procedure for creating a new process involves:步骤:b选择一个答案a. Allocating space for the processb. All of the abovec. Initializing the process control blockd. Assigning a unique identifierA process switch may occur when the system encounters an interruptcondition, such as that generated by a: 进程切换:TRAP(异常)+系统调用 +INTERRUPT选择一个答案ca. Trapb. Supervisor callc. All of the aboved. Memory fault##操作系统仅仅是一组程序,并被处理器执行,是进程吗,如何控制它, 。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

第十一章 I/O管理和磁盘调度复习题11.1列出并简单定义执行I/O的三种技术。

·可编程I/O:处理器代表进程给I/O模块发送给一个I/O命令,该进程进入忙等待,等待操作的完成,然后才可以继续执行。

·中断驱动I/O:处理器代表进程向I/O模块发送一个I/O命令,然后继续执行后续指令,当I/O模块完成工作后,处理器被该模块中断。

如果该进程不需要等待I/O完成,则后续指令可以仍是该进程中的指令,否则,该进程在这个中断上被挂起,处理器执行其他工作。

·直接存储器访问(DMA):一个DMA模块控制主存和I/O模块之间的数据交换。

为传送一块数据,处理器给DMA模块发送请求,只有当整个数据块传送完成后,处理器才被中断。

11.2逻辑I/O和设备I/O有什么区别?·逻辑I/O:逻辑I/O模块把设备当作一个逻辑资源来处理,它并不关心实际控制设备的细节。

逻辑I/O模块代表用户进程管理的一般I/O功能,允许它们根据设备标识符以及诸如打开、关闭、读、写之类的简单命令与设备打交道。

·设备I/O:请求的操作和数据(缓冲的数据、记录等)被转换成适当的I/O指令序列、通道命令和控制器命令。

可以使用缓冲技术,以提高使用率。

11.3面向块的设备和面向流的设备有什么区别?请举例说明。

面向块的设备将信息保存在块中,块的大小通常是固定的,传输过程中一次传送一块。

通常可以通过块号访问数据。

磁盘和磁带都是面向块的设备。

面向流的设备以字节流的方式输入输出数据,其末使用块结构。

终端、打印机通信端口、鼠标和其他指示设备以及大多数非辅存的其他设备,都属于面向流的设备。

11.4为什么希望用双缓冲区而不是单缓冲区来提高I/O的性能?双缓冲允许两个操作并行处理,而不是依次处理。

典型的,在一个进程往一个缓冲区中传送数据(从这个缓冲区中取数据)的同时,操作系统正在清空(或者填充)另一个缓冲区。

11.5在磁盘读或写时有哪些延迟因素?寻道时间,旋转延迟,传送时间11.6简单定义图11.7中描述的磁盘调度策略。

FIFO:按照先来先服务的顺序处理队列中的项目。

SSTF:选择使磁头臂从当前位置开始移动最少的磁盘I/O请求。

SCAN:磁头臂仅仅沿一个方向移动,并在途中满足所有未完成的请求,直到它到达这个方向上最后一个磁道,或者在这个方向上没有其他请求为止。

接着反转服务方向,沿相反方向扫描,同样按顺序完成所有请求。

C-SCAN:类似于SCAN,11.7简单定义图7层RAID。

0:非冗余1:被镜像;每个磁盘都有一个包含相同数据的镜像磁盘。

2:通过汉明码实现冗余;对每个数据磁盘中的相应都计算一个错误校正码,并且这个码位保存在多个奇偶校验磁盘中相应的文件。

3:交错位奇偶校验;类似于第二层,不同之处在于RAID3为所有数据磁盘中同一位置的位的集合计算一个简单的奇偶校验位,而不是错误校正码。

4:交错块分布奇偶校验;对每个数据磁盘中相应的条带计算一个逐位奇偶。

5:交错块分布奇偶校验;类似于第四层,但把奇偶校验条带分布在所有磁盘中。

6:交错块双重分布奇偶校验;两种不同的奇偶校验计算保存在不同磁盘的不同块中。

11.8典型的磁盘扇区大小是多少?512比特习题11.1考虑一个程序访问一个I/O设备,并比较无缓冲的I/O和使用缓冲区的I/O。

说明使用缓冲区最多可以减少2倍的运行时间。

如果计算的时间正好等于它的I/O时间(它是最佳环境),操作者和外围设备同时运行。

如果单独运行,只要花费他们的一半时间,设C是整个程序的计算时间,T为所要求总的I/O时间,因而寄存器最好的运行时间是max(C,T),不需要寄存器的运行时间是C+T,显然((C+T)/2)≤max(C,T)≤(C+T).11.2把习题11.1的结论推广到访问n个设备的程序中。

最佳比是(n+1)﹕n11.3使用与表11.2类似的方式,分析下列磁道请求:27,129,110,186,147,41,10,64,120。

假设磁头最初定位在磁道100处,并且沿着磁道号减11.4机地均匀分布在磁盘上。

现在要计算一次寻道平均跨越的磁道数。

a.首先,计算当磁头当前位于磁道t时,寻道长度为j的可能性。

提示:这是一个关于确定所有组合数目的问题,所有磁道位置作为寻道目标的可能性是相等的。

b.接下来计算寻道长度为K的可能性。

提示:这包括所有移动了K个磁道的可能性之和。

c.使用下面计算期望值得公式,计算一次寻道平均跨越的磁道数目:N-1E[X]=∑i∑Pr[x=i]i=0d.说明档N比较大时,一次寻道平均跨越的磁道数接近N/3.(a)设P[j/t]表示位于磁道t,寻道长度为j的概率,知随机访问一个任何一个磁道的可能性为相等为1/N,因此我们有P[j/t]=1/N,t<=j-1或者t>=N-j;P[j/t]=2/N,j-1<t<N-j.前一种情况下,当前磁道接近于磁盘的两端。

因此只有一个相距j长度的磁道,故为2/N。

(b)令P[k]=∑P[k/t]*P[t]=1/N∑P[k/t],由(a)可知,取值1/N的有2k个磁道,取值为2/N有(N-k)个,所以有P[k]=(2k/N+2(N-k)/N)/N=2(N-k)/N*N(c)E[k]=∑k*P[k]=∑2k(N-k)/N*N=(N*N-1)/3N(d)当N比较大时,从上文可以看出一次寻道平均跨越磁道数接近N/311.5下面的公式适用于高速缓冲存储器和磁盘高速缓存:Ts=Tc+M×Td请把这个公式推广到N级存储器结构,而不是仅仅2级。

定义:Ai=从i级存储器找到信息的时间;Hi=消息在第i级存储器并且没有在更高级存储器的概率;Bi=从第(i+1)级向第i级传送一块数据的时间。

假设缓存在1级存储上,主存在2级存储上,如此下去,形成一个N 级存储结构,因此有Ts=∑AiHi若消息在M1层,可以立即被读,如果在M2中,不在M1中,那么这块数据从M2传到M1中再读。

因此 A2=B1+A1进而有 A3=B2+A2=B1+B2+A1即有 Ai=A1+∑Bj所以 Ts=T1∑Hi+∑∑BjHi因为∑Hi=1最后可得 Ts=T1+∑∑BjHi11.6对基于频率的替换算法(见图11.12),定义F new,F middle和Fold分别为包含新区,中间区和的高速缓存片段,显然F new+F middle+Fold=1.如果有a.Fold=1—F newb. Fold=1/(高速缓存大小)请分别描述该策略。

a.图11.11的中间区是空的,因此这种策略退化为图11.11a的策略。

b.老区由一块组成,并且我们有LRU替换策略。

11.7对于一个有9个磁道的磁带,磁带速度为120英寸每秒,磁带密度为1600线位/英寸,请问它的传送率为多少?密度可表示为1600线位每英寸,因此传送速率为1600×1200=192000线位每秒。

11.8假设有一个2400英寸的磁带盘,记录间的间隙为0.6英寸,这个间隙是磁带在读操作之间的停止;在间隙期间磁带速度成线性增加或减小,磁带的其他与习题11.7相同。

磁带上的数据按物理记录组织,每个物理记录包含固定数目的由用户定义的单元,称为逻辑记录。

a.在磁带上读取分装在10个物理记录中的120个逻辑记录需要多少时间?b.同样。

如果是分装在30个物理记录中,则需要多少时间?c.对于上述每种分块方案,整个磁带分别可以保存多少个逻辑记录?d.对于上述每种分块方案,有效的总传速率分别是多少?e.磁带的容量是多少?假设每个记录由30块组成。

b.我们先定义从一个物理块加间隙到了另一块的读取时间物理块的大小=(30个逻辑记录每物理记录)×(120比特每逻辑记录)=3600字节物理块的长度=3600字节/(1600比特/英寸)=2.35英寸间隙的长度=0.6英寸传输一个块加间隙的传输时间=2.25/120+0.6/60=0.02875秒磁带上块的数目=(2400×12)/(2.25+0.6)=10105物理块因此,读取时间为 10105×0.02875=291秒c.如果分装在30个物理记录中,磁带包含10105个物理记录和30×10105=303150个逻辑记录。

d.分装在30个物理记录中的有效传输数率:R=(303150×120)/291=125010字节/秒e.容量=303150×120=36378000字节11.9如果磁盘中扇区大小固定为每扇区为512字节,并且每磁道96个磁区,每面110个磁道,一共有8个可用的面,对于习题11.8(b),计算存储这些逻辑记录需要多少磁盘空间(扇区、磁道和面)。

忽略文件头记录和磁道索引,并假设记录不能跨越两个扇区。

每个扇区能容纳4个记录,所需扇区数=303150/4=75788所需磁道数=75788/96=790所需面数=790/110=811.10考虑习题11.9所描述的磁盘系统,假设该磁盘的旋转速度为360r/m。

一个处理器使用中断驱动I/O从磁盘中读取一个扇区,每个字节一个中断。

如果处理每个中断需要2.5us,处理器花费在处理I/O上的时间占多少百分比(忽略寻道时间)?每扇区512字节,每字节一个中断,所以每扇区512个中断。

中断总时间=2.5×512=1280us。

每个扇区读取时间=60s/m×360r/m×96扇区/磁道=1736us处理器花费在处理I/O上的时间百分比=100×1280/1736=74%11.11如果使用DMA策略并假设每个扇区一个中断,重做习题11.10。

使用DMA策略,中断总时间=2.5us处理器花费在处理I/O上的时间百分比=100×2.5/1736=0.14%11.12一个32位计算机有两个选择通道和一个多路通道,每个选择通道支持两个磁盘和两个磁带部件。

多路通道有两个行式打印机、两个卡片阅读机,并连接着10个VDT终端。

假设有以下的传送率:磁盘驱动器 800KB/s磁带驱动器 200KB/s行式打印机 6.6KB/s卡片阅读机 1.2KB/sVDT 1KB/s系统中的最大合计传送率为多少?每次只有一个驱动设备能在选择通道上得到服务,因此,最大速率=800+800+2×6.6+2×1.2+10×1=1625.6KB/s11.13当条带大小比I/O大小小时,磁盘条带化显然可以提高数据传送率。

同样,相对于单个的大磁盘,由于RAID 0可以并行处理多个I/O请求,显然它可以提高性能。

但是,相对于后一种情况,磁盘条带化还有必要存在吗?也就是说,相对于没有条带化的磁盘阵列,磁盘条带化可以提高I/O请求速度的性能吗?这取决于I/O请求类型。

相关文档
最新文档