In a multi-program, if we want our program to run, we must first create a process. The first step in creating a process is to load the program and corresponding data into memory. Turning the user's source program into an executable program requires three processes: compilation-link-loading.
What I want to say at the moment is the last step, how to allocate the corresponding memory space for a user program.
The first type: a single continuous distribution method
Suitable for single-user, single-task operating systems. There is nothing to say.
The second type: fixed partition allocation
This allocation method divides the memory space into fixed-size areas, and each partition allows one job to be loaded. The partition size can be different. A partition usage table is usually established to record the starting address, partition size, and status of each partition. If there is not a large enough partition, it refuses to allocate memory. This distribution method is the earliest multi-program storage management method.
Disadvantages: The number of processes is limited, and the memory space utilization is relatively low.
The third type: dynamic partition allocation
This method involves the corresponding data structure (partition table, partition chain), partition allocation algorithm and recovery operation.
The partition allocation algorithms include: first adaptation algorithm (take the linked list structure as an example, the same below. Search in order from the beginning of the chain, find a qualified partition and then perform the corresponding allocation, if there is no qualified partition, the allocation will fail), cyclic first adaptation Algorithm (recursive search from the last eligible partition), optimal adaptation algorithm (first need to sort the list of free partitions by capacity [the purpose of sorting is to speed up the search, otherwise it is necessary to traverse the entire list], and then proceed from the beginning of the chain Sequential search), worst adaptive algorithm (select the largest free partition, and then allocate), fast adaptive algorithm (categorized search algorithm, take the partition table plus the linked list managed by the same category to record, only according to the length of the process, you can Allocate the corresponding memory space).
The method of reclaiming memory: As long as the reclaimed space is adjacent to the free partition, it only needs to be merged with the free partition; otherwise, a new table must be created for the reclaimed area, and then the first address of the reclaimed area is inserted into the free chain In the corresponding position.
Disadvantages: The corresponding allocation algorithm is more complicated, the reclaiming space needs to merge the partitions, and the system overhead is high.
Fourth: Buddy System
Regulation: The size of the allocated interval or the free interval is 2 to the power of k.
Specifically: When the process needs a space of length n, it needs to calculate an i value so that the i-1 power of 2 is less than n, and the i power of 2 is greater than or equal to n. Then, according to the calculation results, the free partition list is searched for a free partition with a size of 2 to the power of i. If there is no such partition, the 2 to the i+1 power is converted into two free partitions to the power of 2 to the power of i. By analogy, there are always free partitions that match. The way of reclaiming and allocating space is exactly the opposite.
Fifth: Hash algorithm
On the basis of the classification search algorithm, the advantages of quick hash search are used to quickly find the linked list of the same capacity category to achieve the best allocation strategy.
Sixth: Relocatable partition allocation
This kind of algorithm considers the situation: There are many memory fragments. For a process, no fragment can meet the capacity requirements of the process, but the total capacity of the fragments can meet the capacity requirements of one or more processes.
Solution: â‘ Move all the jobs in the memory to make them compact together, so that the memory fragments are concentrated together. (Need to modify the moved program address)
Partition allocation algorithm: similar to the dynamic partition allocation algorithm, but with more "compact" operations.
Seventh: swap
Put processes that occupy memory but do nothing in the swap area (the external memory is divided into a file area and a swap area).
Digital Display Test Pen ,Power Tester Pen,Voltage Pen,Digital Voltage Tester
YINTE TOOLS (NINGBO) CO., LTD , https://www.yinte-tools.com