# US 2015/0178186 A1 · Method and apparatus for swapping in data to memory

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2015/0178186 A1
- Document ID: US20150178186A1
- Status: Published application
- Kind: A1
- Application number: 14/584,799
- Filed: 2014-12-29
- Published: 2015-06-25
- Earliest claimed: 2013-12-20
- Assignees: Huawei Technologies Co., Ltd.
- Applicants: Huawei Technologies Co., Ltd.
- Inventors: Liangwang Wang
- Web page: https://patentgrep.com/patent/US20150178186A1

## CPC

- G06F 12/023: {Free address space management}
- G06F 9/5061: {Partitioning or combining of resources}
- G06F 12/08: in hierarchically structured memory systems, e.g. virtual memory systems
- G06F 12/1009: using page tables, e.g. page table structures
- G06F 12/12: Replacement control
- G06F 2212/1016: Performance improvement
- G06F 2212/657: Virtual address space management
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A method for swapping in data to a memory is disclosed. The method includes: determining, according to a received instruction command, a process in which data needs to be swapped in to a physical memory of an operating system; and swapping in all data, in a swap partition of the operating system, of at least one process of the determined processes to the physical memory of the operating system according to a current free memory capacity of the physical memory of the operating system. According to embodiments of the present invention, data that needs to be swapped in to a physical memory of an operating system and corresponds to at least one process can be actively swapped in to the physical memory at a time according to a user requirement.

## Claims

### Claim 1

A method for swapping in data to a memory, the method comprising:
determining, according to a received instruction command, at least one process in which data needs to be swapped in to a physical memory of an operating system, wherein the instruction command carries at least one process identifier that is used to indicate the process in which data needs to be swapped in to the physical memory of the operating system; and
swapping in all data, in a swap partition of the operating system, of at least one process of the determined at least one process to the physical memory of the operating system according to a current free memory capacity of the physical memory of the operating system.

### Claim 2 (depends on 1)

The method according to claim 1, wherein if it is determined that there is one process in which data needs to be swapped in to the physical memory of the operating system, swapping in all data, in the swap partition of the operating system, of the determined process to the physical memory of the operating system according to the current free memory capacity of the physical memory of the operating system comprises:
when it is determined that a data volume, in the swap partition of the operating system, of the determined process is not larger than the current free memory capacity of the physical memory of the operating system, swapping in all the data, in the swap partition, of the determined process to the physical memory.

### Claim 3 (depends on 2)

The method according to claim 2, wherein the method further comprises:
when it is determined that the data volume, in the swap partition of the operating system, of the determined process is larger than the current free memory capacity of the physical memory of the operating system, terminating swap-in processing of the data, in the swap partition of the operating system, of the determined process.

### Claim 4 (depends on 1)

The method according to claim 1, wherein if it is determined that there are at least two processes in which data needs to be swapped in to the physical memory of the operating system, swapping in all data, in the swap partition of the operating system, of the determined processes to the physical memory of the operating system according to the current free memory capacity of the physical memory of the operating system comprises:
sequentially selecting each process from the determined processes, and determining whether a data volume, in the swap partition, of a currently selected process is not larger than the current free memory capacity of the physical memory;
when it is determined that the data volume, in the swap partition, of the currently selected process is not larger than the current free memory capacity of the physical memory, swapping in all data, in the swap partition, of the currently selected process to the physical memory; and
when it is determined that the data volume, in the swap partition, of the currently selected process is larger than the current free memory capacity of the physical memory, terminating swap-in processing of the data, in the swap partition, of the currently selected process.

### Claim 5 (depends on 1)

The method according to claim 1, wherein if it is determined that there are at least two processes in which data needs to be swapped in to the physical memory of the operating system, and the instruction command further carries information about a priority corresponding to each process identifier, swapping in all data, in the swap partition of the operating system, of the determined processes to the physical memory of the operating system according to the current free memory capacity of the physical memory of the operating system comprises:
sequentially selecting each process from the determined processes in a sequence from high to low according to the priorities corresponding to the process identifiers, and determining whether a data volume, in the swap partition, of a currently selected process is not larger than the current free memory capacity of the physical memory;
when it is determined that the data volume, in the swap partition, of the currently selected process is not larger than the current free memory capacity of the physical memory, swapping in all data, in the swap partition, of the currently selected process to the physical memory; and
when it is determined that the data volume, in the swap partition, of the currently selected process is larger than the current free memory capacity of the physical memory, terminating swap-in processing of the data, in the swap partition, of the currently selected process.

### Claim 6 (depends on 1)

The method according to claim 1, wherein if it is determined that there are at least two processes in which data needs to be swapped in to the physical memory of the operating system, swapping in all data, in the swap partition of the operating system, of the determined processes to the physical memory of the operating system according to the current free memory capacity of the physical memory of the operating system comprises:
when it is determined that a total data volume, in the swap partition of the operating system, of the determined processes is not larger than the current free memory capacity of the physical memory of the operating system, swapping in all the data, in the swap partition, of the determined processes to the physical memory.

### Claim 7 (depends on 6)

The method according to claim 6, wherein the method further comprises:
when it is determined that the total data volume, in the swap partition of the operating system, of the determined processes is larger than the current free memory capacity of the physical memory, terminating swap-in processing of the data, in the swap partition of the operating system, of the determined processes.

### Claim 8

An apparatus for swapping in data to a memory, the apparatus comprising:
a determining module, configured to determine, according to a received instruction command, at least one process in which data needs to be swapped in to a physical memory of an operating system, wherein the instruction command carries at least one process identifier that is used to indicate the process in which data needs to be swapped in to the physical memory of the operating system; and
a processing module, configured to swap in all data, in a swap partition of the operating system, of at least one process of the determined at least one process to the physical memory of the operating system according to a current free memory capacity of the physical memory of the operating system.

### Claim 9 (depends on 8)

The apparatus according to claim 8, wherein if it is determined that there is one process in which data needs to be swapped in to the physical memory of the operating system, the processing module is configured to:
when it is determined that a data volume, in the swap partition of the operating system, of the determined process is not larger than the current free memory capacity of the physical memory of the operating system, swap in all data, in the swap partition, of the determined process to the physical memory.

### Claim 10 (depends on 9)

The apparatus according to claim 9, wherein the processing module is further configured to:
when it is determined that the data volume, in the swap partition of the operating system, of the determined process is larger than the current free memory capacity of the physical memory of the operating system, terminate swap-in processing of the data, in the swap partition of the operating system, of the determined process.

### Claim 11 (depends on 8)

The apparatus according to claim 8, wherein if it is determined that there are at least two processes in which data needs to be swapped in to the physical memory of the operating system, the processing module is configured to:
sequentially select each process from the determined processes, and determine whether a data volume, in the swap partition, of a currently selected process is not larger than the current free memory capacity of the physical memory;
when it is determined that the data volume, in the swap partition, of the currently selected process is not larger than the current free memory capacity of the physical memory, swap in all data, in the swap partition, of the currently selected process to the physical memory; and
when it is determined that the data volume, in the swap partition, of the currently selected process is larger than the current free memory capacity of the physical memory, terminate swap-in processing of the data, in the swap partition, of the currently selected process.

### Claim 12 (depends on 8)

The apparatus according to claim 8, wherein if it is determined that there are at least two processes in which data needs to be swapped in to the physical memory of the operating system, and the instruction command further carries information about a priority corresponding to each process identifier, the processing module is further configured to:
sequentially select each process from the determined processes in a sequence from high to low according to the priorities corresponding to the process identifiers, and determine whether a data volume, in the swap partition, of a currently selected process is not larger than the current free memory capacity of the physical memory;
when it is determined that the data volume, in the swap partition, of the currently selected process is not larger than the current free memory capacity of the physical memory, swap in all data, in the swap partition, of the currently selected process to the physical memory; and
when it is determined that the data volume, in the swap partition, of the currently selected process is larger than the current free memory capacity of the physical memory, terminate swap-in processing of the data, in the swap partition, of the currently selected process.

### Claim 13 (depends on 8)

The apparatus according to claim 8, wherein if it is determined that there are at least two processes in which data needs to be swapped in to the physical memory of the operating system, the processing module is configured to:
when it is determined that a total data volume, in the swap partition of the operating system, of the determined processes is not larger than the current free memory capacity of the physical memory of the operating system, swap in all data, in the swap partition, of the determined processes to the physical memory.

### Claim 14 (depends on 13)

The apparatus according to claim 13, wherein the processing module is further configured to:
when it is determined that the total data volume, in the swap partition of the operating system, of the determined processes is larger than the current free memory capacity of the physical memory, terminate swap-in processing of the data, in the swap partition of the operating system, of the determined processes.
