【操作系统】知识点集合

操作系统(Operating System,OS)是指控制和管理整个计算机系统的硬件和软件资源,并合理地组织调度计算机的工作和资源的分配;以提供给用户和其他软件方便的接口和环境;它是计算机系统中最基本的系统软件。

OS roles

1.系统资源管理者Resource manager

Track and record resource usage

Determine resource allocation strategy------algorithm

Allocate and recover resources

Improve resource utilization

Coordinate conflicts between multiple processes for resource requests

five basic functions

1.Process/Thread management (CPU management)

2.Memory management

3.File management

4.I/O device management

5.User interface

2.向上层提供服务Provide users with various services(services of OS)

给用户使用的:GUI、命令接口(联机命令接口、脱机命令接口)

给软件使用的:程序接口

Typical services

1.流程创建和执行process creation and execution

2.file and directory operation

3.I/O device handling

4.various statistics

3.接近硬件Extensions to hardware

需要实现对硬件机器的拓展
没有任何软件支持的计算机成为裸机。在裸机上安装的操作系统,可以提供资源管理功能和方便用户的服务功能,将裸机改造成功能更强、使用更方便的机器
通常把覆盖了软件的机器成为扩充机器,又称之为虚拟机

OS establishes an equivalent extension machine between applications and hardware. (virtual machine)

abstract hardware and improve portability; program more easily than hardware

Main characteristics of OS

并发concurrency

并发是指两个任务可以在重叠的时间段内启动、运行和完成。concurrency is when two tasks can start, run, and complete in overlapping time periods.

并行是指任务实际上同时运行,例如在多核处理器上。parallelism is when tasks literally run at the same time, e.g. on a multi-core processor.

sharing

OS shares the limited system resources with multi-users' programs OS must allocate and use the system resources reasonably. Resources are alternately used by multiple processes in a time period sharing type exclusive sharing (i.e. printer) inclusive sharing (i.e. file)

虚拟化virtualization

虚拟机(virtual machine)是在操作系统中模拟硬件设备,然后运行另一个操作系统,

Virtualization A physical entity is mapped to several corresponding logical entities time-sharing or space-sharing Virtualization is an important means for OS to manage system resources. High resource utilization CPU----virtual processor of each process Memory---each process has a separate virtual address space(code+data+stack) Display device-multi-window or virtual terminal

asynchronization (异步)(random)

Asynchronous means that you can execute multiple things at a time and you don't have to finish executing the current thing in order to move on to next one.

Random: OS must respond to the events which occur in an unpredictable order. Reason: unpredicatable process speed------multiple processes execute concurrently difficult to reproduce the state of the system (including running error)

synchronization(同步) Synchronous basically means that you can only execute one thing at a time

Classification of OS

Batch operating system Time-sharing operating system Real-time operating system Network operating system Distributed operating system Embedded operating system

Central Processing Unit (CPU) mode

CPU generally composes of control unit(CU), arithmethic-logic unit(ALU), a series of registers and cache. Types of registers General purpose registers

Special purpose registers

Program Counter (PC):It contains the memory address of the next instruction to be fetched它包含要获取的下一条指令的内存地址 Instruction Register (IR):It holds the instruction which is currently been executed. Flag register: It is a collection of status flag bits for a processor Program Status Word(PSW): It is an IBM System/360 architecture and successors. It refers as a flag register. It keeps track of the current state of the system, such as, mode Memory Address Register (MAR):holds the memory location of data that needs to be accessed Memory Buffer Register (MBR): also known as memory data register (MDR)stores the data being transferred to and from the immediate access storage也称为内存数据寄存器 (MDR),用于存储传入和传出即时访问存储的数据

Two CPU modes in OS (dual mode)

Kernel mode(Privileged mode):Run operating system programs

Privileged instructions that can only be used by OS and cannot be used by the user (in the kernel mode)

User mode (Non privileged mode):Run user program

Non-privileged instructions that user program can use

Switching between CPU modes

Interrupt /Exception handling

It is one of the core mechanisms of modern computer systems. In order for a computer to effectively manipulate interrupt/exception, its hardware and software must work together.

Interrupt / exception mechanism is one of the core mechanisms of modern computer systems. Hardware and software work together to make the computer system fully Exert ability.

Interrupt response

There is an Interrupt control register (ICR) in processor The process of discovering interrupts and receiving interrupts, implemented completed by interrupt hardware components

Interrupt Vector Table

Interrupt vectors are addresses that inform the interrupt handler as to where to find the ISR (interrupt service routine, also called interrupt service procedure). All interrupts are assigned a number from 0 to 255, with each of these interrupts being associated with a specific interrupt vector.

Interrupt Handler

While designing OS, it programs a corresponding handler for each type of interrupt / exception event, and sets the interrupt vector table. If the system responds to an interrupt while the system is running, the interrupt hardware component transfers CPU control to the interrupt handler

Save related registers' information Analyze the specific cause of the interruption / exception Perform the corresponding interrupt handler Restore the context and return to the program interrupted by the event

system call

OS service that users can call while programming

Role of system calls

System calls are the only interface provided by OS to programmers Make the CPU mode from the user mode into the kernel mode

Design of system call

Select a special instruction: trap instruction

System call number and parameters

System call table

Parameter passing process

Parameters by trap instruction Passing parameters through general purpose registers Create a dedicated stack area in memory to pass parameters

System call execution

When a call is made in user mode that starts a system call, CPU executes a special trap instruction, which switches CPU mode from user to kernel . System call routine Save the context; save the parameters in the kernel stack; transfer control to the corresponding system call routine by checking the system call table Execute system call routines Restore the context and return to the user program

Process

A process is basically a program in execution It is the unit of system resource allocation and scheduling by OS Transform one CPU into multiple virtual CPUs System resources are allocated in units of processes, such as memory, files, ... Each process has an independent address space OS dispatches the CPU to the required processes Multiple processes can be related to the same program.

Process types

System process, user process Foreground process, background process I/O bound process, CPU bound process

Process hierarchy

UNIX: Process family tree, init as the root WINDOWS: Same status

multiprogramming

In a multiprogramming system there are one or more programs loaded in main memory which are ready to execute. Only one program at a time is able to get the CPU for executing its instructions (i.e., there is at most one process running on the system) while all the others are waiting their turn. The main idea of multiprogramming is to maximize the use of CPU time.

Concurrent environment

There are two or more programs begin to run, but not ended, at the same time period with a single CPU. The order is not predetermined

Process states and state transitons

In a multitasking computer system, processes may occupy a variety of states When a process executes, it passes through different states. These stages may differ in different OS, and the names of these states are also not standardized. Three states ready, running, waiting/blocked Five states new, ready, running, waiting/blocked, terminated Seven states new, ready, running, waiting/blocked, blocked suspend, ready suspend, terminated

PCB

A process handles the operating system activities through PCB (Process control Block) A PCB is a data structure used by OS to store all the information about a process. It is also known as a process descriptor. When a process is created (initialized or installed), the operating system creates a corresponding PCB. There is a one-to-one correspondence between the process and the PCB The process table is an array of PCBs, that means logically contains PCBs for all the current processes in the system.

Components of PCB

Naming the process State of the process Resources allocated to the process Memory allocated to the process Scheduling information Input / output devices associated with process

Prcess ID: In computer system there are various process running simultaneously and each process has its unique ID. Process State: It refers the states of the processes. Program counter: It is used to point to the address of the next instruction to be executed in any process Register Information: It is comprising with the various registers, such as index and stack that are associated with the process. Scheduling information: It is used to set the priority of different processes. Accounting information: It stores the details relate to central processing unit (CPU) utilization and execution time of a process. I/O information:It stores the details pertaining to resource utilization and file opened during the process execution Memory related information: It comprises of page and segment tables. It also stores the data contained in base and limit registers.

process scheduling

CPU switch

Context Switching involves storing the context or state of a process so that it can be reloaded when required and execution can be resumed from the same point as earlier. This is a feature of a multitasking operating system and allows a single CPU to be shared by multiple processes. Context Switching Triggers Multitasking(多任务处理): In a multitasking environment, a process is switched out of the CPU so another process can be run. Interrupt Handling User and Kernel Mode Switching

context switching

When a process is running: 1.its hardware state is stored in registers on the CPU. 2.Registers 2.1.program counter, PSW, stack pointer, values of general-purpose registers and other control registers 3.When the process is not running, the values of these registers are stored in PCB; 4.when the operating system wants to run a new process, the relevant values in the PCB are sent to the corresponding registers

process queue

OS creates one or more queues for each type of process Element of queue is PCB With the state transitions, its PCB goes from one queue to another

Events in multiple waiting queues are different The ready queue can also be multiple Only one process in the running queue with single CPU

process control

Process management functions are usually placed in the OS kernel The OS kernel contains two aspects: 1.Supporting functions:interrupt processing, clock management, primitive operation 2.Resource management functions:process management, memory management, device management

ps:A primitive is the smallest 'unit of processing' available to a programmer of a given machine, or can be an atomic element of an expression in a language. Primitives are units with a meaning, i.e., a semantic value in the language.

process creation

process termination

process blocking

A process in the running state expects an event to occur duri

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

岩塘

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值