2023 Software Test Intermediate "Software Designer" (Exam Preparation Sprint Version) | Operating System

Table of contents

1. Concepts related to operating system

1.1 Functions of the operating system

1.2 Special operating systems

2. Process management

2.1 Concept of process

2.1.1 The concept of thread

2.1.2 Process status

2.2 Process Scheduling

2.2.1 Concept of PV operation

2.2.2 Semaphores and PV operations

2.2.3 Precursor graph and PV operation

3. Storage management

3.1 Page storage

3.2 Segment storage

3.3 Segment page storage

3.4 Disk management

4.Device management

4.1 I/O management software layering

4.2 Concepts related to I/O management software

5.File management

5.1 File related concepts

5.2 Tree directory structure

5.3 Bitmap

5.4 Index file structure


1. Concepts related to operating system

Test points: Understand the concepts related to operating systems, including the functions of operating systems, the classification of special operating systems, and the characteristics of embedded operating systems.

Test method: Identify the operating system level; determine whether the description of the operating system is correct; determine whether part of the thread content can be shared

Key points:

1.1 Functions of the operating system

Consider the hierarchical structure of a computer operating system, as shown below:

6ff3bcb7686846c294423ca7b84f85d7.jpeg

1.2 Special operating systems

118f3d484de84f5ca27c7dc6b8133981.jpg

Focus on embedded operating systems!

2. Process management

2.1 Concept of process

2.1.1 The concept of thread

Test method: What are the resources that threads can share and the resources that cannot be shared?

Can share Memory address space, code, data, files
cannot share Program counter, registers, stack

2.1.2 Process status

Key points:

1. Three-state model:

6d02e832e1fd4b2e91ce4977329a8005.jpg

important point:

        1. A single processor will not have two running states

        2. Waiting cannot directly enter the running state.

2. Five-state model :

c2b88e3b73294d17845fcee5fcb1975c.jpg

 Note the pending state

2.2 Process Scheduling

2.2.1 Concept of PV operation

Key points:

1. Critical resources : resources that need to be shared between multiple processes in a mutually exclusive manner;

2. Mutual exclusion and synchronization concepts;

3. Semaphore: A special global variable that can represent the number of resources. When it is a negative number, it can also represent the number of queued processes.

2.2.2 Semaphores and PV operations

Test method: Determine whether it is a synchronous or mutually exclusive semaphore; what is the initial value of the semaphore; fill in the appropriate pv operation in the flow chart

Key points:

The pv operation accesses critical resources;

p locks, v unlocks, pv lives and dies together;

p operation, s-1; v operation, s+1;

1. Single buffer-mutual exclusion model: In the same process, p and v operations are performed before and after using the buffer, and the initial value of the semaphore s is the number of buffers.

2. Single buffer-synchronization model: Two processes, s1 and s2, perform pv operations in the two processes. The initial value of the semaphore that locks p first is 1, and the initial value of the semaphore that unlocks v first is 0.

3. Single buffer-mutual exclusion synchronization combination: two processes cannot use the buffer at the same time, and a mutual exclusion semaphore s is added to the buffer separately. It is locked before use and unlocked after use.

4. Determine the initial value of the buffer semaphore: the buffer with space bit m, the initial value of s is m, and the buffer itself is also a critical resource.

2.2.3 Precursor graph and PV operation

Test method: Combine the predecessor graph with PV operation, mark the semaphore according to the arrow line of the predecessor graph, and then fill in the blanks according to the process graph:

Key points:

Label semaphores for arrows: An arrow corresponds to a semaphore, not a process or activity.

The starting point of the arrow line is the V operation (that is, after the completion of the predecessor activity, the V operation is used to notify the successor activity);

The end position of the arrow line is the P operation (that is, the P operation is used to check whether the predecessor activity is completed before starting the subsequent activity).

0c00d6c46c8b447aa65d89d53cb64b00.jpeg

Example: What should be filled in abcdef in the picture?

59d8324301ec4e4080cf43edfc8eb53d.jpegQuestion-solving skills:

1. First mark the pv operation and semaphore in the arrow diagram

2. The order of marked semaphores is matched according to the order of activities from small to large.

3. Determine the relationship between semaphores and mark them in the pv operation

2.2.4 Deadlock (involving calculation)

Deadlock: refers to the phenomenon that two or more processes require each other's resources that the other party already occupies, resulting in the inability to continue running.

Test points: Understand the conditions of deadlock, master deadlock resource allocation calculation and banker's algorithm

Test method: The main test forms for this knowledge point are: calculating the number of deadlock resources according to the process situation; using the banker's algorithm to allocate resources according to the number of resources, and judging whether the sequence given in the option is safe.

Key points:

3eae90eaa5c246c2a8017d0c76f66ef2.jpeg

1. Understand the conditions and prevention concepts of deadlock: Process management is the core of the operating system, but if it is not designed properly, deadlock problems will occur. If a process is waiting for something that cannot happen, the process is deadlocked. And if one or more processes deadlock, it will cause a system deadlock.
2. Based on the process and resource allocation given in the question stem, determine the minimum number of resources or other parameters that cause a deadlock :

In this case, when allocating resources, each process gets the number of resources that can complete the process minus one. This is the worst case for deadlock. In this case, one more resource can solve the deadlock problem, which is impossible. A deadlock is formed.

Assume that m processes each require w R resources, and there are n R resources in the system. The conditions for no deadlock at this time are:

m*(w-1)+1<=n。

n<w: The system must be deadlocked; m*(w-1)<=n<=w, it may be avoided or deadlocked.


3. Banker's algorithm: When a process's maximum demand for resources does not exceed the number of resources in the system, the process can be admitted. A process can request resources in installments, but the total number of requests cannot exceed the maximum demand. When the existing resources of the system cannot satisfy the number of resources needed by the process, the request for the process can be postponed, but the process can always get the resources within a limited time. Use the Banker's algorithm to determine whether the relevant process sequence will form a deadlock, and if so, it is an unsafe sequence.

2.2.5 Process resource graph

49983a83dcdd46638d95b0725e09cfb9.jpeg

e47282622a7a4a46a26e8d6fdafb8e3d.jpeg

3. Storage management

3.1 Page storage (involving calculations)

Page storage : Divide the program and memory into blocks of the same size, and transfer the program into the memory in units of pages.

Test points: the physical address corresponding to the logical address, the length of the address in the page

05160c0d291742529f70ad5d89cc0abc.jpg

Key points:
1. The allocated pages are not enough -> page fault interrupt occurs -> reallocation solves, eliminates the allocated memory, and new allocation -> eliminates the original page: 1. The elimination access bit is 0, 2. Multiple accesses The bit is 0, and the modified bit is 0 for elimination first.

2. Elimination algorithm:

For multiple elimination algorithms:

Optimal algorithm OPT (ideal type),

Random algorithm RAND (randomness) ,

First in first out FIFO (may produce "jitter"),

LRU is used at least recently (based on the locality principle).
 

3.2 Segment storage

Test point: Judgment of legality of segmented storage address

Key points:

1. Advantages and disadvantages of segmented storage

Advantages: Multi-programs share memory, and modifications to each program do not affect each other.

Disadvantages: low memory utilization, large waste of memory fragmentation

2. Judgment of legality of segment storage address

Logical address within the segment (segment number, offset within the segment)

The offset within the segment must be ≤ the corresponding segment length range

b8c0e14b0078485ba50de8c05633b4cd.jpg

3.3 Segment page storage

Test points: calculation of segment number length, page number length, and page address length calculation

148f9b682b2640fb815412161d0995c7.jpg

3.4 Disk management (involving computing)

Test points: Master disk-related problem-solving skills (disk access time calculation; disk optimization storage problem; arm-shift scheduling algorithm problem)

Test method: Calculate the reading time of disk data; optimize the data reading time after storage; related applications of disk scheduling algorithms;

Key points:

1. Access time = seek time + waiting time

577946d0b2a14cd182a881b557308ea4.jpg

2. Disk scheduling algorithm (when considering arm movement, only cylinder information needs to be considered, sectors do not need to be considered, multiple sectors on the same cylinder are in random order):

First come, first served FCFS (who applies first, first served);

SSTF gives priority to the shortest seek time (the distance to the current position of the head is judged when applying, and the one with the shortest time is served first);

Scan algorithm SCAN ( elevator algorithm, two-way scan);

Circular scan CSCAN (unidirectional scan)

3. During the arm movement scheduling process, what should I do if there are multiple sectors on the same cylinder?
Generally speaking, when it comes to the arm-moving scheduling algorithm, you only need to consider the arm-moving process and check the cylinder order. The rotation waiting time is related to whether multiple heads (disk surfaces) can read and write concurrently. Judging from the current disk technology, it supports simultaneous reading and writing of multiple disk surfaces. So as long as they are on the same cylinder, there is no requirement for the sector order.

4. Single buffer and double buffer

4.Device management

4.1 I/O management software layering

I took the test more than twice!

566a8744606944ac8636352e92e2fcb0.jpg

4.2 Concepts related to I/O management software

5.File management

5.1 File related concepts

File: A collection of related information items with a symbolic name and logically complete meaning. √Logical structure: structured record files, unstructured streaming files.

Physical structure: continuous structure, link structure, index structure, index table of multiple physical blocks.

File directory: file directory entry/file description/file control block FCB

Basic information: file name, physical address of the file, file length, number of file blocks, etc.

Storage control information category: File storage permissions: read, write, execute permissions, etc.

(File attributes: execute only, implicit, read-only, read/write, shared, system)

Usage information category : file creation date, last modification/access date, currently used information, number of processes opening the file, and waiting queue on the file, etc.

Directory Structure

First-level directory structure: linear structure, slow search speed, duplicate names and file sharing are not allowed, etc.

Secondary directory structure: main file directory (MFD) + user directory (UFD)

Three-level directory structure: tree directory structure (multi-level directory structure)

5.2 Tree directory structure

Test points: Choose the correct absolute path, relative path, and full file name

699775f2ffa14897a2cfe3b766178d08.jpg

5.3 Bitmap (involving calculations)

Two states: 0 idle (available), 1 occupied (unavailable)

9923c8e20e804abb9ba1656edf775540.jpg

5.4 Index file structure (involving calculations)

Test points: The logical page number corresponds to the indexing method, and the maximum file length that can be indexed

5907f3498a6045cbb5aa5e9f331a5240.jpg

Question skills

1. The index method corresponding to the index node will generally be given in the question stem. If it is not given, it will be understood as shown in the figure by default. The calculation process of the file size below is given in the figure.

2. Based on the physical block size (assuming 1KB) and address item length (assuming 4B), the number of address items that can be stored in the physical block storing the indirect index can be calculated: physical block size/address item length, rounded down.

(1KB/4B=256, pay attention to unit and base conversion).

3. Direct index (that is, the index node directly points to the physical block where the file is actually stored). The logical page number range that can be represented is 0 to 4, and the file size that can be represented is 5*1KB.

4. First-level indirect index (that is, the physical block pointed to by the index node stores address items, corresponding to 256 address items, which can point to 256 physical blocks that actually store files), and the range of logical page numbers that can be represented is

5-256+256, the file size that can be represented is 256*1KB+256*1KB.

5. Secondary indirect index (that is, the physical block pointed to by the index node stores the address items of the indirect index, a total of 256, which can point to 256 physical blocks storing address items, and each physical block points to the address item of the actual stored file. There are 256, and the final physical blocks pointed to are 256*256). The logical page number range that can be represented is 266~66053, and the file size that can be represented is 66053KB.

5+256+256+256*256=66053

Guess you like

Origin blog.csdn.net/qq_35902025/article/details/130194461