读书笔记系列 - Operating Systems: Three Easy Pieces - Intro

简介: 读书笔记系列 - Operating Systems: Three Easy Pieces - Intro

Preface

The three easy pieces refer to the three major thematic elements the book is organized around: virtualization, concurrency, and persistence.


1. Dialogue

1.I hear and I forget. I see and I remember. I do and I understand.

2.According to http://www.barrypopik.com (on, December 19, 2012, entitled “Tell me and I forget; teach me and I may remember; involve me and I will learn”) Confucian philosopher Xunzi said “Not having heard some thing is not as good as having heard it; having heard it is not as good as having seen it; having seen it is not as good as knowing it; knowing it is not as good as putting it into practice.” Later on, the wisdom got attached to Confucius for some reason.


2. Introduction

1.Well, a running program does one very simple thing: it executes instructions.

2.Many millions (and these days, even billions) of times every second, the processor fetches an instruction from memory, decodes it (i.e., figures out which instruction this is), and executes it (i.e., it does the thing that it is supposed to do, like add two numbers together, access memory, check a condition, jump to a function, and so forth). After it is done with this instruction, the processor moves on to the next instruction, and so on, and so on, until the program finally completes.

3.THE CRUX OF THE PROBLEM: HOW TO VIRTUALIZE RESOURCES – One central question we will answer in this book is quite simple: how does the operating system virtualize resources? This is the crux of our problem. Why the OS does this is not the main question, as the answer should be obvious: it makes the system easier to use. Thus, we focus on the how: what mechanisms and policies are implemented by the OS to attain virtualization? How does the OS do so efficiently? What hardware support is needed?

4.The primary way the OS does this is through a general technique that we call virtualization. That is, the OS takes a physical resource (such as the processor, or memory, or a disk) and transforms it into a more general, powerful, and easy-to-use virtual form of itself. Thus, we sometimes refer to the operating system as a virtual machine.

5.A typical OS, in fact, exports a few hundred system calls that are available to applications. Because the OS provides thse calls to run programs, access memory and devices, and other related actions, we also sometimes say that the OS provides a standard library to applications.

6.Because virtualization allows many programs to run (thus sharing the CPU), and many programs to concurrently access their own instructions and data (thus sharing memory), and many programs to access devices (thus sharing disks and so forth), the OS is sometimes known as a resource manager. Each of the CPU, memory, and disk is a resource of the system; it is thus the operating system’s role to manage those resources, doing so efficiently or fairly or indeed with many other possible goals in mind.

7.It turns out that the operating system, with some help from the hardware, is in charge of this illusion, i.e., the illusion that the system has a very large number of virtual CPUs. Turning a single CPU (or a small set of them) into a seemingly infinite number of CPUs and thus allowing many programst o seemingly run at once is what we call virtualizing the CPU, the focus of the first major part of this book.

8.If two programs want to run at a particular time, which should run? This question is answered by a policy of the OS; policies are used in many different places within an OS to answer these types of questions, and thus we will study them as we learn about the basic mechanisms that operating systems implement (such as the ability to run multiple programs at once). Hence the role of the OS as a resource manager.

9.The model of physical memory presented by modern machines is very simple. Memory is just an array of bytes; to read memory, one must specify an address to be able to access the data stored there; to write (or update) memory, one must also specify the data to be written to the given address.

10.Each process accesses its own private virtual address space (sometimes just called its address space), which the OS somehow maps onto the physical memory of the machine. A memory reference within one running program does not affect the address space of other processes (or the OS itself); as far as the running program is concerned, it has physical memory all to itself. The reality, however, is that physical memory is a shared resource, managed by the operating system. Exactly how all of this is accomplished is also the subject of the first part of this book, on the topic of virtualization.

11.In system memory, data can beeasily lost, as devices such as DRAM store values in a volatile manner; when power goes away or the system crashes, any data in memory is lost. Thus, we need hardware and software to be able to store data persistently; such storage is thus critical to any system as users care a great deal about their data.

12.So now you have some idea of what an OS actually does: it takes physical resources, such as a CPU, memory, or disk, and virtualizes them. It handles tough and tricky issues related to concurrency. And it stores files persistently, thus making them safe over the long-term. Given that we want to build such a system, we want to have some goals in mind to help focus our design and implementation and make trade-offs as necessary; finding the right set of trade-offs is a key to building systems.

13.One of the most basic goals is to build up some abstractions in order to make the system convenient and easy to use.

14.One goal in designing and implementing an operating system is to provide high performance; another way to say this is our goal is to minimize the overheads of the OS.

15.Another goal will be to provide protection between applications, as well as between the OS and applications. Protection is at the heart of one of the main principles underlying an operating system, which is that of isolation; isolating processes from one another is the key to protection and thus underlies much of what an OS must do.

16.The operating system must also run non-stop; when it fails, all applications running on the system fail as well. Because of this dependence, operating systems often strive to provide a high degree of reliability.

17.Other goals make sense: energy-efficiency is important in our increasingly green world; security (an extension of protection, really) against malicious applications is critical, especially in these highly-networked times; mobility is increasingly important as OSes are run on smaller and smaller devices.


目录
相关文章
|
前端开发 Java 应用服务中间件
【总结】Javaweb和Java项目的比较
webapp:这是一个重要的目录,用于存放Web应用程序的相关资源和文件。这些资源和文件能够被Web容器解析和处理,用于构建Web页面和提供Web服务。在webapp目录下,可以包含以下子目录和文件: WEB-INF目录:该目录包含Web应用程序的配置文件和受保护的资源。常见的文件和目录有: web.xml:Web应用程序的部署描述符,包含了Servlet、Filter、Listener等的配置信息。 lib目录:用于存放Web应用程序所需的依赖库(JAR文件)。 classes目录:编译输出目录,用于存放编译生成的字节码文件(.class文件)。
|
编解码 弹性计算 Cloud Native
倚天使用|倚天ECS视频编解码之x264性能
在平头哥发布了首颗为云而生的 CPU 芯片倚天710之后,搭载倚天 710 的 ECS 实例表现出强劲的性能实力,在x264编解码场景下有着极高的性价比。
|
人工智能 机器人 物联网
用AI生成可爱的泡泡玛特盲盒风,带prompt
用AI生成可爱的泡泡玛特盲盒风
1293 1
用AI生成可爱的泡泡玛特盲盒风,带prompt
|
9月前
|
存储 C语言
【C语言】输入/输出函数详解
在C语言中,输入/输出操作是通过标准库函数来实现的。这些函数分为两类:标准输入输出函数和文件输入输出函数。
1052 6
|
10月前
|
监控 安全 网络安全
企业网络安全:构建高效的信息安全管理体系
企业网络安全:构建高效的信息安全管理体系
313 5
|
10月前
|
缓存 NoSQL 关系型数据库
mysql和缓存一致性问题
本文介绍了五种常见的MySQL与Redis数据同步方法:1. 双写一致性,2. 延迟双删策略,3. 订阅发布模式(使用消息队列),4. 基于事件的缓存更新,5. 缓存预热。每种方法的实现步骤、优缺点均有详细说明。
402 3
|
人工智能 自然语言处理 区块链
什么是token?3分钟带你看懂
`Token`在人工智能领域指的是文本处理的最小单元,用于大语言模型如LLM,它可以是单词、字母等。在模型运作中,输入的文本被转化为tokens,模型通过分析上下文tokens预测并生成输出。模型的上下文(窗口)长度限制了处理的token数量,影响性能和用户体验。此外,`token`也与收费计量单位相关,大模型服务商常按token量计费。同时,`AI token`在某些场景下代表代币,用于应用程序交易、服务和投资,有时扮演加密货币角色。Token在人机交流中起到桥梁作用,促进了通用人工智能的普及和发展。
|
缓存 前端开发 JavaScript
优化前端性能的10个实用技巧
提高网站或应用程序的性能是前端开发中至关重要的一部分。本文将介绍10个实用的技巧,帮助前端开发人员优化其项目的性能,包括减少HTTP请求、使用CDN加速、压缩和合并文件、优化图片等方面的技术手段,以提升用户体验和网站加载速度。
|
前端开发 JavaScript UED
【专栏:HTML基础篇】HTML列表与表格:展示数据的两种方式
【4月更文挑战第30天】本文探讨了HTML中的列表和表格两种元素在网页设计中的重要性。无序列表(`<ul>`)和有序列表(`<ol>`)用于呈现相关项目,前者常用于导航菜单,后者适合有序信息。表格(`<table>`)用于展示结构化数据,通过`<tr>`、`<td>`和`<th>`定义行和单元格。尽管简单,列表和表格在内容呈现和用户体验上起着关键作用。然而,响应式设计趋势下,表格可能被更灵活的布局替代,复杂数据展示则可借助JavaScript库提升交互性。正确使用这些基础元素能有效组织信息,创建优质网页。
619 0
|
存储 关系型数据库 MySQL
【MySQL从入门到精通】【高级篇】(八)聚簇索引&非聚簇索引&联合索引
上一篇文章我们介绍了【MySQL从入门到精通】【高级篇】(七)设计一个索引&InnoDB中的索引方案,该文介绍了如何设计一个索引,以及InnoDB中的索引如何形成。
461 0
【MySQL从入门到精通】【高级篇】(八)聚簇索引&非聚簇索引&联合索引