首页 > 其他分享 >1.OS-Introduction|Begin

1.OS-Introduction|Begin

时间:2023-04-17 19:23:18浏览次数:39  
标签:Begin run Introduction system operating memory OS CPU

image

Von Neumann model of computing

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 **

operating system

In fact, that is responsible for making it easy to run programs (even allowing you to seemingly run many at the same time), allowing programs to share memory, enabling programs to interact with devices, and other fun stuff like that. That body of software is called the operating system.

THE CRUX OF THE PROBLEM -- HOW TO VIRTUALIZE RESOURCES

  • 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

You should what is the crux problem!

virtualization

vitualization all resoure!
Easy-to-use virtual form of itself : a ** virtual machine. **
a few hundred system calls,we also sometimes say that the **OS provides a standard library to applications. **
OS is sometimes known as a **resource manager. **

2.1 Virtualizing The CPU

Virtualizing the CPU,让我们看起来像是有很多CPU在运行。其实只是一个,而背后的实现,取决于操作系统OS的策略policy。

代码1:
It doesn’t do much. In fact, all it does is call Spin(), a function that repeatedly checks the time and returns once it has run for a second. Then, it prints out the string that the user passed in on the command line, and repeats, forever.
image.png

-Wall 的意思为显示所有警告
-w的意思是关闭警告
./文件 ./文件 ./文件,一次性启动多个程序

显示1:
image.png
显示2:
Running Many Programs At Once
image.png
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 programs to seemingly run at once is what we call virtualizing the CPU, the focus of the first major part of this book.

You might also notice that the ability to run multiple programs at once raises all sorts of new questions. For example, 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.
当然,CPU虚拟化也引发出了各种各样的问题,如线程竞争,哪一个优先?

2.2 Virtualizing Memory

image.png
image.png
Physical memory物理内存
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 。
Don’t forget that each instruction of the program is in memory too; thus memory is accessed on each instruction fetch.
字节流->读写地址(不要忘记指令也在内存,所以每一次指令操作都要读写内存)
发现地址是一样的
Indeed, that is exactly what is happening here as the OS is virtualizing memory. 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. (实际上:物理内存是共享的,由操作系统管理)

如何管理,也正是我们要研究的主题!

2.3 Concurrency

image.png
image.png

THE CRUX OF THE PROBLEM: HOW TO BUILD CORRECT CONCURRENT PROGRAMS?
When there are many concurrently executing threads within the same memory space, how can we build a correctly working program? What primitives are needed from the OS? What mechanisms should be provided by the hardware? How can we use them to solve the problems of concurrency ?

Takes three instructions: one to **load the value **of the counter from memory into a register, one to increment it, and one to store it back into memory
Because these three instructions **do not execute atomically (all at once), **strange things can happen.

并发,会引起一系列问题,这是我们要思考且要考虑的。这也是现代编程需要面对的一个大问题。

2.4 Persistence

The hardware comes in the form of some kind of input/output or I/O device; in modern systems, a hard drive is a common repository for** long lived information,** although solid-state drives** (SSDs) **are making head way in this arena as well.
The software in the operating system that usually **manages the disk is called the file system; **it is thus responsible for storing any files the user creates in a reliable and efficient manner on the disks of the system.

硬件作为IO设备出现
文件系统管理磁盘

HOW TO STORE DATA PERSISTENTLY
The file system is the part of the OS in charge of managing persistent data. What techniques are needed to do so correctly? What mechanisms and policies are required to do so with high performance? How is reliability achieved, in the face of failures in hardware and software?

image.png

不像操作系统为 CPU 和内存提供的抽象,操作系统不会为每个应用程序创建专用的虚 拟磁盘。相反,它假设用户经常需要共享(share)文件中的信息。

2.5 Design Goals

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.

  • One of the most basic goals is to** build up some abstractions **in order to make the system convenient and easy to use
  • 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 **
  • Another goal will be to provide protection between applications, as well as between the OS and applications
  • 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 **

标签:Begin,run,Introduction,system,operating,memory,OS,CPU
From: https://www.cnblogs.com/HX-Note/p/17326848.html

相关文章

  • TopoSort
    //TopoSort.cpp--TopologicalSortPage182#include<stdio.h>#include<stdlib.h>#include"myconst.h"#defineMAX_VERTEX_NUM20typedefintVertexType;typedefintInfoType;typedefstructArcNode{intadjvex;structArcNo......
  • VMware安装GHOST系统出现chs data error disk错误的解决方法
    选择高级选择最后一个......
  • EasyBoot教程三:制作GHOST多重启动盘方法
    怎么让EasyBoot支持ghost文件?1.先下载常用IMG集合找到GHOSTWIN7.IMG2.解压GHOSTWIN7.IMG,用记事本打开AUTOEXEC.BAT,更改gho文件名我这里用win764.gho这个名3.用WinImage这个软件打开GHOSTWIN7.IMG用修改好的AUTOEXEC.BAT文件,保存好后替换上图中的文件点击另存为保存类型选择:所有文......
  • ECShop开源商城与COS互通:降低本地存储负载、提升访问体验
    ECShop简介ECShop是一款开源电子商务平台,具有简单易用、安全稳定、模块化设计等特点。它提供了完整的电子商务解决方案,包括商品管理、订单管理、支付管理、配送管理、会员管理、促销管理、数据统计等功能。ECShop支持多语言、多货币、多种支付方式和配送方式,并可通过插件扩展更多......
  • Centos安装Redis
    下载Rediswgethttps://github.com/redis/redis/archive/7.0.10.tar.gz解压tar-zxf7.0.10.tar.gz-C/usr/local/cd/usr/local/redis-7.0.10mv/usr/local/redis-7.0.10//usr/local/rediscd/usr/local/redis/安装一些依赖yum-yinstallncursesncurses-developens......
  • Postman 如何传递 Date 类型参数
    背景最近在写一个接口,这里我就简单展示一下:http://127.0.0.1:3006/api/v1/date他的作用是把用户端的当前时间发送到后端去,方便后端对于用户行为的行为埋点~开始前我们可以先回顾下:了解Postman:这个API工具的功能和用途是什么?调试此接口发现问题使用了Postman进行调试此接口,但是......
  • 安装完SFTP后,用PUTTY连接CENTOS,软件闪退问题
    我出现这个问题是因为SFTP和SSH的配置文件是一个,都是etc/ssh/sshd_config所以是配置文件的问题,我将配置SFTP时设置的删除下面这些就好了MatchGroupsftpX11ForwardingnoAllowTcpForwardingnoChrootDirectory%h           ForceCommandinternal-sftp......
  • Centos7安装web环境
    1、安装Apache[root@localhost~]#yum-yinstallhttpd#开机自启动[root@localhost~]#chkconfighttpdon#启动httpd服务[root@localhost~]#servicehttpdstart现在直接在浏览器键入http://localhost 或http://本机IP ,应该会看到Apache的测试页面这里需要注意关闭防......
  • Centos7安装Cmake3.0
    下载Cmakewgethttps://cmake.org/files/v3.0/cmake-3.0.0.tar.gz解压Cmaketarxvfcmake-3.0.0.tar.gz&&cdcmake-3.0.0/编译安装cmake./bootstrapgmakegmakeinstall查看编译后的cmake版本/usr/local/bin/cmake--version移除原来的cmake版本yumremovecmake-y新建软连接ln......
  • CentOS7更新yum源
    [1]首先备份mv/etc/yum.repos.d/CentOS-Base.repo/etc/yum.repos.d/CentOS-Base.repo.backup[2]进入yum源配置文件所在文件夹cd/etc/yum.repos.d/[3]下载163的yum源配置文件,放入/etc/yum.repos.d/(操作前请做好相应备份)wgethttp://mirrors.163.com/.help/CentOS7-Base-163.......