Partitioning

COMPUTER ORGANIZATION AND ARCHITECTURE DESIGNING FOR PERFORMANCE NINTH EDITION

The simplest scheme for partitioning available memory is to use

fixed-size partitions,

as shown in Figure 8.13. Note that, although the partitions are of fixed size,

they need not be of equal size. When a process is brought into memory, it is placed

in the smallest available partition that will hold it.

Even with the use of unequal fixed-size partitions, there will be wasted memory.

In most cases, a process will not require exactly as much memory as provided by

the

partition. For example, a process that requires 3M bytes of memory would be placed

in the 4M partition of Figure 8.13b, wasting 1M that could be used by another process.

A more efficient approach is to use variable-size partitions. When a process is

brought into memory, it is allocated exactly as much memory as it requires and no more.

Example 8.2

An example, using 64 Mbytes of main memory, is shown in Figure 8.14.

Initially, main memory is empty, except for the OS (a). The first three processes are loaded

in, starting where the OS ends and occupying just enough space for each process (b, c, d).

This leaves a “hole” at the end of memory that is too small for a fourth process. At some

point, none of the processes in memory is ready. The OS swaps out process 2 (e), which

leaves sufficient room to load a new process, process 4 (f). Because process 4 is smaller

than process 2, another small hole is created. Later, a point is reached at which none of the

processes in main memory is ready, but process 2, in the Ready-Suspend state, is available.

Because there is insufficient room in memory for process 2, the OS swaps process 1 out (g)

and swaps process 2 back in (h).

As this example shows, this method starts out well, but eventually it leads to a

situation in which there are a lot of small holes in memory. As time goes on, mem-

ory becomes more and more fragmented, and memory utilization declines. One

technique for overcoming this problem is

compaction

: From time to time, the OS

shifts the processes in memory to place all the free memory together in one block.

This is a time-consuming procedure, wasteful of processor time.

Before we consider ways of dealing with the shortcomings of partitioning, we

must clear up one loose end. Consider Figure 8.14; it should be obvious that a proc-

ess is not likely to be loaded into the same place in main memory each time it is

swapped in. Furthermore, if compaction is used, a process may be shifted while in

main memory. A process in memory consists of instructions plus data. The instruc-

tions will contain addresses for memory locations of two types:

?

Addresses of data items

?

Addresses of instructions, used for branching instruction

But these addresses are not fixed. They will change each time a process is

swapped in. To solve this problem, a distinction is made between logical addresses

and physical addresses. A logical address is expressed as a location relative to the

beginning of the program. Instructions in the program contain only logical addresses.

A physical address is an actual location in main memory. When the processor exe-

cutes a process, it automatically converts from logical to physical address by adding

the current starting location of the process, called its base address, to each logical

address. This is another example of a processor hardware feature designed to meet

an OS requirement. The exact nature of this hardware feature depends on the mem-

ory management strategy in use. We will see several examples later in this chapter.

时间: 2025-01-16 18:55:41

Partitioning的相关文章

uva 11584 Partitioning by Palindromes 线性dp

// uva 11584 Partitioning by Palindromes 线性dp // // 题目意思是将一个字符串划分成尽量少的回文串 // // f[i]表示前i个字符能化成最少的回文串的数目 // // f[i] = min(f[i],f[j-1] + 1(j到i是回文串)) // // 这道题还是挺简单的,继续练 #include <algorithm> #include <bitset> #include <cassert> #include <

[LeetCode]132.Palindrome Partitioning II

题目 Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning of s. For example, given s = "aab", Return 1 since the palindrome partitioning ["aa&qu

leetcode -- Palindrome Partitioning II

指责别人,看清自己 [问题描述] Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning of s. For example, given s = "aab",Return 1 since the palindrome partitioning

132. Palindrome Partitioning II (String; DP)

Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning of s. For example, given s = "aab",Return 1 since the palindrome partitioning ["aa",

[LeetCode][Java] Palindrome Partitioning

题目: Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. For example, given s = "aab", Return [ ["aa","b"], ["a","a",&

Palindrome Partitioning -- leetcode

Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. For example, given s = "aab", Return [ ["aa","b"], ["a","a","

1503 - A PRIMARY KEY must include all columns in the table&#39;s partitioning function

1503 - A PRIMARY KEY must include all columns in the table's partitioning function 错误的原因:表的主键字段必须包含分区字段.为什么? 举例来说,Id为auto_increment primary key,按日期分区.考虑下面的场景,插入一条Id为100的记录,mysql根据日期,当然知道插入到那个分区中,但是要检查所有的分区中是否已经包含Id为100的记录,显然效率很低.如果不检查所有的分区,只检查当前插入的分区

LeetCode: Palindrome Partitioning II 解题报告

Palindrome Partitioning II Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning of s. For example, given s = "aab",Return 1 since the palindrome pa

Palindrome Partitioning II

Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning of s. For example, given s = "aab",Return 1 since the palindrome partitioning ["aa",

leetcode -- Palindrome Partitioning

谋事在人,成事在天 [问题描述] Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. For example, given s = "aab",Return [ ["aa","b"], ["a",&qu