Tsinghua operating system class notes

Operating system definition  is the control and management of computer systems hardware and software resources , rational organizational computer workflows and user-friendly use , a system software .

The role of the operating system  purpose is to improve the setting of the operating system of the computer system efficiency , and enhance the system's processing power , give full play to the system's efficiency , user-friendly use

Hardware interrupts and channel base ---

Interrupt  refers to the CPU after receiving the external interrupt signal to stop the original work, turn to handle the interrupt events, after completion back to the original break to continue working.

Interrupt process: interrupt request, interrupt, breakpoint (Pause the current task and save the site), interrupt handling routines, interrupt return (restoration site in the breakpoint and continue the original mission)

Channel (also called I / O processor)   is actually a function of a single, simple configuration I / O processor, which the CPU alone, and directly control the external device, data transfer with the memory.

It has its own I / O processor, instructions, to achieve a variety of complex programmable I / O processing

Concept multiprogramming techniques    simultaneously stored in the computer memory a few independent programs are under the control of the hypervisor interpenetrating run, sharing the CPU and peripherals and other resources. Multi-channel programming technology called a multi-batch system batch system

OS is a   system software  used in a multiprogramming operating mode can improve the system CPU and the external device    efficiency  . In general, in order to achieve multi-channel programming, computers need    more memory

Three operating systems basic types of batch systems, time-sharing system, real-time systems

Timesharing system: using the same computer system a plurality of users sharing (time divided by rotation) is referred to as a time-sharing system.

Time-sharing system, in order to enable multiple users to simultaneously interact with the system, the most critical issue is to   be able in a short period of time, so that all users can run programs;

Sharing features:

- simultaneous multi-way: the simultaneous multi-user operation, using a computer

- exclusive: Each terminal user feel exclusive computer;

- Time: the user's request in a relatively short period of time appropriate;

- Interactivity: Users can be human and computer - machine dialogue.

Response time is the time the user issues an instruction system that processed and the instructions needed to answer to

Real-time operating system is mainly used for real-time process control requirements, such as transaction processing, its main feature is  real-time and reliability

In the design of time-sharing operating system, the first thing to consider is the   interaction and response time  ; in the design of real-time operating system, the first thing to consider is   real-time and reliability  ; in the design of a batch system, the first thing to consider is   turnover time and system throughput

The current operating system, usually have a time-sharing, real-time and batch processing, also known as general-purpose operating system .

Modern operating systems main features :

Concurrency

Uniprocessor, when multiprogramming, concurrently macroscopically, microscopically performed alternately. Concurrency refers to the process, the operating system is a concurrent system.

Sharing

A plurality of processes share the limited resources of the computer system, a reasonable allocation of system resources in a period are alternately used by the plurality of processes.

Virtual sex

Mapped to a physical entity corresponding to a plurality of logical entities (time or space division). Virtual operating system is an important means to manage system resources, can improve resource utilization.

Asynchrony

Also known as asynchronous nature of uncertainty, the order refers to the process of the implementation and execution time and uncertainty of the results: A program execution uncertain outcome, not reproducible under B multiprogramming environment, the program runs in an asynchronous mode.

 

Why interrupts, exceptions, system call?

Interrupt: Because when IO devices, such as keyboard, then if you knock on the CPU in for anything. Not for you, then, you see no response will feel very bad to use, so this time we should stop interrupting the matter at hand, then the response is given

Exception: Since the divisor is 0 then this error is to run in order to know, get another go at this time will be a problem, so there is an exception to an error

System call: This bank safe place needs some protection, but also allows users to access and, this time on the need to call the system kernel level, because the kernel is the most secure

 

System call: Source: Application initiative responds to the service request sent by the operating system: asynchronous processing mechanism: continuous, transparent to the user

Exception: source: illegal instruction or other causes of the current instruction execution failed responds: synchronization mechanisms: killing or re-execute the command

Interrupt: Source: processing requests from a hardware device responds: synchronous or asynchronous processing mechanism: Wait and sustained

 

System calls and function calls the difference?

There is a conversion system call stack

It is a simple function call stack

System call function call stack and the stack is a different stack, because if it is the same, the function stack can be very simple to modify the value inside, it is unsafe

System call is safer than a function call, but the system call overhead is larger than function calls

The reason: Because there are several involved

1, the address space of the guide mechanism 2, the establishment of the stack 3, authentication parameter (authentication pass over in the end character does not meet parameters) 4, the address space mapping user mode kernel mode 4, kernel mode independently

 https://blog.csdn.net/qq_39823627/article/details/78736650   explain in detail the user mode and kernel mode

 

 Operation flow of a user mode and kernel mode

Also known as user mode to run user mode kernel runs state -> state when the user is running, and the state of the kernel run time

A simple example: When a user with read read the file, and then compilation of links compiled by three after the process, the function call to read kernel mode

 

Memory management

Relocation paged virtual memory segment

 

Inner and outer debris debris

In the debris: fragments is within the time allocated, the user application memory, but I dynamically allocated, it can not take advantage of the address is within the debris, because the power of the computer can only allocate memory address 2, but if the user application 511, it will actually be at 512, then 1 byte can not be used

 

External fragmentation: that after several assignments, the remaining free partition can not be allocated to other people, it will become debris

 

Contiguous memory allocation

1, the first assignment to find the first address can be assigned

2, find the optimal allocation of just greater than

3 worst match to find the maximum allocation

Advantages and disadvantages, emmm do not write

Contiguous memory defragmentation

1, the compact (what if there is no pointer, then references may be dynamically relocated can go all the free space together)

2, the partition exchange (preemption process in the waiting state and recovering the partition, to increase the available memory space)

 

 

  The Buddy System

A balanced distribution of advantages and disadvantages of various distribution pattern

How it works: the start block is a 2 ^ k, if the size of the application is 2 ^ (k-1) <= x <= 2 ^ k, then put the blocks assigned to it, if not, put the current block to split, split in half, if still not satisfied, also split, that is to say

Within the debris is reduced to a maximum size of the current block, efficiency is not low, is a comprehensive approach, this usage is used in the Linux kernel

 

Non-contiguous memory

Guess you like

Origin www.cnblogs.com/Lis-/p/12326366.html