# US 2008/0270771 A1 · Method of optimizing multi-set context switch for embedded processors

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

- Number: US 2008/0270771 A1
- Document ID: US20080270771A1
- Status: Published application
- Kind: A1
- Application number: 11/742,322
- Filed: 2007-04-30
- Published: 2008-10-30
- Earliest claimed: 2007-04-30
- Assignees: National Tsing Hua University
- Inventors: Jenq Kuen Lee; Kun Yuan Hsieh; Yung Chia Lin
- Web page: https://patentgrep.com/patent/US20080270771A1

## CPC

- G06F 9/3012: {Organisation of register space, e.g. banked or distributed register file}
- G06F 9/30123: {according to context, e.g. thread buffers}
- G06F 9/462: {with multiple register sets}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A method of optimizing multi-set context switch for embedded processors includes the steps of partitioning a plurality of registers into a plurality of register sets based on a live-range-sensitive context-switch procedure that is associated with a usage frequency of each of the registers, storing contents of first target registers according to live set information of a current task, wherein the first target registers are selected from the register sets, determining a next task by an operating system and updating the live set information according to the next task, and restoring contents of second target registers according to the updated live set information, wherein the second target registers are selected from the register sets.

## Claims

### Claim 1

A method of optimizing multi-set context switch for embedded processors, comprising the steps of:
partitioning a plurality of registers into a plurality of register sets based on a live-range-sensitive context-switch procedure that is associated with a usage frequency of each of the registers;
storing contents of first target registers according to live set information of a current task, wherein the first target registers are selected from the register sets;
determining a next task by an operating system and updating the live set information according to the next task; and
restoring contents of second target registers according to the updated live set information, wherein the second target registers are selected from the register sets.

### Claim 2 (depends on 1)

The method of optimizing multi-set context switch for embedded processors of claim 1, wherein the live set information is generated by the compiler.

### Claim 3 (depends on 1)

The method of optimizing multi-set context switch for embedded processors of claim 1, wherein the register sets are arranged in the order of decreasing usage frequency of each of the register sets and with increasing indices.

### Claim 4 (depends on 3)

The method of optimizing multi-set context switch for embedded processors of claim 3, wherein the first target registers are selected by the steps of:
providing a first threshold value generated from the live set information;
providing a first union set comprising the register sets with the indices not less than the first threshold value; and
collecting the registers in the first union set to form the first target registers.

### Claim 5 (depends on 3)

The method of optimizing multi-set context switch for embedded processors of claim 3, wherein the second target registers are selected by the steps of:
providing a second threshold value generated from the updated live set information;
providing a second union set comprising the register sets with the indices not less than the second threshold value; and
collecting the registers in the second union set to form the second target registers.

### Claim 6 (depends on 1)

The method of optimizing multi-set context switch for embedded processors of claim 1, wherein the live-range-sensitive context-switch procedure comprises the steps of:
providing a base set comprising the registers and providing a plurality of subsets of the base set, wherein the subsets are arranged in order;
setting each of the subsets empty;
providing a key subset comprising a longest-live register selected from the registers in the base set and the longest-live register having the longest live time;
generating a first system cost associated with the register sets;
moving the long-live register from the key subset to a preceding subset to form a second temporary subset and a first temporary subset, respectively;
generating a second system cost associated with the first temporary subset, the second temporary subset and other subsets excluding the key subset and the preceding subset;
updating the subsets according to the result of comparing the first system cost with the second system cost; and
forming the register sets according to the subsets;
wherein the register sets are arranged in order with the usage frequency of each of the register sets.

### Claim 7 (depends on 6)

The method of optimizing multi-set context switch for embedded processors of claim 6, wherein the step of updating the subsets comprises the steps of:
updating the preceding subset with the first temporary subset and updating the key subset with the second temporary subset if the first system cost is larger than the second system cost; and
removing the longest-live register from the base set.

### Claim 8 (depends on 6)

The method of optimizing multi-set context switch for embedded processors of claim 6, wherein the longest-live register is updated by the compiler.

### Claim 9 (depends on 6)

The method of optimizing multi-set context switch for embedded processors of claim 6, wherein the first system cost is associated with a comparison cost that is defined as a cost function of deciding a live register set before performing context switch, and a store-load cost that is the sum of products of each single cost and a corresponding living probability.

### Claim 10 (depends on 9)

The method of optimizing multi-set context switch for embedded processors of claim 9, wherein the corresponding living probability of the each register set is correlated to a live time of the each register set over the total execution time of the multitasking operating system.

### Claim 11 (depends on 6)

The method of optimizing multi-set context switch for embedded processors of claim 6, wherein the live-range-sensitive context-switch procedure is not terminated until each of the subset is determined.
