Operating System Introduction

news2024/11/25 23:53:03

What is an Operating System?

A program that acts as an intermediary between a user of a computer and the computer hardware 操作系统即用户与计算机硬件中的类似中介的程序
Operating system goals:
Execute user programs and make solving user problems easier
Make the computer system convenient to use
Use the computer hardware in an efficient manner 目的便捷高效

Computer System Structure 

Computer system can be divided into four components:
Hardware – provides basic computing resources
CPU, memory, I/O devices
Operating system
Controls and coordinates use of hardware among various applications and users
Application programs – define the ways in which the system resources are used to solve the computing problems of the users
Word processors, compilers, web browsers, database systems, video games
Users
People, machines, other computers

计算机系统四个组件 硬件 操作系统 应用程序 用户

 

What Operating-Systems Do

Depends on the point of view
Users want convenience, ease of use and good performance
Don t care about resource utilization
But shared computer such as mainframe or minicomputer must keep all users happy
Operating system is a resource allocator and control program making efficient use of HW and managing execution of user programs
Users of dedicated systems such as workstations have dedicated resources but frequently use shared resources from servers
Mobile devices like smartphones and tablets are resource poor,  optimized for usability and battery life
Mobile user interfaces such as touch screens, voice recognition
Some computers have little or no user interface, such as embedded computers in devices and automobiles

                Run primarily without user intervention

1方便且高性能需求 2利用硬件管理用户程序的执行 3服务器共享资源 4移动设备用户界面 5设备中的嵌入式计算机

Operating-System Definition

The one program running at all times on the computer is the kernel, part of the operating system
Everything else is either
A system program (ships with the operating system, but not part of the kernel) , or
An application program , all programs not associated with the operating system
Today’s OSes for general purpose and mobile computing also include middleware – a set of software frameworks that provide additional services to application developers such as databases, multimedia, graphics 内核是计算机始终运行的程序 系统程序和应用程序

 

 What Happens When a Computer is Powered Up?

When computer is powered up, a bootstrap program executes. Bootstrap program is usually stored in a ROM/EEPROM on the motherboard, and the bootstrap program

1. loads the operating-system kernel into the main memory
2. lets the CPU executes the kernel. 

 Once the operating-system kernel is executing, it

3. loads some other components of the operating system like the hardware drivers (including k ernel interrupt - driver ), system daemons (i.e. services provided outside of the kernel), and system programs
4. loads graphic interface program to provide user a graphic interface, or just stop (stay at a command line environment)
5. waits for user input.

 计算机开机 执行存储在主板上的ROM的引导程序 1该程序会将操作系统内核加载到主内存中并让CPU执行内核 2当操作系统内核开始运行,加载操作系统其他组件,eg硬件驱动 系统进程 系统程序 3加载图形界面或者直接中断 并等待用户输入

Interrupts

Interrupts provide a mechanism to stop what the CPU is doing and immediately transfer execution to a fixed location.

All the user inputs, hardware/software errors, and other exceptions trigger interrupts.
When a CPU receives an interrupt, the CPU stops what it is doing, and transfers to the interrupt response program to react with the interrupt e.g. to respond to user input.
When the interrupt response program is complete, the CPU goes back to continue the previous program.

 中断机制 停止CPU工作,立即将执行转移到固定位置  有可能导致中断的情况:用户输入 软硬件错误  当CPU中断后,会有中断响应程序反映,当其完成后,CPU返回继续执行原先的程序

Hardware interrupt by one of the devices:
User input
Hardware error
Software interrupt ( exception or trap ):
Software error (e.g., division by zero)
Request for operating system service – system call
Other process problems include infinite loop, processes modifying each other or the operating system

 Multitasking (Timesharing)

One of the most important aspects of operating systems is the ability to run multiple programs (a program in execution is termed a process).

Timesharing is to achieve this. The idea is: the CPU executes multiple processes by switching among them, but the switches occur frequently, so the user feels that multiple programs are running at the same time. 多任务运行 CPU通过多个进程高频率切换达到同时运行多程序目的

Dual-mode Operation

Modern CPUs supports Dual-mode operation i.e. u ser mode and kernel mode . This allows OS to protect itself and other system components.
In user mode, a program can only access the memory allocated to itself. In kernel mode, a program can access the whole memory including the memory allocated to other programs.
In a CPU, there is mode bit (a register), specifying which mode is using.
Operating-system is working in kernel mode, so it can allocate memory to programs.
User programs are in user mode, so programs do not interfere with each other.
Interrupt response programs are in kernel mode, so when an interrupt is triggered, the mode is changed to kernel. When come back to the previous program, the mode changes back to user.

 

双模式运行 即用户模式和内核模式 保护操作系统和系统组件
用户模式:程序访问分配给子集的内存 程序之间不会相互干扰
内核模式:程序访问整个内存 操作系统为程序分配内存  中断响应程序处于内核模式(中断被触发时,模式变为内核模式。当返回前一个程序时,模式又变回用户模式)
CPU内有寄存器指定使用的模式

Storage Structure 

Main memory – only large storage media that the CPU can access directly
Random access
Typically volatile
Typically random-access memory in the form of Dynamic Random-access Memory (DRAM)
Secondary storage – extension of main memory that provides large nonvolatile storage capacity

 主存储器 CPU可以直接存取的唯一大型存储介质 随机存取 易失 DRAM形式随机存取存储器

第二存储器 主存储器的扩展 有大容量非易失存储空间

Hard Disk Drives ( HDD ) – rigid metal or glass platters covered with magnetic recording material
Disk surface is logically divided into tracks , which are subdivided into sectors
The disk controller determines the logical interaction between the device and the computer
Non-volatile memory ( NVM ) devices– faster than hard disks, nonvolatile
Various technologies
Becoming more popular as capacity and performance increases, price drops

硬盘 HDD 硬金属或玻璃盘 表面磁性记录材料 分为磁道 在划分为扇区 硬盘控制器决定设备iyu计算机之间的交互

非易失存储器NVM 速度快 非易失 

Storage Hierarchy

Storage systems organized in hierarchy
Speed
Cost
Volatility
Caching – copying information into faster storage system; main memory can be viewed as a cache for secondary storage
Device Driver for each device controller to manage I/O
Provides uniform interface between controller and kernel

存储层次结构 按层次结构组织的存储系统 速度成本波动性

缓存 将信息复制到速度更快的存储系统中;主存储器可视为二级存储的缓存

设备驱动程序在设备控制器里管理I/O 提供控制器与内核之间的统一接口

Direct Memory Access Structure

Used for high-speed I/O devices able to transmit information at close to memory speeds
Device controller transfers blocks of data from buffer storage directly to main memory without CPU intervention
Only one interrupt is generated per block, rather than the one interrupt per byte
直接内存访问结构 用于高速 I/O 设备,能以接近内存的速度传输信息 设备控制器将数据块从缓冲存储器直接传输到主存储器,无需 CPU 干预  每个数据块只产生一个中断,而不是每个字节产生一个中断

Resource Management  

Process Management

 

A process is a program in execution. It is a unit of work within the system. Program is a passive entity; process is an active entity .
Process needs resources to accomplish its task e.g. CPU, memory, I/O, files, and Initialization data
Process termination requires reclaim of any reusable resources
•Single-threaded process has one program counter specifying location of next instruction to execute
•Process executes instructions sequentially, one at a time, until completion
•Multi-threaded process has one program counter per thread
•Typically system has many processes, some user, some operating system running concurrently on one or more CPUs
•Concurrency by multiplexing the CPUs among the processes / threads

进程是执行中的程序 系统中的工作单位 程序是被动的 进程是主动的

进程:需要资源完成任务eg CPU、内存、I/O、文件和初始化数据 终止需要回收可重复使用的资源 按顺序执行指令,一次执行一条

单线程进程有一个程序计数器,指定下一条要执行指令的位置  多线程进程每个线程有一个程序计数器 在进程/线程之间多路复用 CPU 来实现并发性

The operating-system is responsible for the following activities in connection with process management: 

Creating and deleting both user and system processes
Suspending and resuming processes
Providing mechanisms for process synchronization
Providing mechanisms for process communication
Providing mechanisms for deadlock handling

Memory Management

To execute a program all (or part) of the instructions must be in memory
All  (or part) of the data that is needed by the program must be in memory
Memory management determines what is in memory and when
Optimizing CPU utilization and computer response to users
Memory management activities
Keeping track of which parts of memory are currently being used and by whom
Deciding which processes (or parts thereof) and data to move into and out of memory
Allocating and deallocating memory space as needed

 执行程序需要部分指令和所需部分数据在内存中 内存管理决定内存的内容和实践优化CPU利用老板和计算机响应 

File-system Management

OS provides uniform, logical view of information storage
Abstracts physical properties to logical storage unit  - file
Each medium is controlled by device (i.e., disk drive, tape drive)
Varying properties include access speed, capacity, data-transfer rate, access method (sequential or random)
File-System management
Files usually organized into directories
Access control on most systems to determine who can access what
OS activities include
Creating and deleting files and directories
Primitives to manipulate files and directories
Mapping files onto secondary storage
Backup files onto stable (non-volatile) storage media

操作系统为信息存储提供统一的逻辑视图 将物理属性抽象为逻辑存储单元“文件” 每种介质由设备控制 不同的属性包括访问速度、容量、数据传输速率、访问方法(顺序或随机)

文件系统管理 文件以目录排列 系统有访问控制决定谁可以访问什么 

Mass-Storage Management

Usually disks used to store data that does not fit in main memory or data that must be kept for a long period of time
Proper management is of central importance
Entire speed of computer operation hinges on disk subsystem and its algorithms
OS activities
Mounting and unmounting
Free-space management
Storage allocation
Disk scheduling
Partitioning
Protection

 大容量存储管理 磁盘用于存储主存储器无法容纳或需要长期保存的数据 计算机运行速度取决于磁盘子系统和算法

Caching

Important principle, performed at many levels in a computer (in hardware, operating system, software)
Information in use copied from slower to faster storage temporarily
Faster storage (cache) checked first to determine if information is there
If it is, information used directly from the cache (fast)
If not, data copied to cache and used there
Cache smaller than storage being cached
Cache management important design problem
Cache size and replacement policy

缓存 重要原则在计算机多层面执行  使用中的信息从较慢的存储暂时复制到较快的存储  首先检查较快的存储(缓存)确定信息是否存在 - 如果存在,直接从缓存使用信息(快速) - 如果不存在,数据复制到缓存并在缓存中使用  缓存小于被缓存的存储

Migration of data “A” from Disk to Register

Multitasking environments must be careful to use most recent value, no matter where it is stored in the storage hierarchy

Multiprocessor environment must provide cache coherency in hardware such that all CPUs have the most recent value in their cache

I/O Subsystem 

One purpose of OS is to hide peculiarities of hardware devices from the user
I/O subsystem responsible for
Memory management of I/O including buffering (storing data temporarily while it is being transferred), caching (storing parts of data in faster storage for performance), spooling (the overlapping of output of one job with input of other jobs)
General device-driver interface
Drivers for specific hardware devices

操作系统的目的之一是向用户隐藏硬件设备的特殊性 I/O 子系统负责 - I/O 的内存管理- 一般设备驱动程序接口 - 特定硬件设备的驱动程序

Computer System Environments

Traditional
Mobile
Client Server
Peer-to-Peer
Cloud computing
Real-time Embedded

Traditional 

Stand-alone general-purpose machines
But blurred as most systems interconnect with others (i.e., the Internet)
Portals provide web access to internal systems
Network computers ( thin clients ) are like Web terminals
Mobile computers interconnect via wireless networks
Networking becoming ubiquitous – even home systems use firewalls to protect home computers from Internet attacks
传统型 独立的通用机器 门户网站提供对内部系统的网络访问 移动计算机通过无线网络互连

 Mobile

Handheld smartphones, tablets, etc.
What is the functional difference between them and a “traditional” laptop?
Extra feature – more OS features (GPS, gyroscope)
Allows new types of apps like augmented reality
Use IEEE 802.11 wireless, or cellular data networks for connectivity
Leaders are Apple iOS and Google Android
移动型 更多操作系统功能(GPS、陀螺仪) - 允许使用增强现实等新型应用程序 - 使用 IEEE 802.11 无线或蜂窝数据网络进行连接

Client Server

Client-Server Computing
Dumb terminals supplanted by smart PCs
Many systems now servers , responding to requests generated by clients
Compute-server system provides an interface to client to request services (i.e., database)
File-server system provides interface for clients to store and retrieve files

 用户服务器端 计算机服务器系统为客户机请求服务(如数据库)提供接口 - 文件服务器系统为客户机存储和检索文件提供接口

Peer-to-Peer

Another model of distributed system
P2P does not distinguish clients and servers
Instead all nodes are considered peers
May each act as client, server or both
Node must join P2P network
Registers its service with central lookup service on network, or
Broadcast request for service and respond to requests for service via discovery protocol
Examples include Napster and Gnutella , Voice over IP ( VoIP ) such as Skype

p2p 不区分客户端和服务器 所有节点都被视为对等体都可以充当客户端、服务器 节点必须加入 P2P 网络 - 向网络上的中央查找服务注册其服务,或 - 通过发现协议广播服务请求并响应服务请求 

Cloud Computing

Delivers computing, storage, even apps as a service across a network
Logical extension of virtualization because it uses virtualization as the base for its functionality.
Amazon EC2  has thousands of servers, millions of virtual machines, petabytes of storage available across the Internet, pay based on usage
Many types
Public cloud – available via Internet to anyone willing to pay
Private cloud – run by a company for the company’s own use
Hybrid cloud – includes both public and private cloud components
Software as a Service ( SaaS ) – one or more applications available via the Internet (i.e., word processor)
Platform as a Service ( PaaS ) – software stack ready for application use via the Internet (i.e., a database server)
Infrastructure as a Service ( IaaS ) – servers or storage available over Internet (i.e., storage available for backup use)
Cloud computing environments composed of traditional OSes, plus VMMs, plus cloud management tools
Internet connectivity requires security like firewalls
Load balancers spread traffic across multiple applications

 

 云计算 - 通过网络提供计算、存储甚至应用程序服务 - 虚拟化的逻辑延伸,因为它使用虚拟化作为其功能的基础 云计算环境由传统操作系统、VMM 和云管理工具组成 - 互联网连接需要防火墙等安全措施 - 负载平衡器将流量分散到多个应用程序中

Real-Time Embedded Systems

Real-time embedded systems most prevalent form of computers
Vary considerable, special purpose, limited purpose OS,  real-time OS
Use expanding
Many other special computing environments as well
Some have OSes, some perform tasks without an OS
Real-time OS has well-defined fixed time constraints
Processing must be done within constraint
Correct operation only if constraints met

实时嵌入式系统是最普遍的计算机形式  有明确定义的固定时间限制 - 必须在限制范围内进行处理 - 只有满足限制条件才能正确运行

Key points An operating-system is a set of interrelated system software programs that host and control computer operations, utilize and run hardware and software resources, and provide common services to organize user interaction. • Operating-system executes in kernel mode, but user programs execute in user mode. • The CPU executes multiple processes by switching among them, but the switches occur frequently

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1607074.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

代码随想录算法训练营DAY28|C++回溯算法Part.4|93.复原IP地址、78.子集、90.子集II

文章目录 93.复原IP地址思路确定非法的范围树形结构 伪代码 78.子集思路伪代码实现CPP代码 90.子集II思路CPP代码用used去重的办法用set去重的版本不使用used数组、set的版本 93.复原IP地址 力扣题目链接 文章讲解:93.复原IP地址 视频讲解:回溯算法如何分…

Hadoop数据压缩

Hadoop数据压缩 Hadoop 数据压缩是一种用于减少存储空间和网络传输成本的技术,通常应用于大数据处理场景。随着数据量的不断增长,对存储和网络带宽的需求也在增加,因此采用数据压缩技术可以有效地减少数据的存储和传输成本,提高数…

ERROR in [eslint] reorder to top import/first

情景再现:在react开发的时候,导入组件、函数时报错:Import in body of module; reorder to top import/first … 原因:在import语句前有变量声明 解决: 变量的声明,要放在import之后 // 错误示例 import {…

Transformer 代码详解(Pytorch版)

前言 基于上一篇经典网络架构学习-Transformer的学习,今天我们来使用pytorch 搭建自己的transformer模型,加深对transformer的理解,不仅在NLP领域绕不开transformer,而且在CV领域也是很火热,很多模型都用到了注意力机…

Python 基于 OpenCV 视觉图像处理实战 之 OpenCV 简单人脸检测/识别实战案例 之三 简单人脸眼睛检测添加睫毛效果

Python 基于 OpenCV 视觉图像处理实战 之 OpenCV 简单人脸检测/识别实战案例 之三 简单人脸眼睛检测添加睫毛效果 目录 Python 基于 OpenCV 视觉图像处理实战 之 OpenCV 简单人脸检测/识别实战案例 之三 简单人脸眼睛检测添加睫毛效果 一、简单介绍 二、简单人脸眼睛检测添加…

手机照片误删怎么恢复?别慌,教你轻松恢复!

如今数字化的时代,人们已经离不开手机,手机里珍藏的照片也成为了人与人之间的羁绊。然而有时候我们会因为手机故障或者操作失误,将手机照片误删。那么手机照片误删怎么恢复呢?三招教你找回误删的手机照片,有效实用且方…

激活函数:GELU(Gaussian Error Linear Units)

激活函数:GELU(Gaussian Error Linear Units) 前言相关介绍GELU(Gaussian Error Linear Units)代码示例 参考 前言 由于本人水平有限,难免出现错漏,敬请批评改正。更多精彩内容,可点…

LUA脚本判断是否为空

系列文章目录 文章目录 系列文章目录前言 前言 前些天发现了一个巨牛的人工智能学习网站,通俗易懂,风趣幽默,忍不住分享一下给大家。点击跳转到网站,这篇文章男女通用,看懂了就去分享给你的码吧。 Lua是一个小巧的脚…

linux 的Jdk1.8详细安装部署教程

一、环境准备 1.下载安装包 下载地址,这是1.8的你也可以选择安装别的版本的 https://www.oracle.com/java/technologies/downloads/#java8-windows 选择想要的系统和对应的位数,点击下载即可 2.上传安装包 选择自己要安装的路径,&#x…

分步搭建HF区块链网络

一.搭建网络规划 采用容器环境,搭建1个排序节点(Orderer)、2个对等节点(Peer),另外用 一个fabric-cli容器。实训中的绝大部分命令是通过该容器执行的。 容器名称设置 二. 配置HF网络证书 首先docker ps 检查镜像,确保镜像为空 1.生成crypto…

TDesign:腾讯的企业级前端框架,对标elementUI和ant-design

elementUI和ant-design在前端开发者中有了很高知名度了,组件和资源十分丰富了。本文介绍腾讯的一款B端框架:TDesign TDesign 是腾讯公司内部推出的企业级设计体系,旨在为腾讯旗下的各种产品提供一致、高效、优质的设计支持。这个设计体系是由…

今天给大家推荐36套404页面模板

404页面是网站必备的一个页面,它承载着用户体验与SEO优化的重任。当用户访问不存在的页面时,服务器会返回404错误代码,并显示404页面。一个好的404页面可以帮助用户快速找到所需信息,并提升网站的用户体验。 以下是一些演示下载资…

【每日一题】2007. 从双倍数组中还原原数组-2024.4.18

题目: 2007. 从双倍数组中还原原数组 一个整数数组 original 可以转变成一个 双倍 数组 changed ,转变方式为将 original 中每个元素 值乘以 2 加入数组中,然后将所有元素 随机打乱 。 给你一个数组 changed ,如果 change 是 双…

【ES】springboot集成ES

1. 去Spring官方文档确认版本兼容性 这一版的文档里没有给出springboot的版本对应,但我在一个博主的文章里看到的es8.0以前的官方文档中就有给出来,所以还需要再去寻找spring framework和springboot的对应关系??? 还…

Java项目 苍穹外卖 黑马程序员

目录 day1一、项目效果展示二、项目开发整体介绍三、项目介绍3.1 定位3.2 功能架构3.3 产品原型3.4 技术选型 四、开发环境搭建4.1 前端环境4.2 后端环境 五、导入接口文档六、Swagger6.1 介绍6.2 使用方式6.3 常用注解 day2一、新增员工二、员工分页查询三、启用禁用员工账号四…

深度解析:基于隐马尔科夫模型的语音转文字技术

引言 语音转文字(Speech-to-Text, STT)技术作为人机交互的重要一环,在智能助手、自动字幕生成、语音命令识别等领域发挥着越来越重要的作用。隐马尔科夫模型(Hidden Markov Model, HMM)作为一种统计模型,因其在处理时间序列数据方面的优势,被广泛应用于语音识别系统中。…

蓝牙耳机推荐高性价比2024,运用六大实战技巧,精准捕获超值机型

​无论是通勤路上、健身房里,还是在家中放松时,蓝牙耳机都是我们享受音乐、提升生活品质的好帮手。随着蓝牙耳机技术的快速发展,各种款式层出不穷,选择起来确实不易。作为一名耳机发烧友,我认为是时候向大家推荐几款质…

Springboot+Vue项目-基于Java+MySQL的房屋租赁系统(附源码+演示视频+LW)

大家好!我是程序猿老A,感谢您阅读本文,欢迎一键三连哦。 💞当前专栏:Java毕业设计 精彩专栏推荐👇🏻👇🏻👇🏻 🎀 Python毕业设计 &…

Hive 解决数据倾斜方法

数据倾斜问题, 通常是指参与计算的数据分布不均, 即某个 key 或者某些 key 的数据量远超其他 key, 导致在 shuffle 阶段, 大量相同 key 的数据被发往同一个 Reduce, 进而导致该 Reduce 所需的时间远超其他 Reduce&…

深入探索生产者拦截器的使用以及源码设计

文章目录 一、介绍二、使用1. ProducerInterceptor接口2. 实现之统计3. 实现之二次处理4. 小结 三、实现原理1. 初始化流程2. 生效流程 四、总结 一、介绍 在软件设计中,为了方便能够应对不同的场景,一般在一些容易有差异的环节会考虑允许用户自定义逻辑…