【操作系统概念-作业1】Introduction

Operating System Concepts Exercises 1

Introduction

操作系统作业1

  • 1.1, 1.5, 1.6
  • 1.12, 1.15, 1.19, 1.22, 1.23, 1.27

每题最后一个引用块是老师提供的参考答案

Practice Exercises

1.1 What are the three main purposes of an operating system?

操作系统的三个主要目的是什么?

答:

  1. 作为系统资源的管理者
  2. 向上层提供方便易用的服务
  3. 作为最接近硬件的层次

参考自其他中文教材

The three main purposes are:

  1. To provide an environment for a computer user to execute programs on computer hardware in a convenient and efficient manner.为计算机用户提供一个以方便和高效的方式在计算机硬件上执行程序的环境

  2. 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.根据需要分配计算机的单独资源来解决给出的问题。分配过程应是尽可能的公平和有效的。

  3. 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)监督用户程序的执行,以防止错误和不当使用计算机,以及对I/O设备的操作和控制的(2)管理输入输出设备的运行和控制的管理

1.5 How does the distinction between kernel mode and user mode function as a rudimentary form of protection (security) system?

内核模式和用户模式作为一种初级的保护(安全)系统,其区别是什么?

答:

我们普通程序 员写的程序就是“应用程序”。微软、苹果有一帮人负责实现操作系统,他们写的是“内核程序”。由很多内 核程序组成了“操作系统内核”,或简称“内核(Kernel)”。内核是操作系统最重要最核心的部分,也是最接 近硬件的部分。甚至可以说,一个操作系统只要有内核就够了

Answer:

Certain instructions (privileged instructions) could be executed only when the CPU is in kernel mode.

If any attempt is made to execute a Privileged Instruction in User Mode, then it will not be executed and treated as an illegal instruction. The Hardware traps it to the Operating System.

只有当CPU处于内核模式时,才能执行某些指令(特权指令)。

如果尝试在用户模式下执行特权指令,则不会执行并视为非法指令。硬件将其陷阱到操作系统。

Various examples of Privileged Instructions include:

  • l I/O instructions and Halt instructions
  • l Turn off all Interrupts
  • l Set the Timer
  • l Context Switching
  • ……

Various examples of Non-Privileged Instructions include:

  • l Reading the status of Processor
  • l Reading the System Time
  • l Generate any Trap Instruction
  • ……

Ref:

https://www.geeksforgeeks.org/privileged-and-non-privileged-instructions-in-operating-system/

1.6 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.

Set value of timer, clear memory, turn off interrupts, modify entries in device-status table, Switch from user to kernel mode, access I/O device.

The rest can be performed in user mode.

Exercises

1.12 In a multiprogramming and time-sharing environment, several users share the system simultaneously. This situation can result in various security problems.

在多道程序设计和分时环境中,几个用户同时共享系统。这种情况会导致各种安全问题。

a. What are two such problems?

这两个问题是什么?

答:

:Stealing or copying one’s programs or data; using system resources (CPU, memory, disk space, peripherals) without proper accounting.

b. Can we ensure the same degree of security in a time-shared machine as in a dedicated machine? Explain your answer.

我们能否确保分时机器与专用机器具有相同程度的安全性?解释你的答案

答:

:Probably not, since any protection scheme devised by humans can inevitably be broken by a human, and the more complex the scheme, the more difficult it is to feel confident of its correct implementation.

Answer:

a. Stealing or copying a user’s files; 窃取或复制用户的文件

writing over another program’s (belonging to another user or to the OS) area in memory; 写入内存中的另一个程序(属于其他用户或操作系统)的区域

using system resources (CPU, disk space) without proper accounting;

causing the printer to mix output by sending data while some other user’s file is printing.不使用系统资源(CPU、磁盘空间);

在其他用户的文件正在打印时,通过发送数据,使打印机混合输出。

b. Probably not, since any protection scheme for time-sharing environment devised by a human can also be broken (可能不会,因为任何由人类设计的分时环境保护方案都可能被破坏)-- and the more complex the scheme is, the more difficult it is to be confident of its correct implementation.(该方案越复杂,就越难对其正确实施有信心。)

1.15 Describe the differences between symmetric and asymmetric multiprocessing. What are three advantages and one disadvantage of multiprocessor systems?

描述对称和非对称多处理之间的区别。多处理器系统的三个优点和一个缺点是什么?

答:

three main advantages:

Multiprocessor systems have three main advantages:

  1. Increased throughput. By increasing the number of processors, we expect to get more work done in less time. The speed-up ratio with N processors is not N, however; rather, it is less than N. When multiple processors cooperate on a task, a certain amount of overhead is incurred in keeping all the parts working correctly. This overhead, plus contention for shared resources, lowers the expected gain from additional processors. Similarly, N programmers working closely together do not produce N times the amount of work a single programmer would produce.
  2. Economy of scale. Multiprocessor systems can cost less than equivalent multiple single-processor systems, because they can share peripherals, mass storage, and power supplies. If several programs operate on the same set of data, it is cheaper to store those data on one disk and to have all the processors share them than to have many computers with local disks and many copies of the data.
  3. Increased reliability. If functions can be distributed properly among several processors, then the failure of one processor will not halt the system, only slow it down. If we have ten processors and one fails, then each of the remaining nine processors can pick up a share of the work of the failed processor. Thus, the entire system runs only 10 percent slower, rather than failing altogether.

one disadvantage:

需考虑体系结构,如缓存,内存及总线竞争

Answer

Symmetric processing treats all processors as equals; I/O can be processed on any of them. Process can be scheduled on any of them.对称处理将所有处理器平等处理,其中任何一个都可以处理I/O。进程可以在其中的任何一个进程上进行安排。

Asymmetric processing designates one CPU as the master, which is the only one capable of performing I/O; the master distributes computational work among the other CPUs (worker).不对称处理指定一个CPU作为主计算机,这是唯一能够执行I/O的主计算机;主计算机将在其他CPU之间分配计算工作。

Advantages:

Multiprocessor systems can save money, by sharing power supplies and peripherals. 多处理器系统可以通过共享电源和外设来省钱。

Can execute programs more quickly (parallel)可以更快地执行程序(并行)

can have increased reliability.可以提高可靠性。

Disadvantages:

Multiprocessor systems are more complex in both hardware and software. Additional CPU cycles are required to manage the cooperation, so per-CPU efficiency goes down.多处理器系统在硬件和软件上都更加复杂。需要额外的CPU周期来管理协作,因此每个CPU的效率会下降100

1.19 What is the purpose of interrupts? How does an interrupt differ from a trap? Can traps be generated intentionally by a user program? If so, for what purpose?

中断的目的是什么?中断与陷阱有何不同?陷阱可以由用户程序故意产生吗?如果有,是为了什么目的?

答:

An interrupt is a hardware-generated change of flow within the system. An interrupt handler is summoned to deal with the cause of the interrupt; control is then returned to the interrupted context and instruction. A trap is a software-generated interrupt.
An interrupt can be used to signal the completion of an I/O to obviate the need for device polling. A trap can be used to call operating system routines or to catch arithmetic errors
中断是系统中由硬件产生的流变化。调用中断处理程序来解决造成中断的原因;控制返回到
中断的上下文和指令处。陷阱是由软件产生的中断,中断可以用来发出I/O完成的信号,以消除
对设备轮询。陷阱可以用来调用操作系统例程或捕获算数错误。

Answer:

An interrupt is a hardware-generated signal that changes the flow within the system. An interrupt can be used to signal the completion of I/O so that the CPU doesn’t have to spend cycles polling the device. 中断是一种硬件生成的信号,可以改变系统内部的流量。一个中断可以用来发出I/O的完成信号,这样CPU就不必花费一个周期来轮询设备了。

A trap is a software-generated interrupt. A trap can be used to invoke call system calls.(陷阱是一种由软件生成的中断。一个陷阱可以用于调用呼叫系统调用。)

Exception is raised when an abnormal condition occurs during execution. (For example, Memory protection violation, page fault, illegal instruction)在执行过程中出现异常情况时,会引发异常。(例如,内存保护违规、页面故障、非法指令)

1.22 Many SMP systems have different levels of caches; one level is local to each processing core, and another level is shared among all processing cores. Why are caching systems designed this way?

许多SMP系统有不同级别的缓存;一个级别是每个处理核心的本地级别,另一个级别是所有处理核心之间共享的。为什么缓存系统是这样设计的?

答:

平衡各方优势

If the CPU has an integrated memory controller, then adding CPUs can also increase the amount of memory addressable in the system. Either way, multiprocessing can cause a system to change its memory access model from uniform memory access (UMA) to non-uniform memory access (NUMA). UMA is defined as the situation in which access to any RAM from any CPU takes the same amount of time. With NUMA, some parts of memory may take longer to access than other parts, creating a performance penalty. Operating systems can minimize the NUMA penalty through resource management, as discussed in Section 9.5.4.

如果CPU有一个集成的内存控制器,那么增加CPU也可以增加系统中可寻址的内存数量。无论哪种方式,多处理都会导致系统改变其内存访问模式,从统一内存访问(UMA)变为非统一内存访问(NUMA)。UMA被定义为从任何CPU访问任何RAM都需要相同的时间。在NUMA的情况下,内存的某些部分可能需要比其他部分更长的时间来访问,从而造成性能损失。如第9.5.4节所述,操作系统可以通过资源管理将NUMA惩罚降到最低。

Answer:

The different levels are based on access speed as well as size. In general, the closer the cache is to the CPU, the faster the access. However, faster caches are typically more costly. Therefore, smaller and faster caches are placed local to each CPU, and shared caches that are larger, yet slower, are shared among several different processors.不同的级别是基于访问速度和大小的。一般来说,缓存越接近CPU,访问速度就越快。然而,更快的缓存通常会更昂贵。因此,较小、更快的缓存被放在每个CPU的本地,而更大但较慢的共享缓存则在几个不同的处理器之间共享。

1.23 Consider an SMP system similar to the one shown in Figure 1.6. Illustrate with an example how data residing in memory could in fact have a different value in each of the local caches.

考虑一个类似于图1.6所示的SMP系统。用示例说明内存中的数据在每个本地缓存中具有不同的值。

答:

Say processor 1 reads data A with value 5 from main memory into its local cache.
Similarly, processor 2 reads data A into its local cache as well. Processor 1 then
updates A to 10. However, since A resides in processor 1’s local cache, the update only
occurs there and not in the local cache for processor 2.
处理器1从主内存读取A的值是5,保存到本地缓存中.相似的,处理器2从主内存也读取A
的值。处理器1然后将A更改成10.然而,因为A在处理器1的本地缓存中,更新只在这里而不再
处理器2的本地缓存。(这里实际上有两个问题,一个是处理器1更新时再自己本地缓存更新,
一个是处理器2的值就是旧值,得不到最新的A值。大家可以阅读缓存一致性的文章,但是还不
保证变量的可见性,详见Java volatile)

1.27 Describe some of the challenges of designing operating systems for mobile devices compared with designing operating systems for traditional PCs.

请描述为移动设备设计操作系统与为传统pc设计操作系统的一些挑战。

答:

  • 低功耗
  • 易于使用,用户友好,学习简单
  • 适于触摸语音等交互方式
  • 反应快。待机和使用状态转变快
  • 适应长期驻于后台的多功能设计
  • 安全性高

Answer:

The greatest challenges in designing mobile operating systems include:

  • l Less storage capacity means the operating system must manage memory carefully.(存储容量的减少意味着操作系统必须小心地管理内存。)
  • l The operating system must also manage power consumption carefully.(操作系统还必须仔细管理功耗。电池)
  • l Less processing power plus fewer processors mean the operating system must carefully apportion processors to applications.(更少的处理能力加上更少的处理器意味着操作系统必须小心地将处理程序分配到应用程序。)

注:

翻译:deepl

参考资料:

[1] Operating System Concepts – 9th Edition 及其答案

【操作系统概念-作业1】Introduction相关推荐

  1. 【操作系统概念-作业8】Main Memory

    #! https://zhuanlan.zhihu.com/p/424671940 [操作系统概念-作业8]Main Memory Operating System Concepts Exercise ...

  2. 【操作系统概念-作业6】CPU Scheduling

    #! https://zhuanlan.zhihu.com/p/424667500 [操作系统概念-作业6]CPU Scheduling Operating System Concepts Exerc ...

  3. 【操作系统概念-作业2】Operating-System Structures

    [操作系统概念-作业2]Operating-System Structures Operating System Concepts Exercises 2 Operating-System Struc ...

  4. java大作业私人管家系统_操作系统概念(Operating System Concepts)第十版期中大作业...

    更正: 第一题中,哲学家就餐问题中的哲学家的状态state[i]应属于临界区变量,是可能会产生读写冲突的,所以对其进行读写的时候均需要加一把互斥锁. 非常感谢不听不听不听的指正. ---------- ...

  5. 《Operating System Concepts(操作系统概念)》课程学习(1)——Chapter 1 Introduction(第1章 绪论)

    操作系统概念 Operating System Concepts 说起操作系统,我想在坐的各位同学都不会陌生.因为无论我们想用计算机干什么,首先要做的就是启动操作系统,任何软件的运行都离不开操作系统的 ...

  6. 【渝粤题库】陕西师范大学200751 《操作系统》作业

    <操作系统>作业 一.填空题. 1.加在计算机硬件上的第一层软件为 它是微机以至任何一台计算机必须配置的系统软件. 2.操作系统设计时追求的目标中,其有效性是指 . 3.批(包括多道和单 ...

  7. 1 操作系统第一章 操作系统概念、功能、四大特征、操作系统发展与分类

    文章目录 1.1 操作系统概念 1.2 操作系统功能 1.3 操作系统四大特征 1.3.1 并发 1.3.2 共享 1.3.3 并发性和共享区别及对应关系: 1.3.4 虚拟 1.3.5 异步 1.4 ...

  8. 操作系统概念(一)——导论

    此为本人在期中临近复习操作系统概念时将手写版笔记中的重点进行提炼后,加入个人的理解与思考所写出的总结性笔记,仅供参考. 一.做什么: 1.操作系统是管理计算机硬件的程序,为应用程序提供基础,并充当计算 ...

  9. 《操作系统概念》知识点期末复习整理

    对应<操作系统概念>第7版以及<王道论坛操作系统> 另外附上三个 HTML 思维导图(操作系统概述.进程.调度) 网盘链接:https://pan.baidu.com/s/1w ...

最新文章

  1. mysql double 20_MySQL教程20-小数类型
  2. SSM实现学生宿舍管理系统
  3. Groovy简介和一点资源
  4. 人才短缺是数据中心运营商面临的新问题
  5. 深入理解JVM原理之编译openjdk7
  6. 我如何使用React和Typescript在freeCodeCamp中构建天气应用
  7. 点石成金-3-超市大亨
  8. java n*n矩阵求值及求逆矩阵
  9. Delphi7中默认没有安装的官方控件
  10. ubuntu 18.04 卸载 mysql 过程记录
  11. 学科前沿技术专题第九章
  12. 【表格】从1G到5G的移动通信发展历程(精简版)
  13. android切换夜间模式吗,Android切换夜间模式
  14. 千年古刹南普陀寺义工十年发展已逾6000人
  15. Ubuntu系统安装时grub修复操作
  16. 配置免密登录报错:ssh: Could not resolve hostname note1: Name or service not known
  17. Libev源码分析05:Libev中的绝对时间定时器
  18. DecimalFormat数字格式化用法
  19. 【计算机视觉】文字检测与识别资源
  20. vsm java_vsm向量空间模型java实现(源码)

热门文章

  1. KUKA机器人的零点
  2. MySQL数据库——MySQL创建视图(CREATE VIEW)
  3. DUTOJ-1003: Zeratul的军训游戏
  4. 自控第三章matlab,刘金锟 先进PID控制及MATLAB仿真第3章专家PID学习心得及疑问
  5. 4.1 用格雷戈里公式求π的近似值
  6. 基本的排序算法c++实现
  7. ERP与CRM、MRP、PLM、APS、MES、WMS、SRM的关系
  8. 2022年 新华三杯决赛题目
  9. Soul Dance
  10. python求excel平均数_#python抓取excel表格数据#使用python3读取处理excel表的数据内容如何对内容求平均值...