1. The content of this article comes from courseware and student notes of famous universities (on campus, I often see someone buying notes at high prices)
2. The instructor does not provide references, so he can only express his gratitude to the author. If your work is referenced, you can reply to the document to supplement the reference.
3. I will not answer questions not related to the article, and the article content is also difficult. I am also difficult to answer your questions. If you find a bug, you can use the reply method to help me fix it.
4. Computer Operating System
Applicable to computer operating system courses and postgraduate entrance exams
For more information about the navigation bar of this course, see the navigation bar at the bottom of the page.
§ 5. 5. segment-based Page Management
§ 5.6 local principle and jitter Problems
Summary of this Chapter
§
5.5
Segment and segment Page Management
5.5.1
Basic Idea of segment Management
• The process address space structure during partition and Page Management is both
Linear
This requires that the main
Programs, subprograms, data areas, and so on are arranged in one-dimensional address order of linear space.
. This makes
Share common subroutines and data between different jobs or processes
It becomes very difficult.
If the system cannot specify the User-Defined program name and Data
The block name corresponds to the virtual pages of the shared programs and data in a process.
Then, it is impossible to share these programs and data stored on the Memory Page.
In addition,
During Page Management, a page may contain two different
Sub-program segment command code, therefore, through page sharing to achieve sharing 1
Logically complete subroutines or data blocks are impossible.
• Furthermore,
Only static links can be used for partition management and page management.
. From decrease
CPU
From the perspective of overhead and storage space waste, static links are not suitable.
.
102
• To sum up, segmented storage management is based on
Proposed in a flexible programming environment.
The basis of segment Management
This idea is:
:
Based on content or process
(
Function
)
Link segment,
Each segment has its own name. A user job or process contains
Segment corresponds to
Two-dimensional linear virtual space
, That is, a two-dimensional
Virtual Memory. The segment management program uses
Segment
Allocate memory for units,
Then, the segment virtual address is converted to the actual address through the address ing mechanism.
Memory physical address.
As with page management, segment management is also
Instead
The segments that will not be accessed in the future will be stored in external storage.
The automatic transfer method implements two-dimensional virtual memory.
103
5.5.2
Implementation principle of segment Management
1.
Segmented virtual storage space
• Segment management design the virtual address space of a process into a two-dimensional knot
Structure, that is, the field number
S
Relative address in the same segment
W
.
Page Management, marked
The page numbers of the parts are sequentially numbered.
One-Dimensional Space
And segment
There is no sequential relationship between the field numbers and the Field Numbers.
In addition
Is not as long as the page is divided,
Segment
The length is not fixed.
.
Each segment defines a set of logically complete processes
Sequence or data.
For example, programs and data in a process can be
The main program segment, subprogram segment, data segment, and workspace segment.
• Each segment is a zero first address and a continuous one-dimensional linear space.
As needed,
Segment length can be dynamically increased
.
Segment-based virtual address space
The access includes two parts:
:
Segment name
And
Segment address
.
104
For example,
Call [x] | <Y>
The direction segment is named
X
Subprogram entry point
Y
.
Load 1, [a] | 6
Name the segment
A
In the array
6
The value of each element is read to the Register.
1
.
Store 1, [B] | <C>
Register
1
The content of the bucket is named
B
,
Segment address:
C
.
Segment name
X
,
A
,
B
And portal name
Y
And other compiled programs and linked programs
After the link is compiled, it is converted into a segment number and a unit number that can be recognized inside the machine.
For example,
Call
[
X
]
| <Y>
Can be compiled
Call 3 | 120,
If [
X
]
The corresponding field number is
3
,
<Y>
The unit number in the corresponding segment is
120
.
105
2.
Memory Allocation and release of segment Management
• Segment-Based Management allocates memory in segments and each segment is allocated with a continuous
Storage area. Because the length of each segment varies, the sizes of these buckets are different.
Moreover, each segment of a process is not consecutive.
• Memory allocation and release of segment-based management during job or process execution
Dynamic
Status
.
First,
The segmented management program is ready for execution into the memory.
A process or job allocates part of the memory to serve as the workspace and placement of the process.
The program segment to be executed. As the process is executed, the process is ready as needed
Apply to transfer to New section and release old section.
The process can apply for and release the memory Zone
There are two scenarios.
One is that when a process needs to call a certain segment
There are enough free zones to meet the memory requirements for this segment. The other is not in memory
There are enough free zones to meet the memory requirements for this segment.
106
• In the first case, the system must use the corresponding
Table
Or
Data Structure
To manage
Memory idle zone to facilitate the process or job-related sections of the user
Storage Allocation and recovery. In fact, it can be the same as dynamic partition-based management.
In the left-side navigation pane. That is, the memory in each idle zone is reduced from low to low by physical address.
In high order or by idle area size from small to large or from large to small. And
Corresponding to the free zone chain, which is used for partition management.
Method
:
First adaptation method
,
Best adaptation method
,
Worst adaptation method
Can be used for null
Free Zone allocation. Of course,
The memory reclaim Method Used in partition management is also available.
To be used in segment Management
.
• Another way to allocate and recycle idle memory areas is to not allocate enough memory.
When the idle zone meets the memory requirements of the incoming segment. In this case
Based on the given
Replacement Algorithm
Eliminate memory in the future
No longer
CPU
That is, the segments with the lowest probability of access are eliminated.
107
• Several Common elimination algorithms in dynamic page management can be used as segments
Elimination algorithm during type management
. For example
FIFO
Replacement algorithm,
LRU
Algorithm and
Approximate Algorithms. However,
When the length of each page is the same as that of Page Management
Different, the length of a segment to be transferred may be greater than that of a program to be eliminated
Or the length of the data. In this way, only one segment of elimination may not meet the requirements.
Memory Requirements of the segments to be transferred. At this time, another segment should be eliminated until it is full.
This parameter is valid only when the memory of the CIDR block is required.
• In fact,
The number of segments to be eliminated during one transfer depends on the size of the segments.
. For example
If a job or process has a large number of segments, and the length of the segments varies greatly,
When a large segment is transferred, several segments need to be eliminated.
However,
During segment management, the length of any segment cannot exceed
The length of the storage zone. Otherwise, an error occurs in memory allocation.
108
• Apart from initial allocation,
The Dynamic Allocation of segments is in
CPU
To access
When the requested command and data are not in the memory, a segment is interrupted.
Occurred.
Therefore,
Segment elimination or replacement algorithms are actually missing segments
Part of the interrupt handling process
.
• The entire process of segment interruption handling
5.29
. Figure
5.29
Medium,
X
Indicates the missing segment number. The handler is in
CPU
Access
During execution, the address translation organization finds that this segment is not in the memory, instead of hard
It is called after the device sends a signal of interrupted segments.
109
Figure
5.29
Segment interruption handling process
110
3.
Segment management address transformation
Segment management only stores some copies of user information in the memory, while most
Information is stored in external storage, which will inevitably lead
CPU
The segment to be accessed is not
Memory symptom. So,
CPU
How to perceive that the segment to be accessed is not included
And start the interrupt processing program.
?
And,
The segment virtual address belongs to a two-dimensional virtual space.
.
A two-dimensional
How can a virtual address of a space be transformed into a one-dimensional linear physical address?
?
These
All are resolved by the segment address converter.
(1)
Field table
(Segment mapping table)
Similar to the page management solution, the segment management program allocates initial memory.
Before,
First, set up a job or process based on the memory size required by the user.
A field table
,
In order to achieve dynamic address translation, segment interruption processing, and storage protection
.
As with page management, segment management is also implemented through
Field table
Memory
Management. Considering the segment processing and segment access control protection
5.30
.
111
Figure
5.30
Field table
Figure
Field number
Corresponds to the user-specified segment name,
Start address
And
Length
Respectively
Indicates the physical address and actual length of the segment in memory or external storage.
Access Method
Yes
Used to access and protect this section. Only access control in the processor status word
This segment can be accessed only when the system bit and segment table have the same access mode.
Internal and external
The column indicates
This section is currently stored in external storage or memory. If this topic indicates the accessed section
In the case of external storage, the operation is interrupted. While
Access location
It is based on the needs of the elimination algorithm
Here, we assume that the elimination algorithm will eliminate those access bits that have not been changed.
Segment
(Nur
Algorithm
)
.
Access location
Internal and external
Access Method
Length
Start address
Field number
112
(2)
Dynamic Address Translation
• A fixed area field table is generally provided in the memory.
. When
When a process starts to run, the hypervisor first starts the field table of the process.
Add the address to the segment table address register. By accessing the field table register
The program obtains the field table start address of the process to access the field table.
Then, the field number in the virtual address
S
It is an index and a field table is queried. If
When the segment is in the memory, determine whether the access control method is wrong. If
If the access control method is correct, the segment is identified from the region of the corresponding table in the field table.
At the starting address of the memory, and compare it with the relative address in the segment
W
Phase
To obtain the actual memory address.
113
• If this segment is not in memory
Segment interruption
Set
CPU
Internal control
Storage Allocation program. The memory allocation program first checks the idle zone chain to find enough
The required segments are loaded in idle zones with sufficient length. If the memory is empty
When the total number of free zones is less than the required segment length, check the segment table
Access location
,
Remove the segments with low access probability and call the segments. Segment address conversion
Process
5.31
.
• Same as Page Management,
During segment management, the address transformation process must also be
Over two times of Memory Access
.
Access the field table for Calculation
Ask the physical address of the instruction or data, and then obtain the number of physical addresses.
Data storage operations.
To speed up access
Used
High-speed Lenovo register
The method can also be used in segment address transformation.
If the required segments are found in the Lenovo register, the speed can be greatly improved.
Address conversion speed.
114
Figure
5.31
Segment address conversion process
115
4.
Segment sharing and protection
Segmented Storage Management facilitates memory information sharing and effective
Memory protection. This is because the segment is based on
Logical meaning
Yes.
By segment name
Access
.
(1)
Segment sharing
In multi-channel environments, many subprograms and applications are often used by multiple
User. Especially popular in multi-window systems and support tools
Today, the number and volume of shared programs and data are increasing dramatically.
Usually more than many times the length of the user program. In this case, if each
User processes or jobs keep copies of their shared programs and data in the memory,
This will greatly waste memory space. The best way is
Only one retained in memory
Copies, called
Share
.
Figure
5.32
A section is provided.
Examples of sharing in a system.
Fig 116
5.32
Shared Memory replica in a segmented System
117
5.32
As shown in, if the user process or job needs to be shared
Stored programs or data,
As long as the user uses the same segment name
You can enter the starting location of a segment that already exists in the memory in the new segment table.
To share a logic.
Complete memory segment information.
In addition, in multi-channel environments, the concurrent execution of processes
,
Duan Cheng
When multiple processes are shared in sequence, it is possible that the process may be repeatedly executed multiple times at the same time.
Section Program
(
That is, before a process finishes executing this program,
Other concurrent processes have started to execute this program.
)
. This requires it
In
During execution, the commands and data of this program cannot be modified.
Also
Yes, like other program segments in a process,
Shared segments are sometimes required
Swap out memory
. In this case, you need to set up the corresponding
Shared bit
Come
Determine whether the segment is being called by a process. Apparently
A
Shared segments used by processes or to be used by a process are not called
Out-of-memory.
118
(2)
Segment Protection
As with page management, there are two main types of protection for segment management.
One is
Address out-of-bounds Protection Law
, The other is
Access Control and Protection
Method
. The access method control protection is described earlier.
Duplicate. While
Address out-of-range Protection uses the field length and virtual
Compare the relative addresses in the specified CIDR block.
. If
If the address is greater than the segment length, the system will interrupt the protection. However
In a system with dynamic segment growth, if the relative address within a segment is greater than the segment length
. To this end,
Set the corresponding
Supplemental position
To indicate whether the segment is
This segment can be dynamically increased.
119
5.5.3
Advantages and disadvantages of segment Management
Compared with page management and partition management, the strengths and weaknesses of segment management can be different
Summary:
:
(1)
Similar to dynamic page management, segment management also provides virtual
Storage implementation
. Different from page-Based Management, segment-based virtual storage exchanges
Meaning information, instead of exchanging only fixed-size pages as the web-based virtual storage.
The required information can be fully transferred to the memory only after several page breaks.
(2)
In segment management,
Segment length can be dynamically increased as needed
. This requires constant
Adding or absorbing new data segments is very advantageous.
(3)
Easy to share information segments with complete Logic Functions
.
(4)
Easy to Implement Dynamic Links
. Segment management is based on the logic meaning of information.
Each segment corresponds to a corresponding program module. Therefore, the available segment name is added to the previous segment
Port address and other methods in the execution process to call the corresponding segment for dynamic link. When
However,
Segment dynamic links require hardware support
. For example, you need to link the Register
Store the egress of The Link segment.
120
• Segment management requires more hardware support than other methods
.
This increases machine costs. In addition
This method is the same as partition-based management.
The merge of shards to be eliminated is worse than paging management.
Moreover, the dynamic growth of permitted segments will also bring some impact to system management.
And overhead.
• Another disadvantage of segment management is that the length of each segment is subject to memory
Use area size limit
.
• Like page-based management, the segmented management system selects algorithms for elimination.
It must also be very careful, otherwise it may also generate
Jitter
.
121
5.5.4
Basic Idea of segment-Page Management
• Each of the above storage management methods has its own expertise.
Segment Management provides users
A two-dimensional virtual address space reflects the logic structure of the program and facilitates
Segment dynamic growth and sharing and memory protection, which greatly facilitates the use
User. The paging system effectively overcomes fragments and improves the benefits of memory.
Usage rate. For the purpose of storage management, it is mainly to facilitate the user's Program
Memory usage.
So,
Link segment management with Page Management
Isn't it better to let them learn from each other together?
?
Therefore, the segment-page Manager
Is extracted.
• However,
The cost of segment-and-page management is higher.
. Therefore, segment-and-Page Management
Generally
Mainframe System
. In recent years, due to the rapid development of hardware
The cost of page management has become tolerable on workstations and other models.
122
5.5.5
Implementation principle of segment-Page Management
1.
Virtual Address Structure
A process still has its own
II
Dimension address space
, Which is the same as segment management. First,
One Process
The programs or data contained with independent logic functions are still divided
Segment, with their respective field numbers
S
.
This reflects and inherits segment-level management.
. Second,
For segments
S
In
The page is divided into different sizes.
Like a page system
After
Less than one page still occupies one page
. This reflects the process of segment Page Management.
Of
Page Features
. Thus,
Virtual Address of the Process during segment-Page Management
A virtual address in a space consists of three parts:
:
That is
Field number
S
,
Page number
P
And
Relative address on the page
D
.
As shown below
:
123
• For a virtual address composed of three parts,
Programmer
See
Field number
S
And
Segment relative address
W
.
P
And
D
By address
Transform the Mechanism
W
As the page number.
P
,
And
The low position is interpreted as the on-page address.
D
.
• Because
The smallest unit of a virtual space is a page rather than a segment.
To memory
The zone is divided into several pages of the same size, and
The programs and data in each segment can be stored separately in the memory.
The size of segments is no longer limited by the memory zone.
124
2.
Field table and page table
• To achieve segment-and-Page Management,
The system must be
Each job or process
Create a field table,
Manage memory allocation and release, process missing segments,
Storage protection and address translation.
In addition,
Because a segment is marked again
Divided into several pages,
A page table must be created for each segment.
, Segment
Convert the virtual page in to the actual page in memory.
Apparently,
And webpage
The management process is the same. Page tables must also implement page missing Interrupt Processing and page
Table items of features such as surface protection.
In addition,
Because the segment-based Page Management
The page table no longer belongs to a process but belongs to a specific segment. Therefore,
The Section Table should specify the page table corresponding to the Section
Page table start address
And
Page table length
.
Manage the Middle-section tables, page tables, and memory
System
5.33
. Tables in the figure
For other columns, see section or
Corresponding columns in Page Management
.
125
Figure
5.33
Link between the middle-section table, page table, and memory
126
3.
Dynamic address conversion process
• In computer systems that generally use segment-based storage management
A fixed area is provided in the memory to store the process field table and page table.
Therefore,
In the segment-Page Management System, you must specify the commands or numbers in the memory.
If data is accessed at least three times
Save.
First time
The field table is accessed by the field table address register.
Ask the field table and obtain the page table address of the corresponding segment.
Second
Is
Access the page table to obtain the physical address to be accessed. Only after access
After the field table and page table,
Third time
To access
Physical unit.
Obviously, this will make
CPU
High Speed of executing commands
Lower.
127
• To increase the address conversion speed, Set
Fast Association register
It seems to be a specific segment
And page management.
In the quick Lenovo register
Put the most commonly used field number
S
,
Page number
P
And the corresponding Memory Page and other controls
Create columns.
When you want to access a certain unit of memory space, you can,
The page table searches for memory addresses based on the quick Association register.
Its field number and page number.
If you want to access a segment or page in the quick Lenovo register
The system no longer accesses the field tables and page tables in the memory and directly connects
The value in the Register is the relative address on the page.
D
SPLICE to obtain the physical address.
Experience shows that a register with quick Lenovo has
1/10
Field numbers,
Page number and segment Page Management System, which can be quickly associated with registers
Find
90%
The above memory address to be accessed.
• Segment-and-Page Management address translation mechanism
5.34
.
128
Figure
5.34
Segment-page address transformation
129
• The above briefly introduces the basic principle of address translation in segment-page management. Yes
Section Page Management
Storage Protection
And
Share
And
Segment or page disconnection
Management
For more information, see section management or page management.
• In short, because
Segment-based page management is a combination of segment-based page management solutions.
So they have the advantages of both.
. On the other hand,
Due to management
With the increase of software, the complexity and overhead will increase.
In addition,
Yes
The hardware and memory occupied are also increased.
More importantly,
If no
Improved by Lenovo register
CPU
The internal access speed
The row speed is greatly reduced.
130
§
5.6
Locality Principle and jitter Problems
• Dynamic page management, segment management, and segment-page management all provide
Unified management of memory and external memory
.
However
In essence
Information exchange between memory and external memory
Therefore, we must constantly
Start external devices and the corresponding processing process. Generally, computers
The external memory of the system has a large capacity and the access speed is not high. Is
A series of processing programs involved in Data Reading and Writing also need to consume a lot
The amount of time.
If data exchange between memory and external storage is frequent
Paired Input
/
The huge pressure on output devices and the large amount of machine overhead
It is used to call up data and program segments repeatedly, so that the user's
Required work.
Therefore,
It is required to store a minimum value in the memory.
Degree program segment or data, and they must be those that are being called, or
The parts to be called.
131
•
Simulated Experiment
Yes,
In the execution of almost all programs
Inner,
CPU
Always centrally access a part of the program rather than randomly accessing
All parts of the program have an average access probability. This phenomenon is called
Locality Principle
.
And
CPU
Compared with the number of times that the program accesses the local data
The animation speed is quite slow. This makes the Page Management and segment management discussed earlier take
And segment-page management to achieve the virtual storage system is possible.
• However, if the local segments required by the system cannot be properly put into the memory
Obviously, the system efficiency will be greatly reduced, and even cannot work effectively.
• Tests show that any program has a critical value when it is locally placed.
When the memory allocation is less than this critical value, the switching frequency between the memory and the external memory will
Will increase dramatically,
When the memory allocation exceeds this critical value, the memory allocation is increased.
It cannot significantly reduce the number of exchanges.
• This
The critical value of memory requirements is called
Working Set
. Figure
5.35
This indicates the situation.
132
Figure
5.35
Relationship between memory and swap count
133
• A process is being executed
Page missing
(Missing page)
The occurrence
There are two possibilities.
One is the large sum of working sets required by concurrent processes.
Available zones in the memory.
At this time,
The system will not work properly
Because there is not enough space to load the required program and data.
Another possibility is that even though the storage manager sends
The task is assigned enough work sets, but the system cannot start execution before
Select the appropriate program segment and data to enter the memory.
In this case,
Only depends on the execution process, when
CPU
Command to be accessed
Or when the data is not in the memory, it is transferred to the interrupt processing process after the hardware is interrupted.
To call the required program segments and data.
This is a very self-built
The processing method.
134
• When the memory allocated to the process is smaller than the required working set
Frequent intercommunication, access time and input
/
The output processing time is greatly increased.
As a result
CPU
The system performance is greatly reduced as data is idling.
This causes system jitter.
• Available
Statistical Model
Further analyze the relationship between working sets and jitter.
• Set
R
Is
CPU
The time when a memory unit is accessed in the memory,
T
Read from external store
Time required to output a page of data,
P (S)
Is
CPU
When accessing the memory, the accessed page is
The probability that the memory is not in use.
S
Is the working set of the current process in the memory.
• Obviously, the average time for accessing a memory unit in the case of virtual storage can be described
T =
R + P (S
)
*
T
The program simulation shows that,
P (S
) =
AE
-BS
Here,
0 <A <1 <B
,
AE
-BS
<R
135
• In addition, it is assumed that the concurrent processes in the memory have the same statistical characteristics and
For a concurrent process, the waiting status is changed only when a page is missing.
This is to simplify the discussion and ignore the memory of external devices and process communication functions.
In.
• Because the speed for accessing an external page is
T
,
The probability of page missing is
P (S)
,
Then, when the processor accesses a memory unit
R
Average time per second
The page transfer rate between internal and external storage is
P (S)/R
.
That is
R/P (S)
Seconds required
Transfers one page from external memory to memory. Thus
For
It can be in three possible states:
:
(1) T
<
R/P (S
)
(2) T
>
R/P (S
)
(3) t =
R/P (S
)
136
• In the first case, because the page transfer speed is higher than the access speed of the external storage page
Therefore, the number of page missing occurs in the process during execution is less
Pages are often transferred from external storage.
• However, in the second case, the page transfer speed between internal and external storage
The speed of accessing the external store page is earlier than that of the process.
The number of page defects has reached the limit for external storage. In fact, this
The system is in the jitter status.
• The third case is an ideal situation, namely, the process in the execution process
The required number of pages is exactly the same as the number of pages that can be transferred from external storage. This process
Occupies the optimal working set in the memory.
• According to the above discussion, a process occupies the best working set in the memory
Condition:
: P (w) = R/T
• Here,
R
Yes
CPU
Average time required to access memory units,
T
Yes access to external store 1
Average time required for pages.
137
• Because
P (W)
Can be expressed
P (w) =
AE
-BW
• Thus,
W =
Ln (AT/R)/B
Rabnt (
• That Is,
And memory access speed
R
If the external storage transfer speed is higher
Slow, the larger the work set is.
• Of course, the above discussion is based on many similarities.
Conclusion. In fact, because of the number of program segments contained by each process,
The algorithms used for elimination are different, and the selection of working sets is different.
Generally, there are two options: static and dynamic.
Method.
.
• As discussed above, we can find out the solution to the jitter problem.
Several key methods.
138
• Jitter is only available in
T> R/P (S)
. While
P (S)
Equal
AE
-BS
Is
Collection
S
,
Parameters
A
And
B
Related probability value.
P (S)
Yes. For
System,
T
And
R
It is a number that is hard to change. Obviously, solve the jitter Problem
The most important way is
P (S)
Reduced
T = R/P (S)
.
This only requires
:
(1)
Add
S
,
That is
Expanded work set
, Or
(2)
Change Parameters
A
And
B
,
That is
Select different elimination algorithms to solve the jitter Problem
.
• In physical systems, to prevent jitter,
Generally, the page-missing process is locked to prevent it from being swapped out, while the transferred page or segment is always
Occupy the memory area occupied by the processes that are temporarily not being executed, thus expanding
The working set of the page-missing process.
UNIX System
V is used in this method.
139
Ben
Chapter
Small
End
• This chapter describes various common memory management methods. They are
Partition management,
Page Management, segment management, and segment Page Management.
Core issues of Memory Management
How is it
Solve the unification of memory and external memory and data exchange between them
Problem.
The unified management of memory and external memory improves the memory utilization.
High, user programs are no longer limited by the size of the memory zone. Related to this
Memory Management should address memory expansion, memory allocation and release, and virtual
Address-to-memory physical address conversion, memory protection and sharing, internal and external storage
Inter-Data Exchange Control and other issues.
• Graph
5.36
The functions and required hardware provided by the system for several storage management methods
A comparison is supported.