首页 > 其他分享 >Operating System Concepts 9th: Chapter 1 Introduction

Operating System Concepts 9th: Chapter 1 Introduction

时间:2024-03-28 18:35:38浏览次数:32  
标签:Chapter kernel Introduction System system operating mode memory CPU

An operating system is a program that manages a computer’s hardware. It
also provides a basis for application programs and acts as an intermediary
between the computer user and the computer hardware.

操作系统的定义:一个管理计算机硬件,并作为用户与硬件之间的中介为应用程序提供基础的程序。

What Operating Systems Do

the operating system is the one program running at all times on the
computer—usually called the kernel. (Along with the kernel, there are two
other types of programs: system programs, which are associated with the
operating system but are not necessarily part of the kernel, and applic-
ation programs, which include all programs not associated with the oper-
ation of the system.)

操作系统是一个在计算机运行期间一直在running的程序,也被称为内核。除了内核外还有另外两种程序:系统程序,直接与操作系统交互,但不属于内核。应用程序,不直接与
操作系统交互。

For a computer to start running—for instance, when it is powered up or
rebooted—it needs to have an initial program to run. This initial program,
or bootstrap program, tends to be simple. Typically, it is stored within
the computer hardware in read-only memory (ROM) or electrically erasable
programmable read-only memory (EEPROM), known by the general term
firmware. It initializes all aspects of the system, from CPU registers to device
controllers to memory contents. The bootstrap program must know how to load
the operating system and how to start executing that system. To accomplish
this goal, the bootstrap program must locate the operating-system kernel and
load it into memory.

计算机启动时先启动固件(ROM或EEPROM)中的bootstrap程序,由该程序初始化整个系统,然后加载并执行操作系统内核。

Some services are provided outside of the kernel, by system programs that
are loaded into memory at boot time to become system processes, or system
daemons that run the entire time the kernel is running. On UNIX, the first system
process is “init,” and it starts many other daemons. Once this phase is complete,
the system is fully booted, and the system waits for some event to occur.

内核加载完毕后会加载系统程序,使他们成为系统进程或称守护进程,并且在整个内核运行期间都存在。在UNIX中第一个系统进程是
init进程,他还会启动许多其他守护进程。一旦这一阶段完成,系统就完全启动了,开始等待事件发生。

The occurrence of an event is usually signaled by an interrupt from either
the hardware or the software. Hardware may trigger an interrupt at any time
by sending a signal to the CPU, usually by way of the system bus. Software
may trigger an interrupt by executing a special operation called a system call

事件通常由中断触发,硬件中断由硬件通过系统总线发信号给CPU触发,软件中断通过执行系统调用触发。

Operating-System Structure

One of the most important aspects of operating systems is the ability
to multiprogram. A single program cannot, in general, keep either the CPU
or the I/O devices busy at all times. Single users frequently have multiple
programs running.Multiprogramming increases CPU utilization by organizing
jobs (code and data) so that the CPU always has one to execute.

操作系统最重要的一个方面就是多道程序的能力。多道程序设计可以增加CPU的利用率。

The idea is as follows: The operating system keeps several jobs in memory
simultaneously (Figure 1.9). Since, in general, main memory is too small to
accommodate all jobs, the jobs are kept initially on the disk in the job pool.
This pool consists of all processes residing on disk awaiting allocation of main
memory.

为了实现多道程序,操作系统要把多个任务同时放入内存,但内存太小了,所以任务一开始会被放到磁盘的任务池中,等待被分配内存。

In a multiprogrammed system, the operating system simply switches to,
and executes, another job. When that job needs to wait, the CPU switches to
another job, and so on. Eventually, the first job finishes waiting and gets the
CPU back. As long as at least one job needs to execute, the CPU is never idle.

多道程序系统中,操作系统会在一个任务需要等待时将CPU切换给另一个任务,并且等待结束时将CPU还给它。这样只要由任务需要执行CPU就不会空闲。

Time sharing (or multitasking) is a logical extension of multiprogramming.In
time-sharing systems, the CPU executes multiple jobs by switching among them,
but the switches occur so frequently that the users can interact with each program
while it is running.

分时是多道程序设计的扩展,CPU频繁地在多个进程间切换以达到用户可以与多个进程交互的目的。

A program loaded into memory and executing is called a process.

被加载到内存中并且正在执行的程序叫做进程。

If several jobs are ready to be brought into memory, and if there is not enough room
for all of them, then the system must choose among them. Making this decision involves
job scheduling

任务调度决定磁盘中哪个任务被加载到内存。

if several jobs are ready to run at the same time, the system must choose which job
will run first. Making this decision is CPU scheduling.

CPU调度决定内存中哪个任务被执行。

In a time-sharing system, the operating system must ensure reasonable
response time. This goal is sometimes accomplished through swapping,
whereby processes are swapped in and out of main memory to the disk. A more
common method for ensuring reasonable response time is virtual memory, a
technique that allows the execution of a process that is not completely in
memory. The main advantage of the virtual-memory scheme is that it
enables users to run programs that are larger than actual physical memory.
Further, it abstracts main memory into a large, uniform array of storage,
separating logical memory as viewed by the user from physical memory.
This arrangement frees programmers from concern over memory-storage
limitations.

为了保证实时交互,进程需要在内存与磁盘间交换。一个重要的方法就是虚拟内存,可以使程序部分加载,此外还可以使用户运行大于物理内存的程序,并将内存抽象为一个统一的数组,即逻辑内存,使程序员可以摆脱物理内存的限制。

Operating-System Operations

A trap (or an exception) is a software-generated interrupt caused
either by an error (for example, division by zero or invalid memory access)
or by a specific request from a user program that an operating-system service
be performed.

陷入是一种由软件触发的中断,可能是发生了错误也可能是需要系统服务。

we need two separate modes of operation: user mode and kernel mode (also
called supervisor mode, system mode, or privileged mode). A bit, called the
mode bit, is added to the hardware of the computer to indicate the current
mode:kernel (0) or user (1).

为了系统的安全性,我们将系统分为两种模式:用户模式和内核模式。由mode bit来区分当前处于哪种模式。

when a user application requests a service from the operating system (via a
system call), the system must transition from user to kernel mode to fulfill
the request.

当用户程序请求系统服务时系统由用户模式切换到内核模式。

At system boot time, the hardware starts in kernel mode.

系统启动时处于内核模式。

The dual mode of operation provides us with the means for protecting the
operating system from errant users—and errant users from one another. We
accomplish this protection by designating some of the machine instructions that
may cause harm as privileged instructions. The hardware allows privileged
instructions to be executed only in kernel mode. If an attempt is made to
execute a privileged instruction in user mode, the hardware does not execute
the instruction but rather treats it as illegal and traps it to the operating system.

为了防止恶意的用户,我们将可能造成损害的指令设为特权指令,只有在内核模式才能执行,当在用户模式想要执行特权指令时会发生trap.

Initial control resides in the operating system, where instructions are executed
in kernel mode. When control is given to a user application, the mode is set to
user mode. Eventually, control is switched back to the operating system via an
interrupt, a trap, or a system call.

当控制权交给用户程序时系统会切换到用户模式,最终会由中断,陷入,或系统调用将控制权交回给操作系统。

When a system call is executed, it is typically treated by the hardware
as a software interrupt. Control passes through the interrupt vector to a
service routine in the operating system, and the mode bit is set to kernel
mode.

当执行系统调用时,硬件会将其视为软中断,控制权会通过中断向量转移给系统服务例程,并将模式设为内核模式。

标签:Chapter,kernel,Introduction,System,system,operating,mode,memory,CPU
From: https://www.cnblogs.com/is-zq2003/p/18102349

相关文章

  • Lab2:System Call
    trace该系统调用程序,可以跟踪其他的系统调用命令,该系统调用的形参为一个整数掩码。其具体实参为1<<sys_call所得到的整数值,sys_call是一个系统调用指令在内核中定义的系统调用编号。返回值包含进程id,系统调用sys_call的名称和返回值。并且trace指令可以跟踪当前进程和它派生的......
  • SystemServer 启动流程
    SystemServer启动流程一、介绍SystemServer是Android进入Launcher前的最后准备,顾名思义,它提供了众多由Java语言编写的服务在Zygote自启动过程中,参数boolstartSystemServer为真的话,那么在ZygoteInit.java/main()就会调用函数forkSystemServer()生成SystemSer......
  • 【Azure Cloud Service】部署云服务时候遇见 Last exit code: 0. Last role exception
    问题描述部署云服务时候遇见Lastexitcode:0.Lastroleexception:(System.IO.FileNotFoundException)错误,提示无法加载System.Runtime。Recoveringrole...Applicationstartuptask0finishedsuccessfully.Lastexittime:[2024/03/27,20:23:31.142].Lastexit......
  • System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3
    VS2022.netCore5.0项目编译没问题,运行时报这个错System.IO.FileNotFoundException:“Couldnotloadfileorassembly'System.Runtime,Version=6.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a'.系统找不到指定的文件。” 我这里遇到这个问题的原因是,v......
  • Android Framework system_server进程启动
    哈喽大家我是Zzz.今天分享的blog是system_server进程的启动,环境基于aosp13_r6,话不多说直接上干货前言:system_server是系统核心服务的一个进程,这个进程包含了系统中核心Service的运行,给系统提供如:Window的管理、Activity的管理,系统的核心功能都在System_server中;在ZygoteIni......
  • BitLocker和EFS(Encrypting File System)是Windows操作系统中用于数据加密的两种不同的
    BitLocker和EFS(EncryptingFileSystem)是Windows操作系统中用于数据加密的两种不同的功能。BitLocker:BitLocker是一种全磁盘加密技术,它可以加密整个硬盘驱动器上的数据,包括操作系统、应用程序和用户数据等。BitLocker可以保护计算机在启动时的数据安全,并且可以通过预启动认......
  • System.Security.Cryptography.RijndaelManaged()
    以下为ai生成:System.Security.Cryptography.RijndaelManaged 是.NET框架中的一个加密类,用于提供高级加密标准(AES)算法的实现。AES是一种强大的对称加密算法,它可以用于保护数据的安全。以下是一个使用RijndaelManaged进行数据加密和解密的简单例子:usingSystem;usingSystem.I......
  • As a reader --> On the Robustness of ML-Based Network Intrusion Detection System
    ......
  • 使用systemd部署r-nacos
    1、前言r-nacos是一个用rust实现的nacos服务。相较于javanacos来说,是一个提供相同功能,启动更快、占用系统资源更小(初始内存小于10M)、性能更高、运行更稳定的服务。r-nacos设计上完全兼容最新版本nacos面向clientsdk的协议(包含1.x的httpOpenApi,和2.x的grpc协议),支持使用nac......
  • Windows System Assessment Tool(WinSAT)是Windows操作系统中的一个工具,用于评估和测量
    您可以使用winsat命令来运行性能评分测试程序,也就是WindowsExperienceIndex(Windows体验指数)测试。这个测试程序能够评估您计算机的性能,并为各个硬件组件打分,最终得出一个综合的基准分数。WindowsSystemAssessmentTool(WinSAT)最早出现在WindowsVista操作系统中。它是由......