Soft Exam Intermediate Software Designer Notes Chapter 2 Computer Operating System

1. The knowledge point framework of this chapter is the score distribution

1. Knowledge framework

insert image description here

2. Score distribution ( 上午题6分)

insert image description here

2. Process management

This part of the knowledge framework:
insert image description here

1. The concept of process

A process is a process in which a program runs on a data set, and it is an independent unit of resource allocation and scheduling in the system. It consists of three parts: program block, process control block (PCB) and data block.

Remarks: A process is an execution process of a program, and there is no process without a program.

2. The state of the process

insert image description here

3. Process synchronization and mutual exclusion

Synchronize:

Processes that cooperate with each other need to coordinate their work at certain definite points, and when one process reaches these points, it has to stop and wait for the completion of some operations unless the other process has already completed them. This is the synchronization between processes.

insert image description here

Mutually exclusive:

In a multiprogramming system, each process can share various resources, but some resources can only be used by one process at a time, which are called critical resources. This creates an indirect restriction problem between processes - mutual exclusion.

insert image description here

4.PV operation

insert image description here

(1) Mutual exclusion model

insert image description here
insert image description here

(2) Synchronization model

Producer and Consumer Problem:
insert image description here
Example (Adding PV operations to solve the producer-consumer problem):
insert image description here
insert image description here

example:

From a simple start, there is only one cashier, so start with the cashier process. The cashier must wait for the book buyer to pay the bill at the beginning, that is, b1 is the V operation semaphore starting from S1, so the first payment is S1, so b1=V(S1), when the salesman has received one, he needs to start accepting the next one, that is, b2 is the P operation, and the next one of S1 is S2, so here b2=P(S2), the process of the salesman and the book buyer The process is actually a pair of opposite operations (synchronization model) that a1 is P(S1), a2 is V(S2)

insert image description here

(3) Predecessor diagram

( 有几个进来就有几个P操作,有几个出去就有几个V操作 )
insert image description here

5. Deadlock problem

( 给进程分配最大系统资源减1,再留1个资源就不会发送死锁)
insert image description here
Four factors and prevention methods of forming deadlock
insert image description here

6. The Banker's Algorithm

insert image description here
Example:
insert image description here
7(9) 7(8) 5(5) resources have been allocated, and 2(9-7) 1(8-7) 0(5-5) resources are available
insert image description here
to calculate the number of resources needed (according to the bank Home algorithm execution process)
insert image description here
First, P2 is executed because P2 allocates resources to P2, and P2 releases resources and there are 4 2 1 resources left (the number of remaining resources in P2 2 1 0 + the number of allocated resources 2 1 1), and then in turn analogy.
insert image description here

3. Storage management

1. Partition storage

insert image description here

①First adaptation algorithm: 空闲分区以地址递增的次序链接. For the above question, job 4 applies for 9k of memory. According to the increase of the address, job 4 will be allocated to a free partition of 25k, occupying 9k, and the remaining 25-9=16k.
②Circular first adaptation algorithm: The difference from the first adaptation algorithm is that it does not search from the beginning of the chain every time, but 从上一次找到的空闲分区的下一个空闲分区开始查找. Therefore, job 4 applies for 9k, and the next free partition of the free partition where job 2 and job 3 are located is 28k, that is, job 4 is allocated to the free partition of 28k, occupying 9k, and the remaining 28-9=19k.
③Best adaptation algorithm: 空闲分区按其容量从小到大的顺序链接. Job 4 applies for 9k, and the capacity of the current free partition from small to large is: 10k, 25k, 28k, so job 4 is allocated to the free partition of 10k, occupying 9k, and the remaining 10-9=1k.
④The worst adaptive algorithm: 空闲分区按其容量从大到小的顺序链接(与最佳适应算法相反). Job 4 is allocated to the free partition 28k with the largest capacity, occupying 9k, and the remaining 28-9=19k.

Note: The partition storage content comes from Zhang Qiling-little brother

2. Page storage organization

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

insert image description here

official:

  • logical address = page number + in-page address
  • Physical address = page frame number + page address

example:

The first question is to find the physical address. From the page size 4k=2 12 , we can see that the lower 12 bits are the in-page address. From the logical address=5A29H, we can know that A29 is the in-page address, 5 is the page number, and the page frame number is known from page number 5. It is 6, that is, physical address = 6A29H.
The second question is that the page is eliminated, and the eliminated must be in memory (the status bit is 1), that is, 0, 1, 2, 5, and then see the access bit. Only the access bit can be 0. Knockout is Knockout Page 1

insert image description here

3. Segmented storage organization

insert image description here

4. Segment page storage organization

insert image description here

4. Page Replacement Algorithm

insert image description here

  • first in first out algorithm

Select the page that goes into memory first to be eliminated.

example:
insert image description here

Analysis: 1 comes in, there are none in the 3 physical blocks, so the page is missing, 2 and 3 are the same at this time; after 4 comes in, there is no physical block, that is, the page is missing, and (1, 2, 3) will be eliminated first. The page of memory is 1, so 4 eliminates 1; after 1 comes in, there is no physical block, that is, page missing, eliminates (4, 2, 3) first into memory, which is 2, so 1 eliminates 2; after that 2 comes in, there is no physical block, that is, a page is missing, and the first one (4, 1, 3) that enters the memory is 3, so 2 eliminates 3; after 5 comes in, there is no page in the physical block, that is, a page is missing, and it is eliminated ( 4, 1, 2) The first one to enter the memory is 4, so 5 eliminates 4; then 1 and 2 come in again, there are already these two pages in the physical block, so there is no page missing; after 3 comes in, the physical block If there is none in the physical block, that is, a page is missing, and the first one (5, 1, 2) to enter the memory is eliminated, that is, 1, so 3 eliminates 1; after 4 comes in, there is no page in the physical block, that is, a page is missing, and (5, 3, 2) is eliminated. ) The first to enter the memory, that is, 2, so 4 eliminates 2; the last 5 comes in, there are physical blocks, so there is no page shortage. This is the whole process of the FIFO algorithm in the page replacement algorithm! ! !

Original link: https://blog.csdn.net/weixin_43823808/article/details/108254765

9 out of 12 pages are missing, so page missing rate=9/12=3/4
insert image description here

  • best permutation algorithm

Select pages that will never be needed or those that have not been used for the longest time to be eliminated.

insert image description here

Analysis: When page 1 comes in, there is no physical block, that is, a page is missing; the same is true for pages 2 and 3; after page 4 comes in, there is no physical block, that is, a page is missing. Page 3 is not accessed for the longest time in 3, so page 4 eliminates page 3, then pages 1 and 2 come in, there are already pages in the physical block, and there is no page missing; after page 5 comes in, there is no page in the physical block, that is, it is missing. Page, and then observe the direction behind the page, it can be seen that page 4 is not accessed for the longest time among pages 1, 2, and 4, so page 5 eliminates page 4; after that, pages 1 and 2 come in, which are already in the physical block, but not in the physical block. Page missing; next page 3 comes in, there is no physical block, that is, page missing, although there are no 1, 2, and 5 in the direction behind the page, but considering that pages 1 and 2 have just been accessed, page 1 is accessed earlier, So here page 3 eliminates page 1; 4 comes in in the same way as 3, there is no page in the physical block, that is, page 2 is eliminated; the last 5 comes in, and the physical block already exists, that is, there is no page shortage. This is the whole process of the best replacement algorithm in the page replacement algorithm! !

Original link: https://blog.csdn.net/weixin_43823808/article/details/108254765

  • Most recently unused algorithm

Select the pages that have not been visited for the longest time in the most recent period to be eliminated.

insert image description here

Analysis: First, pages 1, 2, and 3 enter the memory in turn, and there are none in the physical block, that is, page faults will occur; then page 4 comes in, but there is no physical block, that is, pages are missing, and pages 1, 2, and 3 are selected during this period of time. The page that has not been accessed for the longest time, then obviously 1 accesses the earliest, so here page 4 eliminates page 1; after page 1 comes in, there is no page in the physical block, that is, the page is missing, and pages 4, 2, and 3 are eliminated the most during this period of time. The page that has not been accessed for a long time, that is, page 2, so page 1 eliminates page 2; after page 2 comes in, there is no physical block, that is, page is missing, and pages 4, 1, and 3 have not been accessed for the longest time. The page that has passed, that is, page 3, so page 2 eliminates page 3; next page 5 comes in, there is no physical block, that is, page missing, and the page that has not been accessed for the longest time in pages 4, 1, and 2 is eliminated. , that is, page 4, so page 5 eliminates page 4; then pages 1 and 2 come in, and there are already in the physical block, that is, there is no page missing; after page 3 comes in, there is no page in the physical block, that is, pages are missing, and pages 5 and 1 are eliminated. , 2 The page that has not been accessed for the longest time in this period of time. Since 1 and 2 have just been accessed, page 5 should be eliminated here; after page 4 comes in, there is no page in the physical block, that is, page is missing, and page 3 is eliminated. , 1, 2 The page that has not been accessed for the longest time, that is, page 1, so page 4 eliminates page 1; finally page 5 comes in, there is no physical block, that is, page is missing, and pages 3, 4, and 2 are eliminated. The page that has not been visited for the longest time during this period is page 2, so page 5 eliminates page 2. This is the whole process of the most recently unused algorithm in the page replacement algorithm! ! !

Original link: https://blog.csdn.net/weixin_43823808/article/details/108254765

5. Disk Management

insert image description here
Read disk data time calculation:
insert image description here
example:

The time to find a track is 10msX10, the rotation delay time is 100ms+2ms, and the time required to transmit one is 10msX10+100ms+2ms=202ms, that is, 100 blocks require 202msX100=20200ms

insert image description here

6. Disk scheduling algorithm

insert image description here

4. File management

  • index file structure

insert image description here
example:
insert image description here

In this question, the physical block number 50 corresponds to the logical block number 0, the physical block number 67 corresponds to the logical block number 1, the physical block number 68 corresponds to the logical block number 2, the physical block number 78 corresponds to the logical block number 3, and the physical block number 89 corresponds to the logical block number 3. Logical block number 4, these five take the direct address index; while the physical block numbers 90 and 91 take the first-level indirect address index, 90→58 corresponds to the logical block number 5, so the physical block number 5 corresponds to the physical block number 5. The block number is 58.
Because the title says that the size of each address item is 4 bytes, and for the primary and secondary indirect address indexes, each physical block can store 1024 bytes of content, so in each primary and secondary indirect address index , there are 1024/4=256 address entries. Therefore, in the physical block number 90, the storage is from 5 260 (5+256-1); in the physical block number 91, the storage is from 261 516 (261+256-1), so the logical block number 261 corresponds to The physical block number is 187.
Observing the above figure, it can be seen that the physical block 101 obviously adopts the method of secondary indirect address index, so it stores the secondary address index table.

Original link: https://blog.csdn.net/weixin_43823808/article/details/108254765

  • tree directory structure

insert image description here

  • Free storage space management - bitmap method

insert image description here
example:
insert image description here

In this example, first, physical blocks are numbered from 0, and the word length in the system is 32 bits (equivalent to a word containing 32 physical blocks), then for physical block 4195, it is actually the 4196th physical block, Then, the length of each word is 32 bits, so 4196/32=131.125, which means that the 131st word is exceeded, and the first 131 words must be filled, and the current physical block is in the 132nd word. Description, the first empty choice D.
What should the second space system be like? Since the physical block is to be allocated to a file, the value must be 1 (1 means occupation), so A and C are excluded; let's look at it again, the physical block range represented by the first 131 words is 0 ~ 131×31: 0~ 4191, so in the 132nd word, the 0th position represents 4192, the 1st position represents 4193, the 2nd position represents 4194, and the 3rd position represents 4195, so the 3rd position of the 132nd word corresponds to the 4195th physical block. . So the second empty choice B.

Original link : https://blog.csdn.net/weixin_43823808/article/details/108254765

5. Job management

insert image description here

6. Setting management

  • Data transfer control method

insert image description here

  • Virtual Device and SPOOLING Technology

insert image description here

  • microkernel operating system

insert image description here

Guess you like

Origin blog.csdn.net/weixin_42753193/article/details/124235526