Soft test (software designer) test site summary -- basic principles of operating systems

Soft test (software designer) test site summary: https://blog.csdn.net/Lzy410992/article/details/117321579

Hierarchical structure of computer system: hardware layer - operating system layer - language processing program layer - application layer
insert image description here

The purpose of the operating system is to manage the software and hardware resources in the computer system and provide a convenient interface between the user and the computer.

Functions of the operating system: process management, storage files, file management, job management, device management

Process management

Process and thread:

Process: The execution process of a program is a dynamic concept, and it is the basic unit for allocating and managing resources during the execution of the program.
Thread: The basic unit of CPU scheduling and dispatch, it can share all the resources owned by the process with other threads belonging to the same process.

Threads are part of a process, a thread can only belong to one process, and a process can have multiple threads, but at least one thread. Threads in the same process can share resources owned by that process. Access what the process owns to open files, timers, semaphore mechanisms, etc., but does not provide a stack pointer for a thread in a shared process.

insert image description here
Three basic states:
Ready state: The process is in a state of being ready to run, and it can run as soon as it gets the CPU
Running state: The state of the running process
Blocking state: Due to some factors , causing the process to be unable to run even if it reaches the CPU (it also needs I/O devices), it will enter a blocking state

Process synchronization and mutual exclusion:

insert image description here

Time- sharing system: In a system, multiple users use the same computer time-sharing
Real-time system: The computer can process external information at a fast enough speed and respond quickly within the time range allowed by the controlled object.

PV operation and predecessor graph:

insert image description here
PV operation uses the semaphore mechanism, which is an effective process synchronization and mutual exclusion tool, which can realize the mutually exclusive use of resources.

The system adopts PV operation to achieve synchronization and mutual exclusion of processes. If there are n processes sharing k scanners, the initial value of the semaphore is k.
Semaphore S, the initial value is 0 or a positive integer, and the value range is [-(nk), k] . When S is positive, it indicates the number of available resources, and when S is negative, it indicates the waiting process number.
insert image description here

PV operation:

//P减一操作:S>=0系统有资源,进程执行,S<0进程进入阻塞状态
//V加一操作:S>0进程执行,S<=0系统中有等待使用资源的进程,唤醒等待的进程
wait(S){
    
    
	while(S<=0);
	S--;
}

signal(S){
    
    
	S++;
}

Producer Consumer Model:
insert image description here

Example:insert image description here
Answers: A, C
insert image description here
Answers:

Deadlock problem:

insert image description here
Assuming that there are 12 resources and each process is allocated 4 resources, a deadlock just happens, and when any process obtains another resource, the deadlock is released.
When k processes require n resources, the minimum number of resources without deadlock = k*(n-1)+1

insert image description here

Conditions for deadlock formation: any one of mutual exclusion, hold and wait, no preemption, and loop waiting occurs

Solutions to the deadlock problem: deadlock prevention, deadlock avoidance (banker's algorithm)
insert image description here

example:insert image description here
insert image description here
insert image description here

Process resource graph:
insert image description here

insert image description here
Analysis:
R1 has two resources, one is allocated to P1 and the other is allocated to P3. At this time, P2 applies for the resources of R1, because R1 has no available resources at this time, and P2 is blocked.
R2 has three resources, one resource has been allocated to P1, P2, and P3, and P1 applies for resource R2 again at this time. P1 blocks
R3 and has two resources, which have been allocated to P2, and P2 applies for one resource and allocates it to it, so P3 is a non-blocking node
. Simplify: look at starting from a non-blocking node, delete all bian edges around P3 to make it an isolated point, and then look at the remaining resources allocated again as above, If only a group of isolated points remain at the end, it means that the resource graph can be simplified.

Storage management

insert image description here
A dynamic partition allocation algorithm based on sequential search:

First fit (FF) algorithm: search sequentially from the beginning of the chain until a free partition with a size that meets the requirements is found.

Cyclic first fit (next fit, NF) algorithm: instead of searching from the beginning of the chain every time, the search starts from the next free partition of the last found free partition until a free partition that meets the requirements is found.

Best fit (BF) algorithm: When allocating memory for a job, always allocate the smallest free partition that can meet the requirements to the job to avoid "overkill".

Worst fit (worst fit, WF) algorithm: Contrary to the best fit algorithm: when scanning the entire free partition table or linked list, it always selects a largest free area and divides a part of the storage space for the job to use.

Page storage:

Logical address = page number + intra-page address
Physical address = physical block number + physical address
insert image description here

Example Question:
insert image description here
Answers: D, B

Segmented Storage: Segmented Paged Storage
insert image description here
:
insert image description here
Fast Table:
insert image description here
Page Replacement Algorithm:
insert image description here

FIFO algorithm:
insert image description here
Least recently used algorithm:
insert image description here

Example:
insert image description here
Answers: B, C

file management

insert image description here
The index file structure defaults to 13 nodes

insert image description here
The size of each data item is 4B, so 1 KB / 4 B = 1024 / 4 = 256 can be stored in one disk block, and the first 5 blocks (0 to 4) use direct addresses, so the logical number is 5. The physical block number is 58, and the physical block numbered 261 corresponds to the 262nd physical block, which is the physical block numbered 187 (direct index 5 + 90 corresponding to 256 = 261).

Tree directory structure:
insert image description here

Free storage space management:
insert image description here

Example Question:
insert image description here
Answers: D, B
insert image description here

Device management

insert image description here

Required equipment and Spooling technology:
insert image description here
Microkernel OS:
insert image description here

Embedded Systems:

Embedded system initialization process:
chip machine initialization: the initialization of embedded microprocessor, the embedded microprocessor is gradually set from the default state at power-on to the working state required by the system, which is a pure hardware initialization process.
Board-level initialization: To complete the initialization of other hardware other than the embedded microprocessor, some software data structures and parameters are required. It includes the initialization of hardware and software.
System-level initialization: mainly software initialization, mainly for the initialization of the operating system.

Features of embedded operating system:
Miniaturization: From the perspective of performance and cost, it is hoped that the amount of resources and system code occupied is small.
Customizable: In view of reducing costs and shortening the development cycle, it is required that the embedded system can run on different microprocessor platforms, and can configure the structure and function according to hardware changes.
Real-time: The embedded operating system is mainly used in process control, data acquisition, transmission communication, multimedia information and occasions where rapid response is required in key key areas, and has high real-time requirements.
Reliability: System components, modules, and architectures must be as reliable as they should be. Provide fault tolerance and fail-safe measures for critical critical applications.
Easy portability: It adopts the underlying design technology of hardware abstraction and trigger support package, which is easy to port.

The past real questions of the soft exam and related video courseware of station B:
link: https://pan.baidu.com/s/1e4d1-HGOzcEVHSK8Q0j_xA
Extraction code: acij

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324271898&siteId=291194637