[go: up one dir, main page]

WO2025262913A1 - Program execution device and program execution method - Google Patents

Program execution device and program execution method

Info

Publication number
WO2025262913A1
WO2025262913A1 PCT/JP2024/022531 JP2024022531W WO2025262913A1 WO 2025262913 A1 WO2025262913 A1 WO 2025262913A1 JP 2024022531 W JP2024022531 W JP 2024022531W WO 2025262913 A1 WO2025262913 A1 WO 2025262913A1
Authority
WO
WIPO (PCT)
Prior art keywords
task
execution
calculation
checkpoint
program
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
PCT/JP2024/022531
Other languages
French (fr)
Japanese (ja)
Inventor
涼太 北川
勝己 奥田
武郎 細見
克久 小笠原
悦洋 岡本
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Mitsubishi Electric Corp
Original Assignee
Mitsubishi Electric Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Mitsubishi Electric Corp filed Critical Mitsubishi Electric Corp
Priority to JP2024562328A priority Critical patent/JP7642174B1/en
Priority to PCT/JP2024/022531 priority patent/WO2025262913A1/en
Publication of WO2025262913A1 publication Critical patent/WO2025262913A1/en
Pending legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/52Program synchronisation; Mutual exclusion, e.g. by means of semaphores

Definitions

  • This disclosure relates to a program execution device and a program execution method.
  • the exclusive control function provided by the operating system can be used to exclusively control multiple threads or tasks, including critical sections, on a single core.
  • OS operating system
  • a system call is issued to invoke the kernel's exclusive control function. Therefore, in addition to the cost of the exclusive processing itself, there is the cost of switching from userland to the kernel, and this overhead accumulates each time a critical section is executed, resulting in performance degradation.
  • a userland process sets a flag indicating preemption inhibition in its own preemption inhibition variable to 1, and the process invokes a setting process to set the address information where the preemption inhibition variable is located in the OS.
  • the OS references the preemption inhibition variable using a preset preemption inhibition variable address in response to a periodically occurring timer interrupt, and if the value of the preemption inhibition flag is 1 and the time elapsed since the preemption inhibition start time is less than the duration threshold, the OS continues to execute the process without performing preemption.
  • Patent Document 1 from the perspective of a userland process, preemption can be suppressed simply by setting a value in its own preemption-prohibited variable immediately before the critical section is executed. From an assembly level perspective, this can be achieved by adding instructions to load a value into a register and store the register value in memory, and the degradation in process execution performance is thought to be small, but not zero.
  • preemption execution is blocked during execution of a critical section, there is no function to re-execute the blocked preemption after the critical section is executed, and the process must wait for the next preemption opportunity. This can result in long response times.
  • the present disclosure has been made in light of the above, and aims to provide a program execution device that can perform exclusive control while minimizing performance degradation and extended response times, even when multiple threads or tasks that contain a high density of critical sections are exclusively controlled on a single processor core.
  • the program execution device disclosed herein comprises a storage device that stores an operation program and a system program, and a microprocessor that has one or more processor cores and executes the operation program and the system program.
  • the operation program includes a first operation task and a second operation task that has a scheduling priority lower than that of the first operation task, and is executed on a single processor core of the microprocessor.
  • the second operation task includes multiple critical sections and checkpoints located at the beginning of each critical section.
  • the program execution device comprises a task switching unit that transfers execution rights from the second operation task to the first operation task if the second operation task is being executed, and a task modification unit that, when a request to transfer execution rights to the first operation task is made during execution of the second operation task, suspends execution of the second operation task, modifies the second operation task in the storage device to call the task switching unit for the next checkpoint in the second operation task, and resumes execution of the second operation task from the point of suspension in the second operation task.
  • the program execution device disclosed herein has the advantage of being able to perform exclusive control while minimizing performance degradation and response time extension, even when multiple threads or tasks that contain a high density of critical sections are exclusively controlled on a single processor core.
  • FIG. 1 is a block diagram showing an example of a configuration of a program execution device according to a first embodiment
  • 1 is a time chart showing an example of an operation when a computing program is executed in the first embodiment
  • FIG. 10 is a diagram showing an example of a C language description of a second operation task including a critical section in the first embodiment.
  • FIG. 10 is a diagram showing an example of an assembly code of a second operation task including a critical section in the first embodiment.
  • FIG. 1 is a diagram illustrating an example of a configuration of an address calculation unit of a system program in a program execution device according to a first embodiment;
  • FIG. 1 is a diagram showing an example of a configuration of an address table of an address calculation unit of a system program in a program execution device according to a first embodiment
  • FIG. 1 is a diagram illustrating an example of a configuration of a checkpoint information holding register of a system program of the program execution device according to the first embodiment
  • 1 is a flowchart illustrating an example of an operation of a task correction unit of a system program of a program execution device according to a first embodiment.
  • 1 is a flowchart showing an example of an operation of a task switching unit of a system program of a program execution device according to a first embodiment
  • FIG. 1 is a sequence diagram illustrating an example of a series of operations of each component of the program execution device according to the first embodiment.
  • FIG. 10 is a block diagram showing an example of a configuration of a system program of a program execution device according to a second embodiment.
  • FIG. 10 is a diagram showing an example of a C language description of a second operation task including a critical section in the second embodiment.
  • 10 is a flowchart showing an example of an operation of a task correction unit of a system program of a program execution device according to a second embodiment.
  • 10 is a flowchart showing an example of an operation of a task switching unit of a system program of a program execution device according to a second embodiment.
  • FIG. 10 is a block diagram showing an example of a configuration of an arithmetic program of a program execution device according to a third embodiment.
  • FIG. 10 is a time chart showing an example of an operation when a computing program is executed in the third embodiment.
  • FIG. 10 is a diagram showing an example of a C language description of an h-th operation task including a critical section in the third embodiment.
  • FIG. 10 is a diagram showing an example of a C language description of an i-th operation task including a critical section in the third embodiment.
  • 10 is a flowchart showing an example of an operation of a task correction unit of a system program of a program execution device according to a third embodiment.
  • 10 is a flowchart showing an example of an operation of a task switching unit of a system program of a program execution device according to a third embodiment.
  • FIG. 10 is a time chart showing an example of an operation when a computing program is executed in the third embodiment.
  • FIG. 10 is a diagram showing an example of a C language description of an h-th operation task including a critical section in the third embodiment.
  • FIG. 10 is a diagram showing an example of
  • FIG. 10 is a sequence diagram illustrating an example of a series of operations of each component of the program execution device according to the third embodiment.
  • FIG. 13 is a diagram showing an example of a C language description of an h-th operation task including a critical section in the fourth embodiment.
  • FIG. 13 is a diagram showing an example of a C language description of an i-th operation task including a critical section in the fourth embodiment.
  • 10 is a flowchart showing an example of an operation of a task correction unit of a system program of a program execution device according to a fourth embodiment.
  • 10 is a flowchart showing an example of an operation of a task switching unit of a system program of a program execution device according to a fourth embodiment.
  • Performance degradation due to the overhead of exclusive control processing can be reduced by reducing the frequency of use of the exclusive control functions provided by the OS depending on the execution status of the user program, or by performing exclusive control processing in userland instead.
  • Performance degradation due to the overhead of exclusive control processing can be reduced by reducing the frequency of use of the exclusive control functions provided by the OS depending on the execution status of the user program, or by performing exclusive control processing in userland instead.
  • Performance degradation due to the overhead of exclusive control processing can be reduced by reducing the frequency of use of the exclusive control functions provided by the OS depending on the execution status of the user program, or by performing exclusive control processing in userland instead.
  • Performance degradation due to the overhead of exclusive control processing can be reduced by reducing the frequency of use of the exclusive control functions provided by the OS depending on the execution status of the user program, or by performing exclusive control processing in userland instead.
  • Performance degradation due to the overhead of exclusive control processing can be reduced by reducing the frequency of use of the exclusive control functions provided by the OS depending on the execution status of the user program, or by performing exclusive control processing in
  • the emulator is said to consist of multiple dedicated hardware engine models and a shared memory model.
  • the dedicated hardware engine models simulate the instruction operations of the dedicated hardware engines using instructions from the host machine's processor. If the instruction being simulated is a load or store instruction, it will access the shared memory model, so basically the processing of one instruction in the dedicated hardware engine must be exclusively controlled as an indivisible process (critical section).
  • emulator performance is required to be equal to or better than the specs of the target machine. For example, if the target machine's processor frequency is 100 MHz, the time required to execute one instruction must be 10 ns or less. It is easy to imagine that if even a few host machine instructions are added to simulate one target machine instruction for the sake of mutual exclusion, this will result in a significant degradation in the emulator's overall performance.
  • each task corresponding to a dedicated hardware engine must be able to periodically calculate and send control commands to devices such as servos or motors in real time. For example, if an interrupt is used to switch the execution of tasks for each dedicated hardware engine model, it is important that the response time to the interrupt is short and that response performance is good.
  • Embodiment 1 The following describes a program execution device and a program execution method according to embodiment 1.
  • embodiment 1 an example is described in which two computation tasks each having an execution period and a scheduling priority are prioritized by an OS, but embodiment 1 can also be applied to a computation task that does not have an execution period or is not prioritized.
  • FIG. 1 is a block diagram showing an example of the configuration of a program execution device 1000 according to the first embodiment.
  • the program execution device 1000 according to the first embodiment can be constructed, for example, by an embedded controller, but is not limited to this.
  • the program execution device 1000 includes a microprocessor 1100, a main memory device 1200, and a secondary memory device 1300 as a memory device.
  • the microprocessor 1100 has one or more processor cores 1100-1 to 1100-4 and executes various programs. While Figure 1 illustrates a configuration with four processor cores 1100-1 to 1100-4, the number of processor cores is not limited to this.
  • the main memory 1200 stores programs and data required for program execution.
  • the main memory 1200 is, for example, cache memory or RAM (Random Access Memory).
  • the secondary memory 1300 stores and retains programs and data required for program execution.
  • the secondary memory 1300 is, for example, Flash memory or eMMC (embedded Multi-Media Card).
  • the secondary memory 1300 has an operation program 1310 and a system program 1320.
  • the operation program 1310 has a first operation task 1311 and a second operation task 1312.
  • the system program 1320 includes an address calculation unit 1321, a checkpoint information holding register 1322, a task correction unit 1323, and a task switching unit 1324.
  • the task correction unit 1323 uses the address calculation unit 1321 to identify and correct the checkpoint to be executed next for the currently running second calculation task 1312. At that time, a pair of the address of the corrected checkpoint and the instruction at the location pointed to by that address is stored in the checkpoint information holding register 1322. As will be described later, checkpoints are simply marks for identifying critical sections, and no processing is performed by the processor cores 1100-1 to 1100-4.
  • the task switching unit 1324 restores the checkpoint in the second calculation task 1312 corrected by the task correction unit 1323, and switches task execution between the first calculation task 1311 and the second calculation task 1312.
  • Figure 2 is a time chart showing an example of the operation of the calculation program 1310 during execution in embodiment 1.
  • the first calculation task 1311 and the second calculation task 1312 are threads or tasks, which are the smallest units of processing executed by the OS. Furthermore, the first calculation task 1311 and the second calculation task 1312 share an address space with each other and do not have their own independent address spaces. In addition, the first calculation task 1311 and the second calculation task 1312 are not interrupt processing or exception processing. The following explanation takes as an example a case where the first calculation task 1311 and the second calculation task 1312 are tasks.
  • the first calculation task 1311 has a first execution period 2110 and a first scheduling priority 2120.
  • the second calculation task 1312 has a second execution period 2210 and a second scheduling priority 2220 that is lower than the first scheduling priority 2120.
  • the first calculation task 1311 and the second calculation task 1312 are allocated to and executed by a single processor core 1100-n provided in the microprocessor 1100 based on their respective scheduling priorities by the OS scheduler.
  • a timer interrupt or the like occurs at the start of the first execution cycle 2110 of the first calculation task 1311. This causes the execution of the second calculation task 1312 to be suspended, and because the first scheduling priority 2120 is higher than the second scheduling priority 2220, the OS starts execution of the first calculation task 1311. When execution of the first calculation task 1311 ends, execution of the second calculation task 1312 resumes from the point where it was interrupted.
  • Figure 3 shows an example of a C language description of the second calculation task 1312 including a critical section 3400-n in embodiment 1.
  • n is 1, 2, 3, etc.
  • a running variable 3100 is defined, indicating whether the second calculation task 1312 is running.
  • a value of "true” for the running variable 3100 indicates that the task is running, and a value of "false” indicates that the task is not running.
  • a task2() function 3200 is also defined as a routine executed by the second calculation task 1312, and it is assumed that the entry point of this routine is linked to the second calculation task 1312 when the second calculation task 1312 is created.
  • Figure 3 shows an example of an implementation of the task2() function 3200, in which a code block containing a large number of densely packed critical sections is repeatedly processed using a while statement.
  • the waitUntilDispatched() function is used at the beginning of the while statement block to wait until the OS grants execution permission and the task enters the running state. Note that the waitUntilDispatched() function is written to make the example in Figure 3 easier to understand, and in practice a function that acquires a semaphore or similar provided by the OS may be used.
  • the running variable 3100 is set to "true"
  • the running variable 3100 is set to "false".
  • checkpoint 3300-n is simply a marker or label for identifying critical section 3400-n, and no processing is performed by processor cores 1100-1 to 1100-4.
  • each critical section 3400-n includes a checkpoint 3300-n at its beginning that is modified by task modification unit 1323, care must be taken to ensure that the two consecutive critical sections 3400-n and 3400-(n+1) are not optimized together during compilation, resulting in the boundary between them being removed. Therefore, for example, as shown in Figure 3, it is appropriate to write labels equivalent to checkpoint 3300-n using inline assembler with a volatile modifier.
  • the position at which checkpoints 3300-n are inserted into the second operation task 1312 does not necessarily have to be before or after each critical section 3400-n.
  • checkpoints may be inserted after every third or every fourth critical section.
  • the interval at which checkpoints 3300-n are inserted may be used as a parameter, and the interval at which checkpoints 3300-n are inserted may be adjusted based on the degree of degradation in execution performance and the estimated or measured values of response time.
  • FIG. 4 is a diagram showing an example of assembly code for the second operation task 1312, which includes a critical section, in embodiment 1.
  • FIG. 4 shows a simplified version of the assembly code generated as a result of compiling the C language code for the second operation task 1312 shown in FIG. 3.
  • Checkpoints 4100-n in FIG. 4 correspond to checkpoints 3300-n in FIG. 3.
  • FIG. 5 is a diagram showing an example of the configuration of the address calculation unit 1321 of the system program 1320 of the program execution device 1000 according to the first embodiment.
  • the address calculation unit 1321 receives a program counter value as input, and calculates the address of the checkpoint 3300-n to be executed next in the second calculation task 1312 from the program counter value.
  • the address calculation unit 1321 includes an address table 5100.
  • Figure 6 is a diagram showing an example of the configuration of the address table 5100 of the address calculation unit 1321 of the system program 1320 of the program execution device 1000 according to the first embodiment.
  • the address table 5100 is an array of addresses on the main memory device 1200 where the checkpoint 3300-n inserted in the second operation task 1312 is located.
  • Entry 6100-n represents the storage of the addresses of checkpoint 3300-n in Figure 3 and checkpoint 4100-n in Figure 4 (the addresses of the checkpoints in Figures 3 and 4 are the same).
  • One method for obtaining the address of checkpoint 3300-n in the second operation task 1312 is, for example, to declare a variable corresponding to the label equivalent to checkpoint 3300-n as extern in the second operation task 1312, and then obtain the address of each checkpoint 3300-n by referencing each variable during execution.
  • the series of operations up to loading the acquired addresses into each entry 6100-n only needs to be performed once after the second calculation task 1312 is loaded into the main memory 1200, and may be performed during the initialization process of the second calculation task 1312.
  • FIG. 7 is a diagram showing an example of the configuration of the checkpoint information holding register 1322 of the system program 1320 of the program execution device 1000 according to the first embodiment.
  • the checkpoint information holding register 1322 includes an address field 7100 for holding the address of a checkpoint, and an instruction field 7200 for holding the instruction at the location indicated by the checkpoint address.
  • FIG. 8 is a flowchart showing an example of the operation of the task correction unit 1323 of the system program 1320 of the program execution device 1000 according to the first embodiment.
  • the task correction unit 1323 is called when a request for transfer of execution rights occurs, and corrects the checkpoint 3300-n in the second calculation task 1312 as necessary.
  • the execution right transfer request can be made using, for example, an interrupt or a semaphore, and a notification can be sent to the second calculation task 1312 from a task assigned to a processor core 1100-m other than the processor core 1100-n to which the calculation program 1310 is assigned.
  • the task correction unit 1323 may be implemented as an interrupt handler.
  • the task correction unit 1323 may be implemented as a task.
  • step S8101 the value of the running variable 3100 in the second calculation task 1312 is checked to see if it is "true” or "false,” and it is determined whether the second calculation task is currently running. If it is currently running, step S8102 is processed next; if it is not currently running, step S8201 is processed next.
  • step S8102 the program counter (PC) value (return address) at the time when execution of the second calculation task 1312 was interrupted due to the task correction unit 1323 being activated in response to a request to transfer execution rights is obtained.
  • the task correction unit 1323 is implemented as an interrupt handler, for example, if the architecture of the microprocessor 1100 is Armv8, the PC value is saved to a link register when an interrupt occurs, and the PC value is obtained by accessing the link register from the interrupt handler.
  • the register state, etc. (context) is usually saved to a save area on the main memory device 1200 when the OS switches task execution, and the PC value is obtained by accessing that save area.
  • step S8103 the PC value obtained in step S8102 is passed to the address calculation unit 1321, and the address of the next checkpoint 3300-n to be executed in the second calculation task 1312 is obtained.
  • step S8104 the next checkpoint information, which is a pair of the address of the next checkpoint 3300-n obtained in step S8103 and the instruction located at the location pointed to by the address of checkpoint 3300-n, is stored in the checkpoint information holding register 1322. These are stored in the address field 7100 and instruction field 7200, respectively.
  • step S8105 the location pointed to by the address of the next checkpoint 3300-n obtained in step S8103 is rewritten to an instruction that calls the entry point of the task switching unit 1324.
  • This is nothing more than rewriting the instruction in the executable text area loaded onto the main memory device 1200.
  • the executable format is ELF (Executable and Linkage Format)
  • this rewrites the load segment (called the text area) that contains the text section in which the instruction is stored.
  • the calculation program 1310 must assign a writable attribute to the text area when it is compiled.
  • step S8106 execution of the task correction unit 1323 ends, and execution of the second calculation task 1312 resumes.
  • step S8201 since it was determined in step S8101 that the second calculation task 1312 was not currently being executed, the task correction unit 1323 directly calls the task switching unit 1324 and starts the first calculation task 1311.
  • FIG. 9 is a flowchart showing an example of the operation of the task switching unit 1324 of the system program 1320 of the program execution device 1000 according to the first embodiment.
  • the task switching unit 1324 restores the checkpoint in the second calculation task 1312 corrected by the task correction unit 1323, and uses the functions of the OS to transfer execution rights from a task with a low scheduling priority to a task with a high scheduling priority.
  • the task switching unit 1324 may be implemented as a function, for example.
  • step S9101 it is determined whether the second calculation task 1312 is running. For example, this determination may be made by referring to whether the value of the running variable 3100 in the second calculation task 1312 is "true" or "false.” If the second calculation task 1312 is running, step S9102 is processed next; if the second calculation task 1312 is not running, step S9104 is processed next.
  • step S9102 the address of checkpoint 3300-n corrected by the task correction unit 1323 and the pair of instructions located at the location indicated by the address of checkpoint 3300-n are obtained from the checkpoint information holding register 1322.
  • step S9103 the location pointed to by the address obtained in step S9102 is rewritten to the command obtained in step S9102.
  • step S9104 the second operation task 1312, which has a lower second scheduling priority 2220, transfers execution rights to the first operation task 1311, which has a higher first scheduling priority 2120.
  • the transfer of execution rights can be achieved, for example, by using a binary semaphore.
  • the second operation task 1312 begins execution by acquiring a binary semaphore (P operation).
  • the task switcher 1324 releases the binary semaphore (V operation).
  • the OS determines that the first calculation task 1311 has the highest scheduling priority among the calculation tasks currently being executed or executable on the processor core 1100-n, and execution is switched from the second calculation task 1312 to the first calculation task 1311.
  • step S9105 the process waits until execution of the first calculation task 1311 is complete.
  • step S9106 the process returns to the address obtained in step S9102, and execution of the second operation task 1312 resumes.
  • the task switching unit 1324 is implemented as a function
  • the address of the instruction following the jump instruction to the function's entry point is usually held in a dedicated register as the return address, and is used when returning from the function to the caller.
  • the position of the first instruction at the beginning of each critical section 3400-n in the second operation task 1312 is set as checkpoint 3300-n.
  • the task modification unit 1323 rewrites the next checkpoint 3300-(n+1) of the critical section 3400-n that was being executed to an instruction that calls the task switching unit 1324.
  • the task switcher 1324 If the task switcher 1324 is called from checkpoint 3300-(n+1), and the task switcher 1324 returns to the second operation task 1312 by returning to the return address stored in the dedicated register, the task will return to the position of the second instruction from the beginning of the critical section 3400-n, and the first instruction from the beginning will not be executed. To avoid this, when returning from the task switcher 1324 to the second operation task 1312, it is necessary to return to the address obtained from the checkpoint information holding register 1322.
  • FIG. 10 is a sequence diagram showing an example of a series of operations of the components of the program execution device 1000 according to the first embodiment.
  • FIG. 10 shows how the first calculation task 1311, the second calculation task 1312, the task correction unit 1323, and the task switching unit 1324 interact with each other when a request for transfer of execution rights occurs during execution of the critical section 3400-2 in the second calculation task 1312.
  • the task correction unit 1323 is activated and corrects the task so that the task switch unit 1324 is called from checkpoint 3300-3 located at the beginning of the next critical section 3400-3. Execution of the task correction unit 1323 ends, and the unexecuted part of critical section 3400-2 that was being executed in the second operation task 1312 is executed. Execution reaches checkpoint 3300-3 located at the beginning of the next critical section 3400-3, and the task switch unit 1324 is called. The task switch unit 1324 corrects the task so that it is not called from checkpoint 3300-3, and transfers execution rights from the second operation task 1312 to the first operation task 1311, and the first operation task 1311 is executed.
  • the task modification unit 1323 modifies the currently executing task to call the task switching unit 1324 from a checkpoint in the currently executing task, and exclusive control is achieved by switching execution to another task starting from the modified checkpoint.
  • the task modification unit 1323 does not modify the currently executing task, and the original task simply has a checkpoint (label) inserted that is not processed by the processor core 1100-n, so performance degradation during execution is, in principle, zero. Furthermore, because task execution switching is always performed starting from a checkpoint, there is an effect of preventing an unintended extension of response time.
  • Embodiment 2 A program execution device and a program execution method according to the second embodiment will be described below. In the following description, components similar to those described in the first embodiment will be denoted by the same reference numerals, and detailed description thereof will be omitted as appropriate. In the second embodiment, an example will be described in which two computation tasks each having an execution period and a scheduling priority are prioritized by the OS, but the second embodiment can also be applied to a computation task that does not have an execution period or is not prioritized.
  • the task correction unit 1323 when a request to transfer execution rights occurs, the task correction unit 1323 rewrites the checkpoint in the task being executed. In other words, an operation is performed to rewrite the executable text area loaded on the main memory device 1200.
  • a text area is set with readable and executable attributes by a compiler, and rewriting to the text area is not possible when the text area is being executed. If a text area that is intended to be read and executed were to be rewritten during execution, a malicious code block could be inserted and executed, so this is suppressed from a security perspective. Therefore, in the second embodiment, a program execution device and program execution method are described that do not require the operation of rewriting the text area during execution.
  • FIG. 11 is a block diagram showing an example of the configuration of a system program 11000 of a program execution device 1000 according to the second embodiment.
  • the system program 11000 includes a task correction unit 11100 and a task switching unit 11200.
  • Figure 12 is a diagram showing an example of a C language description of the second calculation task 1312 including a critical section 12400-n in embodiment 2.
  • a function pointer 12200 is defined as a checkpoint and initialized to "0."
  • the function pointer 12200 will be described in detail in the explanation of the operation flow of the task correction unit 11100, but this is a difference from embodiment 1.
  • the task correction unit 11100 assigns the address of the entry point of the task switching unit 11200 to the function pointer 12200.
  • Figure 12 shows an example of an implementation of the task2() function 12300 in which a code block containing a large number of critical sections 12400-n densely is repeatedly processed using a while statement.
  • the waitUntilDispatched() function is used at the beginning of the while statement block to wait until execution permission is granted by the OS and the task enters the running state.
  • the running variable 12100 is set to "true"
  • the running variable 12100 is set to "false”.
  • checkpoints 12200-1 to 12200-3 are code for referencing the function pointer and calling the task switcher 11200.
  • overhead is generated for conditional branching depending on the value of the function pointer at the checkpoint. This code for checking the value of the function pointer and calling the function using the function pointer results in overhead for processing the conditional branching compared to embodiment 1, in which the second calculation task 1312 does not contain any unnecessary code. Note that the label corresponding to checkpoint 3300-n in Figure 3 is not processed during execution.
  • hint information may be provided to the compiler, indicating whether the conditional branch is more likely to be taken or not taken, for example.
  • the compiler used is GCC (GNU Compiler Collection) and there is a high probability that the conditional branch of the if statement at checkpoint 12200-n will not be satisfied, checkpoint 12200-n can be written as "if(__builtin_expect(!!(checkpoint) ⁇ 0))checkpoint();" using the built-in functions provided by GCC.
  • FIG. 13 is a flowchart showing an example of the operation of the task modification unit 11100 of the system program 11000 of the program execution device 1000 according to the second embodiment.
  • the task modification unit 11100 is called when a request for transfer of execution rights occurs, and modifies the checkpoint 12200-n in the second calculation task 1312 as necessary.
  • the execution right transfer request can be made using, for example, an interrupt or a semaphore, and a notification can be sent to the second calculation task 1312 from a task assigned to a processor core 1100-m other than the processor core 1100-n to which the calculation program 1310 is assigned.
  • the task modification unit 11100 may be implemented as an interrupt handler.
  • a semaphore is used, the task modification unit 11100 may be implemented as a task.
  • step S13101 the value of the running variable 12100 in the second calculation task 1312 is checked to see if it is "true” or "false,” and it is determined whether the second calculation task is currently running. If it is currently running, step S13102 is processed next; if it is not currently running, step S13201 is processed next.
  • step S13102 the address of the entry point of the task switching unit 11200 is cast to the function pointer corresponding to checkpoint 12200-n and assigned to that function pointer type.
  • the task correction unit 11100 does not need to identify the location to be corrected; it only needs to rewrite the value of the function pointer.
  • step S13103 execution of the task correction unit 11100 ends, and execution of the second calculation task 1312 resumes.
  • step S13201 it is determined that the second calculation task 1312 is not currently running, so the task modification unit 11100 directly calls the task switching unit 11200 and starts the first calculation task 1311.
  • FIG. 14 is a flowchart showing an example of the operation of the task switching unit 11200 of the system program 11000 of the program execution device 1000 according to the second embodiment.
  • the task switching unit 11200 restores the checkpoint 12200-n in the second calculation task 1312 corrected by the task correction unit 11100, and uses the OS functions to transfer execution rights from a task with a low scheduling priority to a task with a high scheduling priority.
  • the task switching unit 11200 may be implemented as a function, for example.
  • step S14101 it is determined whether the second calculation task 1312 is running. For example, this determination may be made by referring to whether the value of the running variable 12100 in the second calculation task 1312 is "true" or "false.” If the second calculation task 1312 is running, step S14102 is processed next; if the second calculation task 1312 is not running, step S14103 is processed next.
  • step S14102 the task correction unit 11100 assigns the invalid value "0" to the function pointer corresponding to the checkpoint 12200-n corrected by the task correction unit 11100.
  • step S14103 the second calculation task 1312, which has a lower second scheduling priority 2220, transfers execution rights to the first calculation task 1311, which has a higher first scheduling priority 2120.
  • step S14104 the process waits until execution of the first calculation task 1311 is complete.
  • step S14105 the process returns to checkpoint 12200-n in the second calculation task 1312, and execution of the second calculation task 1312 resumes. If the task switching unit 11200 is implemented as a function, this step is a normal return operation from the function.
  • the task modification unit 11100 modifies the currently executing task so that the task switching unit 11200 is called from a checkpoint in the currently executing task, and exclusive control is achieved by switching execution to another task starting from the modified checkpoint.
  • the same effect as the first embodiment is achieved in terms of extending response time.
  • the task modification unit 11100 does not rewrite the text area loaded on the main memory device 1200, which has the effect of closing security holes that allow malicious code blocks to be inserted and executed during execution.
  • Embodiment 3 A program execution device and a program execution method according to the third embodiment will be described below. In the following description, components similar to those described in the first and second embodiments will be denoted by the same reference numerals, and detailed description thereof will be omitted as appropriate.
  • the third embodiment an example will be described in which three or more computation tasks each having an execution period and a scheduling priority are prioritized by the OS, but the third embodiment can also be applied to computation tasks that do not have an execution period or are not prioritized.
  • a program execution device was described for a case in which a computation program includes two computation tasks, all of which are assigned to a single processor core for execution.
  • a program execution device and program execution method will be described for a case in which a computation program includes three or more tasks, all of which are assigned to a single processor core for execution.
  • the third embodiment is based on the first embodiment and is a program execution device in which the number of computation tasks is expanded to three or more.
  • checkpoints are simply marks or labels for identifying critical sections, and no processing is performed by processor cores 1100-1 to 1100-4.
  • embodiment 3 the number of calculation tasks was two, so one (second calculation task 1312) was the calculation task to be interrupted, and the other (first calculation task 1311) was the calculation task that interrupted. Therefore, the number of simultaneous execution right transfer requests during execution of the second calculation task 1312 was at most one.
  • the number of calculation tasks is three or more, so there will be two or more interrupting calculation tasks. In other words, it is possible to imagine a case where the number of simultaneous execution right transfer requests during execution of a certain calculation task will be two or more.
  • a malfunction occurs if another execution right transfer request occurs during the period from the time an execution right transfer request is made until the time the first operation task 1311 starts executing. During this period, the checkpoint in the second operation task 1312 that was originally being executed is rewritten with an instruction to jump to the entry point of the task switching unit 1324. If another execution right transfer request occurs during this period, it may happen that the same checkpoint in the second operation task 1312 is rewritten twice, or that the address of the checkpoint to be rewritten cannot be obtained. To avoid these cases, a mechanism is used that does not accept another execution right transfer request during this period.
  • FIG. 15 is a block diagram showing an example of the configuration of a calculation program 15000 of a program execution device 1000 according to the third embodiment.
  • the calculation program 15000 includes N tasks, including a first calculation task 15100, an h-th calculation task 15200, and an i-th calculation task 15300 (1 ⁇ h ⁇ i ⁇ N).
  • the h-th calculation task 15200 corresponds to the second calculation task in the claims
  • the i-th calculation task 15300 corresponds to the third calculation task in the claims.
  • Figure 16 is a time chart showing an example of the operation during execution of the computation program 15000 in embodiment 3.
  • the first computation task 15100 has a first execution period 16110 and a first scheduling priority 16120.
  • the h-th computation task 15200 has an h-th execution period 16210 and an h-th scheduling priority 16220 that is lower than the first scheduling priority 16120.
  • the i-th computation task 15300 has an i-th execution period 16310 and an i-th scheduling priority 16320 that is lower than the h-th scheduling priority 16220.
  • the first computation task 15100, the h-th computation task 15200, and the i-th computation task 15300 are allocated to a single processor core 1100-n provided in the microprocessor 1100 and executed by the OS scheduler based on their respective scheduling priorities.
  • a timer interrupt or the like occurs at the start of the h-th execution cycle 16210 of the h-th computation task 15200. This causes the execution of the i-th computation task 15300 to be suspended, and because the h-th scheduling priority 16220 is higher than the i-th scheduling priority 16320, the h-th computation task 15200 is executed by the OS. When the execution of the h-th computation task 15200 ends, execution of the i-th computation task 15300 resumes from the point where it was interrupted.
  • a timer interrupt or the like occurs at the start of the first execution cycle 16110 of the first calculation task 15100. This causes the execution of the h-th calculation task 15200 to be suspended, and because the first scheduling priority 16120 is higher than the h-th scheduling priority 16220, the OS executes the first calculation task 15100. When the execution of the first calculation task 15100 ends, execution of the h-th calculation task 15200 resumes from the point where it was interrupted.
  • Figure 17 is a diagram showing an example of a C language description of the h-th operation task 15200 including a critical section 17400-n in embodiment 3 (1 ⁇ h ⁇ i ⁇ N).
  • a running_h variable 17100 is defined, which indicates whether the h-th operation task 15200 is running. If the value of the running_h variable 17100 is "true”, it indicates that it is running, and if it is "false", it indicates that it is not running.
  • a task_h() function 17200 is defined as a routine executed by the h-th operation task 15200, and it is assumed that the entry point of this routine is linked to the h-th operation task 15200 when the h-th operation task 15200 is generated.
  • Figure 17 shows an example of an implementation of the task_h() function 17200, in which a while statement is used to repeatedly process a code block that includes a large number of critical sections 17400-n densely.
  • the waitUntilDispatched() function is used at the beginning of the while block to wait until execution rights are granted by the task switching unit 1324 and the task enters a running state.
  • the running_h variable 17100 is set to "true", allowing acceptance of the execution rights transfer request, and the running_h variable 17100 is set to "false" at the end of the while block.
  • Figure 18 is a diagram showing an example of a C language description of the i-th operation task 15300 including a critical section 18400-n in embodiment 3 (1 ⁇ h ⁇ i ⁇ N).
  • a running_i variable 18100 is defined, which indicates whether the i-th operation task 15300 is running. If the value of the running_i variable 18100 is "true”, it indicates that it is running, and if it is "false", it indicates that it is not running.
  • a task_i() function 18200 is defined as a routine executed by the i-th operation task 15300, and it is assumed that the entry point of this routine is linked to the i-th operation task 15300 when the i-th operation task 15300 is created.
  • Figure 18 shows an example of an implementation of the task_i() function 18200, in which a while statement is used to repeatedly process a code block that includes a large number of critical sections 18400-n densely.
  • the waitUntilDispatched() function is used at the beginning of the while block to wait until execution permission is granted by the OS and the process enters a running state.
  • the running_i variable 18100 is set to "true", allowing the request to transfer execution permission to be accepted, and the running_i variable 18100 is set to "false" at the end of the while block.
  • FIG. 19 is a flowchart showing an example of the operation of the task modification unit 1323 of the system program 1320 of the program execution device 1000 according to the third embodiment.
  • the task modification unit 1323 is called when a request for transfer of execution rights occurs, and modifies the checkpoint in the calculation task that was being executed as necessary.
  • the execution rights transfer request can be made using, for example, an interrupt or a semaphore, and a notification can be sent to the i-th calculation task 15300 from a task assigned to a processor core 1100-m other than the processor core 1100-n to which the calculation program 15000 is assigned.
  • the task modification unit 1323 may be implemented as an interrupt handler.
  • the task modification unit 1323 may be implemented as a task.
  • processor core 1100-n to which computing program 15000 is assigned is prohibited from accepting requests to transfer execution rights. If an interrupt is used for the request to transfer execution rights, interrupts with a specific ID (Identification) can be masked, or all interrupts can be prohibited. Similar measures can be taken when a semaphore is used for the request to transfer execution rights. This is because when a specific task is started by releasing a semaphore, the OS usually issues an interrupt to the processor core in question to switch the task execution.
  • step S19102 the task modification unit 1323 identifies the task ID of the calculation task to be executed next after the calculation task that was being executed immediately before being called.
  • the execution right transfer request corresponds one-to-one with the calculation task to be executed next.
  • one interrupt ID is linked to one task.
  • a semaphore is linked to one task. In this way, the task modification unit 1323 can identify the task ID of the calculation task to be executed next by referring to the interrupt ID or semaphore.
  • step S19103 the value of the running variable for all calculation tasks is checked to see if it is "true” or "false,” and it is determined whether any calculation task is currently running. If it is currently running, step S19104 is processed next; if it is not currently running, step S19201 is processed next.
  • step S19104 the PC value at the time when the execution of the i-th calculation task 15300 was interrupted due to the task correction unit 1323 being activated in response to a request to transfer execution rights is obtained.
  • step S19105 the PC value acquired in step S19104 is passed to the address calculation unit 1321, and the address of the checkpoint 18300-n to be executed next in the currently running computation task is acquired.
  • the address table 5100 provided in the address calculation unit 1321 may use the method described in the explanation of Figure 6 to acquire the address of the checkpoint during the initialization process of each computation task, for example, and load the acquired address into each entry 6100-n.
  • step S19106 the next checkpoint information, which is a pair of the address of the next checkpoint 18300-n obtained in step S19105 and the instruction located at the location indicated by the address of checkpoint 18300-n, is stored in the checkpoint information holding register 1322.
  • step S19107 the location pointed to by the address of the next checkpoint 18300-n obtained in step S19106 is rewritten to an instruction to call the entry point of the task switching unit 1324.
  • step S19108 execution of the task correction unit 1323 ends, and execution of the i-th calculation task 15300 that was being executed is resumed.
  • step S19201 since it was determined in step S19103 that no calculation tasks were currently being executed, the task modification unit 1323 directly calls the task switching unit 1324 and starts the calculation task specified by the task ID.
  • FIG. 20 is a flowchart showing an example of the operation of the task switching unit 1324 of the system program 1320 of the program execution device 1000 according to the third embodiment.
  • the task switching unit 1324 restores the checkpoint in the running computation task that has been corrected by the task correction unit 1323. It also uses the OS functions to transfer the execution right from a task with a low scheduling priority to a task with a high scheduling priority. It is assumed that the task switching unit 1324 receives the task ID of the computation task from the task correction unit 1323.
  • step S20101 it is determined whether any calculation task is running. For example, this determination may be made by checking whether the value of the running variable for all calculation tasks is "true” or "false.” If any calculation task is running, step S20102 is processed next; if not, step S20104 is processed next.
  • step S20102 the pair of the checkpoint address corrected by the task correction unit 1323 and the instruction located at the location indicated by the checkpoint address is obtained from the checkpoint information holding register 1322.
  • step S20103 the location pointed to by the address obtained in step S20102 is rewritten to the command obtained in step S20102.
  • step S20104 the execution right is transferred from the currently running calculation task to the calculation task specified by the task ID.
  • the execution right is transferred from the i-th calculation task 15300, which has a lower i-th scheduling priority 16320, to the h-th calculation task 15200, which has a higher h-th scheduling priority 16220.
  • step S20105 the process waits until the execution of the calculation task specified by the task ID is completed.
  • step S20106 the process returns to the address obtained in step S20102 and resumes execution of the previously running computation task.
  • FIG. 21 is a sequence diagram showing an example of a series of operations of the components of the program execution device 1000 according to the third embodiment.
  • FIG. 21 shows how the first operation task 15100, the hth operation task 15200, the ith operation task 15300, the task modification unit 1323, and the task switching unit 1324 interact and operate when a request to transfer execution rights to the hth operation task 15200 occurs during execution of the critical section 18400-2 in the ith operation task 15300, and then a request to transfer execution rights to the first operation task 15100 occurs during execution of the critical section 17400-1 in the hth operation task 15200.
  • the task correction unit 1323 is activated and prohibits acceptance of execution rights transfer requests at the beginning of the critical section, and then corrects the task so that the task switch unit 1324 is called from checkpoint 18300-3 located at the beginning of the next critical section 18400-3. Execution of the task correction unit 1323 ends, and the unexecuted part of critical section 18400-2 that was being executed in the i-th operation task 15300 is executed. Execution reaches checkpoint 18300-3 at the beginning of the next critical section 18400-3, and the task switch unit 1324 is called.
  • the task switching unit 1324 is modified so that it is not called from checkpoint 18300-3, and the execution right is transferred from the i-th operation task 15300 to the h-th operation task 15200.
  • the h-th operation task 15200 is executed, and the execution right transfer request is accepted at the beginning of the task.
  • the task correction unit 1323 is activated and prohibits acceptance of the execution rights transfer request at the beginning of the critical section, and then corrects the task so that the task switch unit 1324 is called from checkpoint 17300-2 located at the beginning of the next critical section 17400-2. Execution of the task correction unit 1323 ends, and the unexecuted part of critical section 17400-1 that was being executed in the h-th operation task 15200 is executed. Execution reaches checkpoint 17300-2 at the beginning of the next critical section 17400-2, and the task switch unit 1324 is called.
  • the task switching unit 1324 is modified so that it is not called from checkpoint 17300-2, and the execution right is transferred from the h-th operation task 15200 to the first operation task 15100.
  • the h-th operation task 15200 is executed, and after accepting the execution right transfer request at the beginning of the task, subsequent processing is executed.
  • execution rights are returned to the task switching unit 1324, and the execution is returned to the h-th operation task 15200, and execution of the h-th operation task 15200 is resumed from the beginning of the critical section 17400-2.
  • execution of the h-th operation task 15200 is completed, the execution is returned to the i-th operation task 15300, and execution of the i-th operation task 15300 is resumed from the beginning of the critical section 18400-3.
  • the task modification unit 1323 modifies the currently executing task to call the task switching unit 1324 from a checkpoint in the currently executing task, and exclusive control is achieved by switching execution to another task starting from the modified checkpoint.
  • the task modification unit 1323 does not modify the currently executing task, and the original task simply has a checkpoint (label) inserted that is not processed by the processor core 1100-n, so performance degradation during execution is, in principle, zero. Furthermore, because task execution switching is always performed starting from a checkpoint, there is an effect of preventing an unintended extension of response time.
  • Embodiment 4 A program execution device and a program execution method according to the fourth embodiment will be described below. In the following description, components similar to those described in the first to third embodiments will be denoted by the same reference numerals, and detailed description thereof will be omitted as appropriate. In the fourth embodiment, an example will be described in which three or more computation tasks each having an execution period and a scheduling priority are prioritized by the OS, but the fourth embodiment can also be applied to computation tasks that do not have an execution period or are not prioritized.
  • the fourth embodiment similar to the third embodiment, a program execution device and a program execution method will be described for a case in which an arithmetic program contains three or more arithmetic tasks, all of which are assigned to and executed by a single processor core.
  • the fourth embodiment is a program execution device based on the second embodiment, in which the number of arithmetic tasks is expanded to three or more.
  • FIG. 22 is a diagram showing an example of a C language description of the h-th operation task 15200 including a critical section 22400-n in embodiment 4.
  • a function pointer 22200 is defined as a checkpoint and initialized to "0.”
  • the task modification unit 11100 assigns the address of the entry point of the task switcher 11200 to the function pointer 22200.
  • FIG. 22 shows an example of an implementation of the task_h() function 22300 in which a code block including a high density of multiple critical sections 22400-n is repeatedly processed using a while statement.
  • the waitUntilDispatched() function is used at the beginning of the while statement block to wait until the task switcher 11200 grants execution rights and the task enters the running state.
  • the running_h variable 22100 is set to "true,” allowing acceptance of a request to transfer execution rights, and the running_h variable 22100 is set to "false" at the end of the while statement block.
  • checkpoints 22200-1 to 22200-3 are thus code for referencing the function pointer and calling task switcher 11200, and during execution, overhead is generated for conditional branching depending on the value of the function pointer at the checkpoint.
  • FIG. 23 is a diagram showing an example of a C language description of the i-th operation task 15300 including critical section 23400-n in embodiment 4.
  • a function pointer 23200 is defined as a checkpoint and initialized to "0.”
  • the task modification unit 11100 assigns the address of the entry point of the task switching unit 11200 to the function pointer 23200.
  • FIG. 23 shows an example of an implementation of the task_i() function 23300 in which a code block containing a large number of densely packed critical sections is repeatedly processed using a while statement.
  • the waitUntilDispatched() function is used at the beginning of the while statement block to wait until execution permission is granted by the OS and the task enters the running state.
  • the running_i variable 23100 is set to "true,” allowing acceptance of a request to transfer execution permission, and the running_i variable 23100 is set to "false" at the end of the while statement block.
  • code is written as checkpoints 23200-1 to 23200-3 to check that the value of the function pointer 23200 is not "0" and to call the task switcher 11200 by referencing the function pointer 23200.
  • FIG. 24 is a flowchart showing an example of the operation of the task correction unit 11100 of the system program 11000 of the program execution device 1000 according to the fourth embodiment.
  • the task correction unit 11100 is called when a request to transfer execution rights occurs, and corrects the checkpoints in the computation task that was being executed as necessary.
  • step S24101 the processor core 1100-n to which the computing program 16000 is assigned is prohibited from accepting a request to transfer execution rights.
  • step S24102 the task modification unit 11100 identifies the task ID of the computation task to be executed next after the computation task that was being executed immediately before being called.
  • the execution right transfer request corresponds one-to-one with the computation task to be executed next.
  • one interrupt ID is linked to one task.
  • a semaphore is linked to one task. This allows the task modification unit 11100 to identify the task ID of the computation task to be executed next by referring to the interrupt ID or semaphore.
  • step S24103 the value of the running variable for all calculation tasks is checked to see if it is "true” or "false,” and it is determined whether any calculation task is currently running. If it is currently running, step S24104 is processed next; if it is not currently running, step S24201 is processed next.
  • step S24104 the task switching unit 11200's entry point address is cast to the function pointer corresponding to the checkpoint in the computation task that was being executed, and assigned to that function pointer type.
  • the task correction unit 11100 does not need to identify the location to be corrected; it only needs to rewrite the value of the function pointer.
  • step S24105 execution of the task correction unit 11100 ends, and execution of the calculation task that was being executed is resumed.
  • step S24201 since it was determined in step S24103 that no arbitrary calculation tasks were currently being executed, the task modification unit 11100 directly calls the task switching unit 11200 and starts the calculation task specified by the task ID.
  • FIG. 25 is a flowchart showing an example of the operation of the task switching unit 11200 of the system program 11000 of the program execution device 1000 according to the fourth embodiment.
  • the task switching unit 11200 restores the checkpoint in the currently running computation task corrected by the task correction unit 11100, and uses the OS functions to transfer execution rights from a task with a low scheduling priority to a task with a high scheduling priority.
  • the task switching unit 11200 may be implemented as a function, for example.
  • step S25101 it is determined whether any calculation task is currently running. For example, this determination may be made by checking whether the value of the running variable for all calculation tasks is "true” or "false.” If any calculation task is currently running, step S25102 is processed next; if not, step S25103 is processed next.
  • step S25102 the task correction unit 11100 assigns "0" to the function pointer corresponding to the checkpoint corrected.
  • step S25103 execution rights are transferred from the currently running computation task to the computation task specified by the task ID. For example, execution rights are transferred from the i-th computation task 15300, which has a lower i-th scheduling priority 16320, to the h-th computation task 15200, which has a higher h-th scheduling priority 16220.
  • step S25104 the process waits until the execution of the calculation task specified by the task ID is completed.
  • step S25105 the process returns to the checkpoint in the previously executing calculation task and resumes execution of that calculation task. If the task switching unit 11200 is implemented as a function, this step is a normal return operation from the function.
  • the task modification unit 11100 modifies the currently executing task so that the task switching unit 11200 is called from a checkpoint in the currently executing task, and exclusive control is achieved by switching execution to another task starting from the modified checkpoint.
  • the fourth embodiment has overhead during execution due to conditional branching based on the value of a function pointer at a checkpoint, but performance degradation is minimized by measures such as providing a hint to the compiler regarding the direction of the conditional branch.
  • the fourth embodiment has the same effect as the third embodiment in terms of extending response time. Additionally, the fourth embodiment does not rewrite the text area loaded on the main memory device 1200, which effectively closes security holes that could allow malicious code blocks to be inserted and executed during execution.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Retry When Errors Occur (AREA)

Abstract

A program execution device (1000) comprises: a task switching unit (1324) that, if a second computation task (1312) is being executed, transfers an execution right from the second computation task (1312) to a first computation task (1311); and a task modification unit (1323) that, if a request to transfer the execution right to the first computation task (1311) is made during execution of the second computation task (1312), interrupts execution of the second computation task (1312), modifies the next checkpoint of the second computation task (1312) on a secondary storage device (1300) so as to cause a call to the task switching unit (1324), and resumes execution of the second computation task (1312) from the point of interruption in the second computation task (1312).

Description

プログラム実行装置およびプログラム実行方法Program execution device and program execution method

 本開示は、プログラム実行装置およびプログラム実行方法に関する。 This disclosure relates to a program execution device and a program execution method.

 計算機システムにおいて、クリティカルセクションを含む複数のスレッドまたはタスクをシングルコア上で排他制御する方法として、オペレーティングシステム(OS:Operating System)が提供する排他制御機能が使用できる。例えば、OSが提供する排他制御機能をユーザプログラムから利用する場合、システムコールを発行してカーネルの排他制御機能を呼び出すことになる。よって、排他処理そのもののコストのほかに、ユーザランドからカーネルへの切り替えコストがかかり、クリティカルセクションを実行するたびにそのオーバヘッドが累積され性能劣化を招く。 In computer systems, the exclusive control function provided by the operating system (OS) can be used to exclusively control multiple threads or tasks, including critical sections, on a single core. For example, when using the exclusive control function provided by the OS from a user program, a system call is issued to invoke the kernel's exclusive control function. Therefore, in addition to the cost of the exclusive processing itself, there is the cost of switching from userland to the kernel, and this overhead accumulates each time a critical section is executed, resulting in performance degradation.

 そこで、特許文献1では、ユーザランドのプロセスが自身に備わるプリエンプション禁止変数中のプリエンプション抑制を表すフラグに1を設定し、当該プロセスは設定処理を呼び出して、プリエンプション禁止変数が配置されているアドレスの情報をOSに設定し、OSは、定期的に発生するタイマ割込みを契機として、予め設定されたプリエンプション禁止変数アドレスを用いてプリエンプション禁止変数を参照し、プリエンプション禁止フラグの値が1であり、かつプリエンプション抑制開始時刻からの経過時間が継続時間閾値未満であれば、プリエンプションを実行せずに当該プロセスを継続実行している。 In Patent Document 1, a userland process sets a flag indicating preemption inhibition in its own preemption inhibition variable to 1, and the process invokes a setting process to set the address information where the preemption inhibition variable is located in the OS. The OS then references the preemption inhibition variable using a preset preemption inhibition variable address in response to a periodically occurring timer interrupt, and if the value of the preemption inhibition flag is 1 and the time elapsed since the preemption inhibition start time is less than the duration threshold, the OS continues to execute the process without performing preemption.

国際公開第2016/063511号International Publication No. 2016/063511

 特許文献1では、ユーザランドのプロセスからすれば、クリティカルセクションが実行される直前に自身のプリエンプション禁止変数に値を設定するだけでプリエンプションを抑制できる。これは、アセンブリレベルで見れば、レジスタに値をロードし、レジスタ値をメモリにストアする命令を追加することで実現できると考えられ、プロセスの実行性能の劣化度合いは小さいと考えられるが、ゼロではない。しかし、特許文献1では、クリティカルセクションの実行中にプリエンプションの実行が阻止された場合、クリティカルセクションの実行後に阻止されたプリエンプションを再実行する機能はなく、次のプリエンプションの機会を待たざるを得ない。よって、応答時間が長くなるケースがある。 In Patent Document 1, from the perspective of a userland process, preemption can be suppressed simply by setting a value in its own preemption-prohibited variable immediately before the critical section is executed. From an assembly level perspective, this can be achieved by adding instructions to load a value into a register and store the register value in memory, and the degradation in process execution performance is thought to be small, but not zero. However, in Patent Document 1, if preemption execution is blocked during execution of a critical section, there is no function to re-execute the blocked preemption after the critical section is executed, and the process must wait for the next preemption opportunity. This can result in long response times.

 また、多数のクリティカルセクションを高密度に含む複数のスレッドまたはタスクを単一コア上で排他制御する場合には、排他制御そのものの処理時間によるオーバヘッドが累積し、結果的に無視できないほど大きな性能劣化を招くという問題がある。加えて、排他制御の副作用によってスレッドまたはタスクの応答時間の伸長を引き起こすという問題がある。特許文献1では、これら双方の問題を解決することは困難である。 Furthermore, when multiple threads or tasks that contain a large number of densely packed critical sections are mutually exclusive on a single core, the overhead caused by the processing time of the mutual exclusive control itself accumulates, resulting in a significant degradation of performance that cannot be ignored. In addition, there is the problem that the side effect of the mutual exclusive control is that it causes an increase in the response time of the threads or tasks. It is difficult for Patent Document 1 to solve both of these problems.

 本開示は、上記に鑑みてなされたものであって、多数のクリティカルセクションを高密度に含む複数のスレッドまたはタスクを単一プロセッサコア上で排他制御する場合であっても、性能劣化と応答時間の伸長とを抑えた排他制御を行うことが可能なプログラム実行装置を得ることを目的とする。 The present disclosure has been made in light of the above, and aims to provide a program execution device that can perform exclusive control while minimizing performance degradation and extended response times, even when multiple threads or tasks that contain a high density of critical sections are exclusively controlled on a single processor core.

 上述した課題を解決し、目的を達成するために、本開示によるプログラム実行装置は、演算プログラムおよびシステムプログラムを格納する記憶装置と、1以上のプロセッサコアを備え、演算プログラムおよびシステムプログラムを実行するマイクロプロセッサと、を備える。演算プログラムは、第1演算タスクおよび第1演算タスクより低いスケジューリング優先度を持つ第2演算タスクを含み、マイクロプロセッサにおける単一のプロセッサコア上で実行される。第2演算タスクは、複数のクリティカルセクションと、各クリティカルセクションの先頭に位置するチェックポイントとを含む。プログラム実行装置は、第2演算タスクが実行中であれば第2演算タスクから第1演算タスクに実行権を移すタスク切替部と、第2演算タスクの実行中に第1演算タスクへの実行権移譲要求があったとき、第2演算タスクの実行を中断し、記憶装置上の第2演算タスクにおける次のチェックポイントに対してタスク切替部を呼び出すよう修正し、第2演算タスクにおける中断箇所から第2演算タスクの実行を再開させるタスク修正部と、を備える。 In order to solve the above-mentioned problems and achieve the objectives, the program execution device disclosed herein comprises a storage device that stores an operation program and a system program, and a microprocessor that has one or more processor cores and executes the operation program and the system program. The operation program includes a first operation task and a second operation task that has a scheduling priority lower than that of the first operation task, and is executed on a single processor core of the microprocessor. The second operation task includes multiple critical sections and checkpoints located at the beginning of each critical section. The program execution device comprises a task switching unit that transfers execution rights from the second operation task to the first operation task if the second operation task is being executed, and a task modification unit that, when a request to transfer execution rights to the first operation task is made during execution of the second operation task, suspends execution of the second operation task, modifies the second operation task in the storage device to call the task switching unit for the next checkpoint in the second operation task, and resumes execution of the second operation task from the point of suspension in the second operation task.

 本開示のプログラム実行装置によれば、多数のクリティカルセクションを高密度に含む複数のスレッドまたはタスクを単一プロセッサコア上で排他制御する場合であっても、性能劣化と応答時間の伸長とを抑えた排他制御を行うことが可能となる、という効果を奏する。 The program execution device disclosed herein has the advantage of being able to perform exclusive control while minimizing performance degradation and response time extension, even when multiple threads or tasks that contain a high density of critical sections are exclusively controlled on a single processor core.

実施の形態1にかかるプログラム実行装置の構成の一例を示すブロック図FIG. 1 is a block diagram showing an example of a configuration of a program execution device according to a first embodiment; 実施の形態1において、演算プログラムの実行時の動作の一例を示すタイムチャート1 is a time chart showing an example of an operation when a computing program is executed in the first embodiment; 実施の形態1において、クリティカルセクションを含む第2演算タスクのC言語記述の一例を示す図FIG. 10 is a diagram showing an example of a C language description of a second operation task including a critical section in the first embodiment. 実施の形態1において、クリティカルセクションを含む第2演算タスクのアセンブリ記述の一例を示す図FIG. 10 is a diagram showing an example of an assembly code of a second operation task including a critical section in the first embodiment. 実施の形態1にかかるプログラム実行装置のシステムプログラムのアドレス算出部の構成の一例を示す図FIG. 1 is a diagram illustrating an example of a configuration of an address calculation unit of a system program in a program execution device according to a first embodiment; 実施の形態1にかかるプログラム実行装置のシステムプログラムのアドレス算出部のアドレステーブルの構成の一例を示す図FIG. 1 is a diagram showing an example of a configuration of an address table of an address calculation unit of a system program in a program execution device according to a first embodiment; 実施の形態1にかかるプログラム実行装置のシステムプログラムのチェックポイント情報保持レジスタの構成の一例を示す図FIG. 1 is a diagram illustrating an example of a configuration of a checkpoint information holding register of a system program of the program execution device according to the first embodiment; 実施の形態1にかかるプログラム実行装置のシステムプログラムのタスク修正部の動作の一例を示すフローチャート1 is a flowchart illustrating an example of an operation of a task correction unit of a system program of a program execution device according to a first embodiment. 実施の形態1にかかるプログラム実行装置のシステムプログラムのタスク切替部の動作の一例を示すフローチャート1 is a flowchart showing an example of an operation of a task switching unit of a system program of a program execution device according to a first embodiment; 実施の形態1にかかるプログラム実行装置の各構成要素の一連の動作の一例を示すシーケンス図FIG. 1 is a sequence diagram illustrating an example of a series of operations of each component of the program execution device according to the first embodiment. 実施の形態2にかかるプログラム実行装置のシステムプログラムの構成の一例を示すブロック図FIG. 10 is a block diagram showing an example of a configuration of a system program of a program execution device according to a second embodiment. 実施の形態2において、クリティカルセクションを含む第2演算タスクのC言語記述の一例を示す図FIG. 10 is a diagram showing an example of a C language description of a second operation task including a critical section in the second embodiment. 実施の形態2にかかるプログラム実行装置のシステムプログラムのタスク修正部の動作の一例を示すフローチャート10 is a flowchart showing an example of an operation of a task correction unit of a system program of a program execution device according to a second embodiment. 実施の形態2にかかるプログラム実行装置のシステムプログラムのタスク切替部の動作の一例を示すフローチャート10 is a flowchart showing an example of an operation of a task switching unit of a system program of a program execution device according to a second embodiment. 実施の形態3にかかるプログラム実行装置の演算プログラムの構成の一例を示すブロック図FIG. 10 is a block diagram showing an example of a configuration of an arithmetic program of a program execution device according to a third embodiment. 実施の形態3において、演算プログラムの実行時の動作の一例を示すタイムチャート10 is a time chart showing an example of an operation when a computing program is executed in the third embodiment. 実施の形態3において、クリティカルセクションを含む第h演算タスクのC言語記述の一例を示す図FIG. 10 is a diagram showing an example of a C language description of an h-th operation task including a critical section in the third embodiment. 実施の形態3において、クリティカルセクションを含む第i演算タスクのC言語記述の一例を示す図FIG. 10 is a diagram showing an example of a C language description of an i-th operation task including a critical section in the third embodiment. 実施の形態3にかかるプログラム実行装置のシステムプログラムのタスク修正部の動作の一例を示すフローチャート10 is a flowchart showing an example of an operation of a task correction unit of a system program of a program execution device according to a third embodiment. 実施の形態3にかかるプログラム実行装置のシステムプログラムのタスク切替部の動作の一例を示すフローチャート10 is a flowchart showing an example of an operation of a task switching unit of a system program of a program execution device according to a third embodiment. 実施の形態3にかかるプログラム実行装置の各構成要素の一連の動作の一例を示すシーケンス図FIG. 10 is a sequence diagram illustrating an example of a series of operations of each component of the program execution device according to the third embodiment. 実施の形態4において、クリティカルセクションを含む第h演算タスクのC言語記述の一例を示す図FIG. 13 is a diagram showing an example of a C language description of an h-th operation task including a critical section in the fourth embodiment. 実施の形態4において、クリティカルセクションを含む第i演算タスクのC言語記述の一例を示す図FIG. 13 is a diagram showing an example of a C language description of an i-th operation task including a critical section in the fourth embodiment. 実施の形態4にかかるプログラム実行装置のシステムプログラムのタスク修正部の動作の一例を示すフローチャート10 is a flowchart showing an example of an operation of a task correction unit of a system program of a program execution device according to a fourth embodiment. 実施の形態4にかかるプログラム実行装置のシステムプログラムのタスク切替部の動作の一例を示すフローチャート10 is a flowchart showing an example of an operation of a task switching unit of a system program of a program execution device according to a fourth embodiment.

 以下に、実施の形態にかかるプログラム実行装置およびプログラム実行方法を図面に基づいて詳細に説明する。 The program execution device and program execution method according to the embodiments are described in detail below with reference to the accompanying drawings.

 ユーザプログラムの実行状況に応じてOSが提供する排他制御機能の利用頻度を減らしたり、ユーザランドで排他制御処理を代替実行したりすることで、排他制御処理のオーバヘッドによる性能劣化を低減することができる。しかし、多数のクリティカルセクションを高密度に含む複数のスレッドまたはタスクを対象とし、単一プロセッサコア上で排他制御しながら実行する場合は、上述した技術を用いてもなお、実行性能、応答性能に関する問題が生じる可能性がある。 Performance degradation due to the overhead of exclusive control processing can be reduced by reducing the frequency of use of the exclusive control functions provided by the OS depending on the execution status of the user program, or by performing exclusive control processing in userland instead. However, when targeting multiple threads or tasks that contain a large number of critical sections at a high density and running them on a single processor core while maintaining exclusive control, even using the above-mentioned technologies may still result in problems with execution performance and response time.

 多数のクリティカルセクションを高密度に含む複数のスレッドまたはタスクの例として、PLC(Programmable Logic Controller)のような専用ハードウェアエンジンおよび共有メモリ等を具備したターゲットマシンを、産業用PC(Personal Computer)のようなホストマシンの単一プロセッサコア上でエミュレートする場合を考える。ちなみに、PLC、産業用PC等の組込み機器において、類似した機能あるいは相互依存のある機能をグルーピングし、同一のプロセッサコアに割り付ける設計はよくある。 As an example of multiple threads or tasks that contain a high density of critical sections, consider the case where a target machine equipped with a dedicated hardware engine and shared memory, such as a PLC (Programmable Logic Controller), is emulated on a single processor core of a host machine, such as an industrial PC (Personal Computer). Incidentally, in embedded devices such as PLCs and industrial PCs, it is common to group similar or interdependent functions and assign them to the same processor core.

 エミュレータは、複数の専用ハードウェアエンジンのモデルおよび共有メモリのモデルから構成されるとする。専用ハードウェアエンジンのモデルは、専用ハードウェアエンジンの命令動作を、ホストマシンのプロセッサの命令で模擬する。模擬対象の命令がロード命令またはストア命令であれば、共有メモリのモデルにアクセスすることになるため、基本的には専用ハードウェアエンジンの1命令分の処理は不可分な処理(クリティカルセクション)として排他制御する必要がある。 The emulator is said to consist of multiple dedicated hardware engine models and a shared memory model. The dedicated hardware engine models simulate the instruction operations of the dedicated hardware engines using instructions from the host machine's processor. If the instruction being simulated is a load or store instruction, it will access the shared memory model, so basically the processing of one instruction in the dedicated hardware engine must be exclusively controlled as an indivisible process (critical section).

 一般に、エミュレータの性能は、ターゲットマシンのスペック値と同等以上であることが求められる。例えば、ターゲットマシンのプロセッサの周波数が100MHzとすると、1命令分の実行に要する時間が10ns以下でなければならない。排他制御のために、ターゲットマシンの1命令を模擬するのにホストマシンの命令が数個でも追加されると、エミュレータ全体としては無視できないほどの性能劣化が生じることは容易に想像できる。 In general, emulator performance is required to be equal to or better than the specs of the target machine. For example, if the target machine's processor frequency is 100 MHz, the time required to execute one instruction must be 10 ns or less. It is easy to imagine that if even a few host machine instructions are added to simulate one target machine instruction for the sake of mutual exclusion, this will result in a significant degradation in the emulator's overall performance.

 また、クリティカルセクションを排他制御する際は、排他制御の副作用によって待機時間が意図せず長大にならないように考慮することも必要である。上述したPLCのエミュレータの場合、専用ハードウェアエンジンに相当するタスクはそれぞれ、周期的かつリアルタイムにサーボまたはモータといった機器への制御指令を算出し、送出できなければならない。例えば、割込みを契機に各専用ハードウェアエンジンモデルのタスクの実行を切り替えるのであれば、割込みに対する応答時間が短く、応答性能が良いことが重要である。 Furthermore, when using exclusive control for critical sections, it is also necessary to consider whether the side effect of exclusive control will unintentionally lengthen waiting times. In the case of the PLC emulator mentioned above, each task corresponding to a dedicated hardware engine must be able to periodically calculate and send control commands to devices such as servos or motors in real time. For example, if an interrupt is used to switch the execution of tasks for each dedicated hardware engine model, it is important that the response time to the interrupt is short and that response performance is good.

 また、多数のクリティカルセクションを高密度に含む複数のスレッドまたはタスクを単一コア上で排他制御する場合には、排他制御そのものの処理時間によるオーバヘッドが累積し、結果的に無視できないほど大きな性能劣化を招くという問題がある。加えて、排他制御の副作用によってスレッドまたはタスクの応答時間の伸長を引き起こすという問題がある。以下に説明する実施の形態にかかるプログラム実行装置では、これら双方の問題を解決する。 Furthermore, when multiple threads or tasks that contain a large number of densely packed critical sections are mutually exclusive on a single core, the overhead caused by the processing time of the mutual exclusive control itself accumulates, resulting in a significant degradation of performance that cannot be ignored. In addition, there is the problem that the side effect of the mutual exclusive control is that it causes an increase in the response time of the threads or tasks. The program execution device according to the embodiment described below solves both of these problems.

実施の形態1.
 以下、実施の形態1に関するプログラム実行装置およびプログラム実行方法について説明する。なお、実施の形態1では、実行周期とスケジューリング優先度とを持つ2つの演算タスクがOSによって優先度スケジューリングされる例を示して説明するが、実行周期を持たない、あるいは優先度スケジューリングされない演算タスクに対しても、実施の形態1を適用することができる。
Embodiment 1.
The following describes a program execution device and a program execution method according to embodiment 1. In embodiment 1, an example is described in which two computation tasks each having an execution period and a scheduling priority are prioritized by an OS, but embodiment 1 can also be applied to a computation task that does not have an execution period or is not prioritized.

 図1は、実施の形態1にかかるプログラム実行装置1000の構成の一例を示すブロック図である。実施の形態1におけるプログラム実行装置1000は、例えば組込み用途のコントローラにより構築可能であるが、これに限定されるものではない。 FIG. 1 is a block diagram showing an example of the configuration of a program execution device 1000 according to the first embodiment. The program execution device 1000 according to the first embodiment can be constructed, for example, by an embedded controller, but is not limited to this.

 プログラム実行装置1000は、マイクロプロセッサ1100と、主記憶装置1200と、記憶装置としての二次記憶装置1300とを備える。 The program execution device 1000 includes a microprocessor 1100, a main memory device 1200, and a secondary memory device 1300 as a memory device.

 マイクロプロセッサ1100は、1以上のプロセッサコア1100-1~1100-4を備え、各種プログラムを実行する。なお、図1では、4つのプロセッサコア1100-1~1100-4を搭載した構成を例示しているが、プロセッサコアの搭載個数はこれに限定されるものではない。主記憶装置1200は、プログラムおよびプログラムの実行に必要なデータを格納する。主記憶装置1200は、例えばキャッシュメモリ、RAM(Random Access Memory)である。二次記憶装置1300は、プログラムおよびプログラムの実行に必要なデータを格納し保持する。二次記憶装置1300は、例えばFlashメモリ、eMMC(embedded Multi-Media Card)である。二次記憶装置1300は、演算プログラム1310と、システムプログラム1320とを備える。演算プログラム1310は、第1演算タスク1311と、第2演算タスク1312とを備える。システムプログラム1320は、アドレス算出部1321と、チェックポイント情報保持レジスタ1322と、タスク修正部1323と、タスク切替部1324とを備える。 The microprocessor 1100 has one or more processor cores 1100-1 to 1100-4 and executes various programs. While Figure 1 illustrates a configuration with four processor cores 1100-1 to 1100-4, the number of processor cores is not limited to this. The main memory 1200 stores programs and data required for program execution. The main memory 1200 is, for example, cache memory or RAM (Random Access Memory). The secondary memory 1300 stores and retains programs and data required for program execution. The secondary memory 1300 is, for example, Flash memory or eMMC (embedded Multi-Media Card). The secondary memory 1300 has an operation program 1310 and a system program 1320. The operation program 1310 has a first operation task 1311 and a second operation task 1312. The system program 1320 includes an address calculation unit 1321, a checkpoint information holding register 1322, a task correction unit 1323, and a task switching unit 1324.

 タスク修正部1323は、実行中の第2演算タスク1312に対して、アドレス算出部1321を用いて次に実行されるチェックポイントを特定し修正を行う。その際、修正を行ったチェックポイントのアドレスと、そのアドレスが指す位置にあった命令との対をチェックポイント情報保持レジスタ1322に格納する。チェックポイントは、後述するが、クリティカルセクションを特定するための単なる目印であり、プロセッサコア1100-1~1100-4によって何の処理も実行されない。タスク切替部1324は、タスク修正部1323によって修正された第2演算タスク1312中のチェックポイントに対して原状回復を行い、第1演算タスク1311と第2演算タスク1312と間でタスクの実行を切り替える。 The task correction unit 1323 uses the address calculation unit 1321 to identify and correct the checkpoint to be executed next for the currently running second calculation task 1312. At that time, a pair of the address of the corrected checkpoint and the instruction at the location pointed to by that address is stored in the checkpoint information holding register 1322. As will be described later, checkpoints are simply marks for identifying critical sections, and no processing is performed by the processor cores 1100-1 to 1100-4. The task switching unit 1324 restores the checkpoint in the second calculation task 1312 corrected by the task correction unit 1323, and switches task execution between the first calculation task 1311 and the second calculation task 1312.

 図2は、実施の形態1において、演算プログラム1310の実行時の動作の一例を示すタイムチャートである。第1演算タスク1311および第2演算タスク1312は、OSによって実行される処理の最小単位であるスレッドもしくはタスクである。また、第1演算タスク1311および第2演算タスク1312は、互いにアドレス空間を共有しており、それぞれ固有の独立したアドレス空間は持たない。加えて、第1演算タスク1311および第2演算タスク1312は、割込み処理または例外処理ではないとする。以降では、第1演算タスク1311および第2演算タスク1312がタスクである場合を例にして説明する。 Figure 2 is a time chart showing an example of the operation of the calculation program 1310 during execution in embodiment 1. The first calculation task 1311 and the second calculation task 1312 are threads or tasks, which are the smallest units of processing executed by the OS. Furthermore, the first calculation task 1311 and the second calculation task 1312 share an address space with each other and do not have their own independent address spaces. In addition, the first calculation task 1311 and the second calculation task 1312 are not interrupt processing or exception processing. The following explanation takes as an example a case where the first calculation task 1311 and the second calculation task 1312 are tasks.

 第1演算タスク1311は、第1実行周期2110を持ち、第1スケジューリング優先度2120を持つ。第2演算タスク1312は、第2実行周期2210を持ち、第1スケジューリング優先度2120より低い第2スケジューリング優先度2220を持つ。第1演算タスク1311および第2演算タスク1312は、OSのスケジューラによってそれぞれのスケジューリング優先度に基づき、マイクロプロセッサ1100に具備される単一のプロセッサコア1100-nに割り付けられ実行されるものとする。 The first calculation task 1311 has a first execution period 2110 and a first scheduling priority 2120. The second calculation task 1312 has a second execution period 2210 and a second scheduling priority 2220 that is lower than the first scheduling priority 2120. The first calculation task 1311 and the second calculation task 1312 are allocated to and executed by a single processor core 1100-n provided in the microprocessor 1100 based on their respective scheduling priorities by the OS scheduler.

 第2演算タスク1312が実行中のときに、第1演算タスク1311の第1実行周期2110の開始時点でタイマ割込み等が入る。すると、第2演算タスク1312の実行が中断され、第1スケジューリング優先度2120の方が第2スケジューリング優先度2220より高いため、OSによって第1演算タスク1311が実行開始される。第1演算タスク1311の実行が終了すると、第2演算タスク1312が割り込まれた地点から実行が再開される。 While the second calculation task 1312 is running, a timer interrupt or the like occurs at the start of the first execution cycle 2110 of the first calculation task 1311. This causes the execution of the second calculation task 1312 to be suspended, and because the first scheduling priority 2120 is higher than the second scheduling priority 2220, the OS starts execution of the first calculation task 1311. When execution of the first calculation task 1311 ends, execution of the second calculation task 1312 resumes from the point where it was interrupted.

 図3は、実施の形態1において、クリティカルセクション3400-nを含む第2演算タスク1312のC言語記述の一例を示す図である。nは、1,2,3,・・・である。図3では、第2演算タスク1312が実行中であるか否かを示すrunning変数3100が定義される。running変数3100の値が「true」であれば実行中であることを示し、「false」であれば実行中でないことを示す。また、第2演算タスク1312によって実行されるルーチンとしてtask2()関数3200が定義されており、第2演算タスク1312の生成時にこのルーチンのエントリポイントが第2演算タスク1312に紐づけられることが想定される。図3では、task2()関数3200の実装として、while文にて多数のクリティカルセクションを高密度に含むコードブロックを反復処理する例を示す。while文のブロックの先頭にてwaitUntilDispatched()関数を用い、OSから実行権を与えられて実行中の状態になるまで待機する。なお、waitUntilDispatched()関数は図3の例を分かりやすく示すために記述したものであって、実際にはOSが提供するセマフォ等を獲得する関数を用いてもよい。待機が解除されると、running変数3100に「true」を設定し、while文のブロックの末尾でrunning変数3100に「false」を設定する。 Figure 3 shows an example of a C language description of the second calculation task 1312 including a critical section 3400-n in embodiment 1. n is 1, 2, 3, etc. In Figure 3, a running variable 3100 is defined, indicating whether the second calculation task 1312 is running. A value of "true" for the running variable 3100 indicates that the task is running, and a value of "false" indicates that the task is not running. A task2() function 3200 is also defined as a routine executed by the second calculation task 1312, and it is assumed that the entry point of this routine is linked to the second calculation task 1312 when the second calculation task 1312 is created. Figure 3 shows an example of an implementation of the task2() function 3200, in which a code block containing a large number of densely packed critical sections is repeatedly processed using a while statement. The waitUntilDispatched() function is used at the beginning of the while statement block to wait until the OS grants execution permission and the task enters the running state. Note that the waitUntilDispatched() function is written to make the example in Figure 3 easier to understand, and in practice a function that acquires a semaphore or similar provided by the OS may be used. When the wait is released, the running variable 3100 is set to "true", and at the end of the while block, the running variable 3100 is set to "false".

 各クリティカルセクション3400-nの先頭には、チェックポイント3300-nとしてラベルが記述される。実施の形態1において、チェックポイント3300-nは、クリティカルセクション3400-nを特定するための単なる目印、ラベルであり、プロセッサコア1100-1~1100-4によって何の処理も実行されない。ただし、各クリティカルセクション3400-nは、その先頭にタスク修正部1323によって修正されるチェックポイント3300-nを含むため、コンパイル時に連続する2つのクリティカルセクション3400-n、3400-(n+1)がまとめて最適化され、両者の境界が取り除かれることがないように留意しなければならない。よって、例えば図3に示すように、チェックポイント3300-n相当のラベルは、volatile修飾子付きのインラインアセンブラを用いて記述するのが適している。 At the beginning of each critical section 3400-n, a label is written as a checkpoint 3300-n. In embodiment 1, checkpoint 3300-n is simply a marker or label for identifying critical section 3400-n, and no processing is performed by processor cores 1100-1 to 1100-4. However, because each critical section 3400-n includes a checkpoint 3300-n at its beginning that is modified by task modification unit 1323, care must be taken to ensure that the two consecutive critical sections 3400-n and 3400-(n+1) are not optimized together during compilation, resulting in the boundary between them being removed. Therefore, for example, as shown in Figure 3, it is appropriate to write labels equivalent to checkpoint 3300-n using inline assembler with a volatile modifier.

 また、第2演算タスク1312にチェックポイント3300-nを挿入する位置は、必ずしも各クリティカルセクション3400-nの前後でなくてもよい。例えば、クリティカルセクションの2つおきにチェックポイントを挿入してもよいし、4つおきに挿入してもよい。チェックポイント3300-nを挿入する間隔が広いほど実行性能の劣化度合いは小さくなるが応答時間は大きくなり(応答性が悪くなる)、間隔が狭いほど実行性能の劣化度合いは大きくなるが応答時間は小さくなる(応答性が良くなる)トレードオフがある。したがって、チェックポイント3300-nの挿入間隔をパラメータとして、実行性能の劣化度合いと応答時間の推測値または実測値とにもとづいて、チェックポイント3300-nの挿入間隔を調整してもよい。 Furthermore, the position at which checkpoints 3300-n are inserted into the second operation task 1312 does not necessarily have to be before or after each critical section 3400-n. For example, checkpoints may be inserted after every third or every fourth critical section. There is a trade-off: the wider the interval at which checkpoints 3300-n are inserted, the less the degree of degradation in execution performance will be, but the longer the response time will be (poor responsiveness); and the narrower the interval, the greater the degree of degradation in execution performance will be, but the shorter the response time will be (better responsiveness). Therefore, the interval at which checkpoints 3300-n are inserted may be used as a parameter, and the interval at which checkpoints 3300-n are inserted may be adjusted based on the degree of degradation in execution performance and the estimated or measured values of response time.

 図4は、実施の形態1において、クリティカルセクションを含む第2演算タスク1312のアセンブリ記述の一例を示す図である。図4は、図3に示した第2演算タスク1312のC言語記述をコンパイルした結果、生成されるアセンブリ記述を簡略化して示したものである。図4中のチェックポイント4100-nは、それぞれ図3中のチェックポイント3300-nに対応する。 FIG. 4 is a diagram showing an example of assembly code for the second operation task 1312, which includes a critical section, in embodiment 1. FIG. 4 shows a simplified version of the assembly code generated as a result of compiling the C language code for the second operation task 1312 shown in FIG. 3. Checkpoints 4100-n in FIG. 4 correspond to checkpoints 3300-n in FIG. 3.

 図5は、実施の形態1にかかるプログラム実行装置1000のシステムプログラム1320のアドレス算出部1321の構成の一例を示す図である。アドレス算出部1321は、プログラムカウンタ値を入力として受け付け、そのプログラムカウンタ値から第2演算タスク1312中の次に実行されるチェックポイント3300-nのアドレスを算出する。アドレス算出部1321は、アドレステーブル5100を具備する。 FIG. 5 is a diagram showing an example of the configuration of the address calculation unit 1321 of the system program 1320 of the program execution device 1000 according to the first embodiment. The address calculation unit 1321 receives a program counter value as input, and calculates the address of the checkpoint 3300-n to be executed next in the second calculation task 1312 from the program counter value. The address calculation unit 1321 includes an address table 5100.

 図6は、実施の形態1にかかるプログラム実行装置1000のシステムプログラム1320のアドレス算出部1321のアドレステーブル5100の構成の一例を示す図である。アドレステーブル5100は、第2演算タスク1312に挿入されたチェックポイント3300-nが配置される主記憶装置1200上のアドレスの配列である。エントリ6100-nはそれぞれ、図3におけるチェックポイント3300-n、および図4におけるチェックポイント4100-nのアドレスが格納されている様子を表している(図3と図4とのチェックポイントのアドレスは同一である)。第2演算タスク1312のチェックポイント3300-nのアドレスの取得方法としては、例えばチェックポイント3300-n相当のラベルに対応する変数を第2演算タスク1312内にextern宣言しておき、実行時に各変数を参照することによって各チェックポイント3300-nのアドレスを取得することができる。取得したアドレスを各エントリ6100-nに装填するまでの一連の操作は、第2演算タスク1312が主記憶装置1200にロードされた後に1回行えばよく、第2演算タスク1312の初期化処理で行ってもよい。 Figure 6 is a diagram showing an example of the configuration of the address table 5100 of the address calculation unit 1321 of the system program 1320 of the program execution device 1000 according to the first embodiment. The address table 5100 is an array of addresses on the main memory device 1200 where the checkpoint 3300-n inserted in the second operation task 1312 is located. Entry 6100-n represents the storage of the addresses of checkpoint 3300-n in Figure 3 and checkpoint 4100-n in Figure 4 (the addresses of the checkpoints in Figures 3 and 4 are the same). One method for obtaining the address of checkpoint 3300-n in the second operation task 1312 is, for example, to declare a variable corresponding to the label equivalent to checkpoint 3300-n as extern in the second operation task 1312, and then obtain the address of each checkpoint 3300-n by referencing each variable during execution. The series of operations up to loading the acquired addresses into each entry 6100-n only needs to be performed once after the second calculation task 1312 is loaded into the main memory 1200, and may be performed during the initialization process of the second calculation task 1312.

 図7は、実施の形態1にかかるプログラム実行装置1000のシステムプログラム1320のチェックポイント情報保持レジスタ1322の構成の一例を示す図である。チェックポイント情報保持レジスタ1322は、チェックポイントのアドレスを保持するためのアドレスフィールド7100と、チェックポイントのアドレスが指す位置にある命令を保持するための命令フィールド7200とを備える。 FIG. 7 is a diagram showing an example of the configuration of the checkpoint information holding register 1322 of the system program 1320 of the program execution device 1000 according to the first embodiment. The checkpoint information holding register 1322 includes an address field 7100 for holding the address of a checkpoint, and an instruction field 7200 for holding the instruction at the location indicated by the checkpoint address.

 図8は、実施の形態1にかかるプログラム実行装置1000のシステムプログラム1320のタスク修正部1323の動作の一例を示すフローチャートである。タスク修正部1323は、実行権移譲要求が発生したときに呼び出され、第2演算タスク1312中のチェックポイント3300-nに対して必要に応じ修正を行う。ここで、実行権移譲要求には、例えば割込みまたはセマフォを利用し、演算プログラム1310が割り付けられたプロセッサコア1100-nとは別のプロセッサコア1100-mに割り付けられたタスクから、第2演算タスク1312に対して通知を行うことができる。割込みを利用する場合は、タスク修正部1323を割込みハンドラとして実装してもよい。セマフォを利用する場合は、タスク修正部1323をタスクとして実装してもよい。 FIG. 8 is a flowchart showing an example of the operation of the task correction unit 1323 of the system program 1320 of the program execution device 1000 according to the first embodiment. The task correction unit 1323 is called when a request for transfer of execution rights occurs, and corrects the checkpoint 3300-n in the second calculation task 1312 as necessary. Here, the execution right transfer request can be made using, for example, an interrupt or a semaphore, and a notification can be sent to the second calculation task 1312 from a task assigned to a processor core 1100-m other than the processor core 1100-n to which the calculation program 1310 is assigned. When an interrupt is used, the task correction unit 1323 may be implemented as an interrupt handler. When a semaphore is used, the task correction unit 1323 may be implemented as a task.

 ステップS8101では、第2演算タスク1312中のrunning変数3100の値が「true」であるか「false」であるかを参照し、第2演算タスクが実行中であるか否かを判断する。実行中であればステップS8102が次に処理され、実行中でなければステップS8201が次に処理される。 In step S8101, the value of the running variable 3100 in the second calculation task 1312 is checked to see if it is "true" or "false," and it is determined whether the second calculation task is currently running. If it is currently running, step S8102 is processed next; if it is not currently running, step S8201 is processed next.

 ステップS8102では、実行権移譲要求によりタスク修正部1323が起動されたことにより第2演算タスク1312の実行が中断された時点のプログラムカウンタ(PC:Program Counter)値(リターンアドレス)を取得する。タスク修正部1323が割込みハンドラとして実装される場合は、例えばマイクロプロセッサ1100のアーキテクチャがArmv8ならば、割込み発生時にPC値がリンクレジスタに退避されるため、割込みハンドラからリンクレジスタにアクセスすることでPC値を取得する。タスク修正部1323がタスクとして実装される場合は、通常、OSはタスクの実行を切り替える際にレジスタの状態等(コンテキスト)が主記憶装置1200上の退避領域に退避されるため、その退避領域にアクセスすることでPC値を取得する。 In step S8102, the program counter (PC) value (return address) at the time when execution of the second calculation task 1312 was interrupted due to the task correction unit 1323 being activated in response to a request to transfer execution rights is obtained. If the task correction unit 1323 is implemented as an interrupt handler, for example, if the architecture of the microprocessor 1100 is Armv8, the PC value is saved to a link register when an interrupt occurs, and the PC value is obtained by accessing the link register from the interrupt handler. If the task correction unit 1323 is implemented as a task, the register state, etc. (context) is usually saved to a save area on the main memory device 1200 when the OS switches task execution, and the PC value is obtained by accessing that save area.

 ステップS8103では、ステップS8102で取得したPC値をアドレス算出部1321に渡し、第2演算タスク1312中の次に実行されるチェックポイント3300-nのアドレスを取得する。 In step S8103, the PC value obtained in step S8102 is passed to the address calculation unit 1321, and the address of the next checkpoint 3300-n to be executed in the second calculation task 1312 is obtained.

 ステップS8104では、ステップS8103で取得した次のチェックポイント3300-nのアドレスとチェックポイント3300-nのアドレスが指す位置に配置された命令との対である次のチェックポイント情報を、チェックポイント情報保持レジスタ1322に格納する。それぞれ、アドレスフィールド7100、命令フィールド7200に格納される。 In step S8104, the next checkpoint information, which is a pair of the address of the next checkpoint 3300-n obtained in step S8103 and the instruction located at the location pointed to by the address of checkpoint 3300-n, is stored in the checkpoint information holding register 1322. These are stored in the address field 7100 and instruction field 7200, respectively.

 ステップS8105では、ステップS8103で取得した次のチェックポイント3300-nのアドレスが指す位置を、タスク切替部1324のエントリポイントを呼び出す命令に書き換える。これは、主記憶装置1200上にロードされた実行形式のテキスト領域の命令を書き換えることにほかならず、例えば実行形式がELF(Executable and Linkage Format)であれば、命令が格納されたtextセクションを含むロード用セグメント(テキスト領域と呼ぶ)を書き換えることになる。そのため、演算プログラム1310は、コンパイル時にテキスト領域に書き込み可能属性を付与する必要がある。ステップS8106では、タスク修正部1323の実行が終了し、第2演算タスク1312の実行が再開される。 In step S8105, the location pointed to by the address of the next checkpoint 3300-n obtained in step S8103 is rewritten to an instruction that calls the entry point of the task switching unit 1324. This is nothing more than rewriting the instruction in the executable text area loaded onto the main memory device 1200. For example, if the executable format is ELF (Executable and Linkage Format), this rewrites the load segment (called the text area) that contains the text section in which the instruction is stored. For this reason, the calculation program 1310 must assign a writable attribute to the text area when it is compiled. In step S8106, execution of the task correction unit 1323 ends, and execution of the second calculation task 1312 resumes.

 ステップS8201では、ステップS8101で第2演算タスク1312が実行中でないと判断されたため、タスク修正部1323からタスク切替部1324を直接呼び出し、第1演算タスク1311を起動する。 In step S8201, since it was determined in step S8101 that the second calculation task 1312 was not currently being executed, the task correction unit 1323 directly calls the task switching unit 1324 and starts the first calculation task 1311.

 図9は、実施の形態1にかかるプログラム実行装置1000のシステムプログラム1320のタスク切替部1324の動作の一例を示すフローチャートである。タスク切替部1324は、タスク修正部1323によって修正された第2演算タスク1312中のチェックポイントに対して原状回復を行い、OSの機能を利用してスケジューリング優先度の低いタスクから高いタスクに実行権を移す。タスク切替部1324は、例えば関数として実装してもよい。 FIG. 9 is a flowchart showing an example of the operation of the task switching unit 1324 of the system program 1320 of the program execution device 1000 according to the first embodiment. The task switching unit 1324 restores the checkpoint in the second calculation task 1312 corrected by the task correction unit 1323, and uses the functions of the OS to transfer execution rights from a task with a low scheduling priority to a task with a high scheduling priority. The task switching unit 1324 may be implemented as a function, for example.

 ステップS9101では、第2演算タスク1312が実行中であるか否かを判断する。例えば、第2演算タスク1312中のrunning変数3100の値が「true」であるか「false」であるかを参照して判断してもよい。第2演算タスク1312が実行中であればステップS9102が次に処理され、第2演算タスク1312が実行中でなければステップS9104が次に処理される。 In step S9101, it is determined whether the second calculation task 1312 is running. For example, this determination may be made by referring to whether the value of the running variable 3100 in the second calculation task 1312 is "true" or "false." If the second calculation task 1312 is running, step S9102 is processed next; if the second calculation task 1312 is not running, step S9104 is processed next.

 ステップS9102では、チェックポイント情報保持レジスタ1322から、タスク修正部1323によって修正されたチェックポイント3300-nのアドレスとチェックポイント3300-nのアドレスが指す位置に配置されていた命令との対を取得する。 In step S9102, the address of checkpoint 3300-n corrected by the task correction unit 1323 and the pair of instructions located at the location indicated by the address of checkpoint 3300-n are obtained from the checkpoint information holding register 1322.

 ステップS9103では、ステップS9102で取得したアドレスが指す位置を、ステップS9102で取得した命令に書き換える。 In step S9103, the location pointed to by the address obtained in step S9102 is rewritten to the command obtained in step S9102.

 ステップS9104では、より低い第2スケジューリング優先度2220を持つ第2演算タスク1312から、より高い第1スケジューリング優先度2120を持つ第1演算タスク1311に対して実行権を移譲する。実行権の移譲には、例えばバイナリセマフォを使用する方法がある。単一のプロセッサコア1100-nに割り付けられた第1演算タスク1311および第2演算タスク1312において、第2演算タスク1312はバイナリセマフォを獲得すること(P操作)によって実行が開始される。第2演算タスク1312の実行中に、上述したタスク修正部1323のステップS8101~S8106を経て、第2演算タスク1312中のチェックポイントからタスク切替部1324が呼び出されたとき、およびステップS8101~S8201を経て、タスク修正部1323からタスク切替部1324が呼び出されたときに、タスク切替部1324がバイナリセマフォを解放する(V操作)。これにより、OSによって当該プロセッサコア1100-n上の実行中あるいは実行可能な演算タスクのうち、第1演算タスク1311のスケジューリング優先度が最高と判断され、第2演算タスク1312から第1演算タスク1311に実行が切り替えられる。 In step S9104, the second operation task 1312, which has a lower second scheduling priority 2220, transfers execution rights to the first operation task 1311, which has a higher first scheduling priority 2120. The transfer of execution rights can be achieved, for example, by using a binary semaphore. In the first operation task 1311 and second operation task 1312 assigned to a single processor core 1100-n, the second operation task 1312 begins execution by acquiring a binary semaphore (P operation). During execution of the second operation task 1312, when the task switcher 1324 is called from a checkpoint in the second operation task 1312 via steps S8101 to S8106 of the task corrector 1323 described above, or when the task switcher 1324 is called from the task corrector 1323 via steps S8101 to S8201, the task switcher 1324 releases the binary semaphore (V operation). As a result, the OS determines that the first calculation task 1311 has the highest scheduling priority among the calculation tasks currently being executed or executable on the processor core 1100-n, and execution is switched from the second calculation task 1312 to the first calculation task 1311.

 ステップS9105では、第1演算タスク1311の実行が完了するまで待機する。 In step S9105, the process waits until execution of the first calculation task 1311 is complete.

 ステップS9106では、ステップS9102で取得したアドレスにリターンし、第2演算タスク1312の実行を再開する。タスク切替部1324を関数として実装することを想定すると、通常、関数呼び出しの際は関数のエントリポイントへのジャンプ命令の次の命令のアドレスがリターンアドレスとして専用レジスタに保持され、関数から呼び出し元にリターンするときに利用される。実施の形態1では、第2演算タスク1312における各クリティカルセクション3400-nの先頭の1番目の命令の位置をチェックポイント3300-nとしている。実行権移譲要求があったときに、実行中であったクリティカルセクション3400-nの次のチェックポイント3300-(n+1)が、タスク修正部1323によってタスク切替部1324を呼び出す命令に書き換えられる。チェックポイント3300-(n+1)からタスク切替部1324が呼び出され、タスク切替部1324から第2演算タスク1312にリターンする際は、専用レジスタに保持されたリターンアドレスにリターンすると、当該クリティカルセクション3400-nの先頭から2番目の命令の位置に戻ってきて、先頭の1番目の命令は実行されないことになる。これを回避するために、タスク切替部1324から第2演算タスク1312にリターンする際は、チェックポイント情報保持レジスタ1322から取得したアドレスにリターンする必要がある。 In step S9106, the process returns to the address obtained in step S9102, and execution of the second operation task 1312 resumes. Assuming that the task switching unit 1324 is implemented as a function, when a function is called, the address of the instruction following the jump instruction to the function's entry point is usually held in a dedicated register as the return address, and is used when returning from the function to the caller. In embodiment 1, the position of the first instruction at the beginning of each critical section 3400-n in the second operation task 1312 is set as checkpoint 3300-n. When a request for transfer of execution rights is made, the task modification unit 1323 rewrites the next checkpoint 3300-(n+1) of the critical section 3400-n that was being executed to an instruction that calls the task switching unit 1324. If the task switcher 1324 is called from checkpoint 3300-(n+1), and the task switcher 1324 returns to the second operation task 1312 by returning to the return address stored in the dedicated register, the task will return to the position of the second instruction from the beginning of the critical section 3400-n, and the first instruction from the beginning will not be executed. To avoid this, when returning from the task switcher 1324 to the second operation task 1312, it is necessary to return to the address obtained from the checkpoint information holding register 1322.

 図10は、実施の形態1にかかるプログラム実行装置1000の各構成要素の一連の動作の一例を示すシーケンス図である。図10では、第2演算タスク1312中のクリティカルセクション3400-2の実行中に、実行権移譲要求が発生したときの、第1演算タスク1311と、第2演算タスク1312と、タスク修正部1323と、タスク切替部1324とが相互作用して動作する様子を示している。 FIG. 10 is a sequence diagram showing an example of a series of operations of the components of the program execution device 1000 according to the first embodiment. FIG. 10 shows how the first calculation task 1311, the second calculation task 1312, the task correction unit 1323, and the task switching unit 1324 interact with each other when a request for transfer of execution rights occurs during execution of the critical section 3400-2 in the second calculation task 1312.

 まず、第2演算タスク1312中のクリティカルセクション3400-2の実行中に実行権移譲要求が発生すると、タスク修正部1323が起動し、次のクリティカルセクション3400-3の先頭に位置するチェックポイント3300-3からタスク切替部1324を呼び出すように修正する。タスク修正部1323の実行が終了し、第2演算タスク1312中の実行中であったクリティカルセクション3400-2の未実行部分が実行される。次のクリティカルセクション3400-3の先頭のチェックポイント3300-3に実行が到達し、タスク切替部1324が呼び出される。タスク切替部1324は、チェックポイント3300-3からタスク切替部1324を呼び出さないように修正し、第2演算タスク1312から第1演算タスク1311に実行権を移し、第1演算タスク1311が実行される。 First, when a request to transfer execution rights occurs during execution of critical section 3400-2 in the second operation task 1312, the task correction unit 1323 is activated and corrects the task so that the task switch unit 1324 is called from checkpoint 3300-3 located at the beginning of the next critical section 3400-3. Execution of the task correction unit 1323 ends, and the unexecuted part of critical section 3400-2 that was being executed in the second operation task 1312 is executed. Execution reaches checkpoint 3300-3 located at the beginning of the next critical section 3400-3, and the task switch unit 1324 is called. The task switch unit 1324 corrects the task so that it is not called from checkpoint 3300-3, and transfers execution rights from the second operation task 1312 to the first operation task 1311, and the first operation task 1311 is executed.

 第1演算タスク1311の実行が終了すると、タスク切替部1324に実行権が戻り、第2演算タスク1312にリターンされ、第2演算タスク1312の実行がクリティカルセクション3400-3の先頭から再開される。 When execution of the first calculation task 1311 is completed, execution rights are returned to the task switching unit 1324 and returned to the second calculation task 1312, and execution of the second calculation task 1312 is resumed from the beginning of the critical section 3400-3.

<実施の形態1の効果>
 実施の形態1では、多数のクリティカルセクションを高密度に含む2つのスレッドもしくはタスクを単一のプロセッサコア1100-n上で実行する場合に、実行権移譲要求の発生時に、タスク修正部1323によって実行中のタスク中のチェックポイントからタスク切替部1324を呼び出すように修正し、修正されたチェックポイントを起点として別タスクに実行切り替えすることで排他制御を実現する。実行権移譲要求が発生していないときは、タスク修正部1323は実行中のタスクに対して何も修正を加えず、元のタスクはプロセッサコア1100-nによって何も処理されないチェックポイント(ラベル)が挿入されているだけなので、実行時の性能劣化は原理上ゼロである。また、必ずチェックポイントを起点としてタスクの実行切り替えを行うため、ユーザが意図しない応答時間の伸長を防止する効果がある。
<Effects of First Embodiment>
In the first embodiment, when two threads or tasks containing a large number of densely packed critical sections are executed on a single processor core 1100-n, when a request for transfer of execution rights occurs, the task modification unit 1323 modifies the currently executing task to call the task switching unit 1324 from a checkpoint in the currently executing task, and exclusive control is achieved by switching execution to another task starting from the modified checkpoint. When a request for transfer of execution rights does not occur, the task modification unit 1323 does not modify the currently executing task, and the original task simply has a checkpoint (label) inserted that is not processed by the processor core 1100-n, so performance degradation during execution is, in principle, zero. Furthermore, because task execution switching is always performed starting from a checkpoint, there is an effect of preventing an unintended extension of response time.

実施の形態2.
 以下、実施の形態2に関するプログラム実行装置およびプログラム実行方法について説明する。なお、以下の説明においては、実施の形態1で説明された構成要素と同様の構成要素については同じ符号を付して図示し、その詳細な説明を適宜省略するものとする。また、実施の形態2では、実行周期とスケジューリング優先度とを持つ2つの演算タスクがOSによって優先度スケジューリングされる例を示して説明するが、実行周期を持たない、あるいは優先度スケジューリングされない演算タスクに対しても、実施の形態2を適用することができる。
Embodiment 2.
A program execution device and a program execution method according to the second embodiment will be described below. In the following description, components similar to those described in the first embodiment will be denoted by the same reference numerals, and detailed description thereof will be omitted as appropriate. In the second embodiment, an example will be described in which two computation tasks each having an execution period and a scheduling priority are prioritized by the OS, but the second embodiment can also be applied to a computation task that does not have an execution period or is not prioritized.

 実施の形態1では、実行権移譲要求の発生時に、タスク修正部1323が実行中のタスク中のチェックポイントを書き換えている。つまり、主記憶装置1200上にロードされた実行形式のテキスト領域が書き換えられる操作が行われる。一般に、テキスト領域はコンパイラによって読み出し可能属性と実行可能属性とが設定され、テキスト領域の実行時はテキスト領域に対して書き換えることが不可能である。本来読み出して実行する目的のテキスト領域が実行時に書き換えられると、悪意のあるコードブロックが挿入されて実行できてしまうため、セキュリティの観点から抑制されている。そのため、実施の形態2では、実行時にテキスト領域を書き換える操作を必要としないプログラム実行装置およびプログラム実行方法について説明する。 In the first embodiment, when a request to transfer execution rights occurs, the task correction unit 1323 rewrites the checkpoint in the task being executed. In other words, an operation is performed to rewrite the executable text area loaded on the main memory device 1200. Generally, a text area is set with readable and executable attributes by a compiler, and rewriting to the text area is not possible when the text area is being executed. If a text area that is intended to be read and executed were to be rewritten during execution, a malicious code block could be inserted and executed, so this is suppressed from a security perspective. Therefore, in the second embodiment, a program execution device and program execution method are described that do not require the operation of rewriting the text area during execution.

 図11は、実施の形態2にかかるプログラム実行装置1000のシステムプログラム11000の構成の一例を示すブロック図である。システムプログラム11000は、タスク修正部11100と、タスク切替部11200とを備える。 FIG. 11 is a block diagram showing an example of the configuration of a system program 11000 of a program execution device 1000 according to the second embodiment. The system program 11000 includes a task correction unit 11100 and a task switching unit 11200.

 図12は、実施の形態2において、クリティカルセクション12400-nを含む第2演算タスク1312のC言語記述の一例を示す図である。図12では、チェックポイントとして関数ポインタ12200が定義され、「0」で初期化される。関数ポインタ12200については、タスク修正部11100の動作フローの説明にて詳述するが、これが実施の形態1と異なる点である。関数ポインタ12200は、タスク修正部11100によってタスク切替部11200のエントリポイントのアドレスが代入される。図12では、task2()関数12300の実装として、while文にて多数のクリティカルセクション12400-nを高密度に含むコードブロックを反復処理する例を示す。while文のブロックの先頭にてwaitUntilDispatched()関数を用い、OSから実行権を与えられて実行中の状態になるまで待機する。待機が解除されると、running変数12100に「true」を設定し、while文のブロックの末尾でrunning変数12100に「false」を設定する。 Figure 12 is a diagram showing an example of a C language description of the second calculation task 1312 including a critical section 12400-n in embodiment 2. In Figure 12, a function pointer 12200 is defined as a checkpoint and initialized to "0." The function pointer 12200 will be described in detail in the explanation of the operation flow of the task correction unit 11100, but this is a difference from embodiment 1. The task correction unit 11100 assigns the address of the entry point of the task switching unit 11200 to the function pointer 12200. Figure 12 shows an example of an implementation of the task2() function 12300 in which a code block containing a large number of critical sections 12400-n densely is repeatedly processed using a while statement. The waitUntilDispatched() function is used at the beginning of the while statement block to wait until execution permission is granted by the OS and the task enters the running state. When the wait is released, the running variable 12100 is set to "true", and at the end of the while block, the running variable 12100 is set to "false".

 各クリティカルセクション12400-nの先頭には、チェックポイント12200-1~12200-3として、関数ポインタの値が「0」でないことをチェックし、関数ポインタを参照してタスク切替部11200を呼び出すためのコードが記述される。このように、実施の形態2において、チェックポイント12200-1~12200-3は、関数ポインタを参照してタスク切替部11200を呼び出すためのコードであり、実行時はチェックポイントで関数ポインタの値に応じて条件分岐する分のオーバヘッドが発生する。この関数ポインタの値のチェックおよび関数ポインタによる関数呼び出しを行うコードによれば、第2演算タスク1312に余計なコードを一切含めない実施の形態1と比べると、条件分岐を処理する分のオーバヘッドが生じる。なお、図3のチェックポイント3300-nに相当するラベルは実行時に処理されるものではない。そこで、オーバヘッドを低減するために、例えば条件分岐が成立と不成立とのどちらとなる確率が高いかというヒント情報をコンパイラに与えてもよい。例えば、コンパイラにGCC(GNU Compiler Collection)を用い、かつチェックポイント12200-nのif文の条件分岐が不成立となる確率が高いならば、GCCが提供する組込み関数を用いて、チェックポイント12200-nは「if(__builtin_expect(!!(checkpoint)、0))checkpoint();」のように記述することができる。 At the beginning of each critical section 12400-n, code is written as checkpoints 12200-1 to 12200-3 to check that the value of the function pointer is not "0" and to call the task switcher 11200 by referencing the function pointer. Thus, in embodiment 2, checkpoints 12200-1 to 12200-3 are code for referencing the function pointer and calling the task switcher 11200. During execution, overhead is generated for conditional branching depending on the value of the function pointer at the checkpoint. This code for checking the value of the function pointer and calling the function using the function pointer results in overhead for processing the conditional branching compared to embodiment 1, in which the second calculation task 1312 does not contain any unnecessary code. Note that the label corresponding to checkpoint 3300-n in Figure 3 is not processed during execution. Therefore, in order to reduce overhead, hint information may be provided to the compiler, indicating whether the conditional branch is more likely to be taken or not taken, for example. For example, if the compiler used is GCC (GNU Compiler Collection) and there is a high probability that the conditional branch of the if statement at checkpoint 12200-n will not be satisfied, checkpoint 12200-n can be written as "if(__builtin_expect(!!(checkpoint)、0))checkpoint();" using the built-in functions provided by GCC.

 図13は、実施の形態2にかかるプログラム実行装置1000のシステムプログラム11000のタスク修正部11100の動作の一例を示すフローチャートである。タスク修正部11100は、実行権移譲要求が発生したときに呼び出され、第2演算タスク1312中のチェックポイント12200-nに対して必要に応じ修正を行う。ここで、実行権移譲要求には、例えば割込みまたはセマフォを利用し、演算プログラム1310が割り付けられたプロセッサコア1100-nとは別のプロセッサコア1100-mに割り付けられたタスクから、第2演算タスク1312に対して通知を行うことができる。割込みを利用する場合は、タスク修正部11100を割込みハンドラとして実装してもよい。セマフォを利用する場合は、タスク修正部11100をタスクとして実装してもよい。 FIG. 13 is a flowchart showing an example of the operation of the task modification unit 11100 of the system program 11000 of the program execution device 1000 according to the second embodiment. The task modification unit 11100 is called when a request for transfer of execution rights occurs, and modifies the checkpoint 12200-n in the second calculation task 1312 as necessary. Here, the execution right transfer request can be made using, for example, an interrupt or a semaphore, and a notification can be sent to the second calculation task 1312 from a task assigned to a processor core 1100-m other than the processor core 1100-n to which the calculation program 1310 is assigned. If an interrupt is used, the task modification unit 11100 may be implemented as an interrupt handler. If a semaphore is used, the task modification unit 11100 may be implemented as a task.

 ステップS13101では、第2演算タスク1312中のrunning変数12100の値が「true」であるか「false」であるかを参照し、第2演算タスクが実行中であるか否かを判断する。実行中であればステップS13102が次に処理され、実行中でなければステップS13201が次に処理される。 In step S13101, the value of the running variable 12100 in the second calculation task 1312 is checked to see if it is "true" or "false," and it is determined whether the second calculation task is currently running. If it is currently running, step S13102 is processed next; if it is not currently running, step S13201 is processed next.

 ステップS13102では、チェックポイント12200-nに相当する関数ポインタにタスク切替部11200のエントリポイントのアドレスを、当該関数ポインタ型にキャストし代入する。実施の形態1とは異なり、タスク修正部11100は修正対象の位置を特定する必要はなく、関数ポインタの値を書き換えるのみでよい。 In step S13102, the address of the entry point of the task switching unit 11200 is cast to the function pointer corresponding to checkpoint 12200-n and assigned to that function pointer type. Unlike in embodiment 1, the task correction unit 11100 does not need to identify the location to be corrected; it only needs to rewrite the value of the function pointer.

 ステップS13103では、タスク修正部11100の実行が終了し、第2演算タスク1312の実行が再開される。 In step S13103, execution of the task correction unit 11100 ends, and execution of the second calculation task 1312 resumes.

 ステップS13201では、第2演算タスク1312が実行中でないと判断されたため、タスク修正部11100から直接タスク切替部11200を呼び出し、第1演算タスク1311を起動する。 In step S13201, it is determined that the second calculation task 1312 is not currently running, so the task modification unit 11100 directly calls the task switching unit 11200 and starts the first calculation task 1311.

 図14は、実施の形態2にかかるプログラム実行装置1000のシステムプログラム11000のタスク切替部11200の動作の一例を示すフローチャートである。タスク切替部11200は、タスク修正部11100によって修正された第2演算タスク1312中のチェックポイント12200-nに対して原状回復を行い、OSの機能を利用してスケジューリング優先度の低いタスクから高いタスクに実行権を移す。タスク切替部11200は、例えば関数として実装してもよい。 FIG. 14 is a flowchart showing an example of the operation of the task switching unit 11200 of the system program 11000 of the program execution device 1000 according to the second embodiment. The task switching unit 11200 restores the checkpoint 12200-n in the second calculation task 1312 corrected by the task correction unit 11100, and uses the OS functions to transfer execution rights from a task with a low scheduling priority to a task with a high scheduling priority. The task switching unit 11200 may be implemented as a function, for example.

 ステップS14101では、第2演算タスク1312が実行中であるか否かを判断する。例えば、第2演算タスク1312中のrunning変数12100の値が「true」であるか「false」であるかを参照して判断してもよい。第2演算タスク1312が実行中であればステップS14102が次に処理され、第2演算タスク1312が実行中でなければステップS14103が次に処理される。 In step S14101, it is determined whether the second calculation task 1312 is running. For example, this determination may be made by referring to whether the value of the running variable 12100 in the second calculation task 1312 is "true" or "false." If the second calculation task 1312 is running, step S14102 is processed next; if the second calculation task 1312 is not running, step S14103 is processed next.

 ステップS14102では、タスク修正部11100によって修正されたチェックポイント12200-nに相当する関数ポインタに無効な値である「0」を代入する。 In step S14102, the task correction unit 11100 assigns the invalid value "0" to the function pointer corresponding to the checkpoint 12200-n corrected by the task correction unit 11100.

 ステップS14103では、より低い第2スケジューリング優先度2220を持つ第2演算タスク1312から、より高い第1スケジューリング優先度2120を持つ第1演算タスク1311に対して実行権を移譲する。 In step S14103, the second calculation task 1312, which has a lower second scheduling priority 2220, transfers execution rights to the first calculation task 1311, which has a higher first scheduling priority 2120.

 ステップS14104では、第1演算タスク1311の実行が完了するまで待機する。 In step S14104, the process waits until execution of the first calculation task 1311 is complete.

 ステップS14105では、第2演算タスク1312中のチェックポイント12200-nにリターンし、第2演算タスク1312の実行を再開する。タスク切替部11200を関数として実装する場合は、本ステップは通常の関数からのリターン操作である。 In step S14105, the process returns to checkpoint 12200-n in the second calculation task 1312, and execution of the second calculation task 1312 resumes. If the task switching unit 11200 is implemented as a function, this step is a normal return operation from the function.

<実施の形態2の効果>
 実施の形態2では、実施の形態1と同様、多数のクリティカルセクション12400-nを高密度に含む2つのスレッドもしくはタスクを単一のプロセッサコア1100-n上で実行する場合に、実行権移譲要求の発生時に、タスク修正部11100によって実行中のタスク中のチェックポイントからタスク切替部11200を呼び出すように修正し、修正されたチェックポイントを起点として別タスクに実行切り替えすることで排他制御を実現する。実施の形態2では、実施の形態1と比べて、実行時はチェックポイントで関数ポインタの値に応じて条件分岐する分のオーバヘッドはあるが、条件分岐方向のヒントをコンパイラに与える等の工夫により性能劣化は最小限に抑えられる。実施の形態2によれば、応答時間の伸長については、実施の形態1と同様の効果がある。加えて、実施の形態2では、タスク修正部11100は主記憶装置1200上にロードされたテキスト領域を書き換える操作は行わないため、実行時に悪意のあるコードブロックを挿入され実行され得るセキュリティホールを塞ぐ効果がある。
<Effects of Second Embodiment>
In the second embodiment, similar to the first embodiment, when two threads or tasks containing a large number of densely packed critical sections 12400-n are executed on a single processor core 1100-n, when a request for transfer of execution rights occurs, the task modification unit 11100 modifies the currently executing task so that the task switching unit 11200 is called from a checkpoint in the currently executing task, and exclusive control is achieved by switching execution to another task starting from the modified checkpoint. In the second embodiment, compared to the first embodiment, there is overhead during execution due to conditional branching based on the value of a function pointer at a checkpoint, but performance degradation is minimized by measures such as providing a hint to the compiler regarding the direction of the conditional branch. According to the second embodiment, the same effect as the first embodiment is achieved in terms of extending response time. In addition, in the second embodiment, the task modification unit 11100 does not rewrite the text area loaded on the main memory device 1200, which has the effect of closing security holes that allow malicious code blocks to be inserted and executed during execution.

実施の形態3.
 以下、実施の形態3に関するプログラム実行装置およびプログラム実行方法について説明する。なお、以下の説明においては、実施の形態1、実施の形態2で説明された構成要素と同様の構成要素については同じ符号を付して図示し、その詳細な説明を適宜省略するものとする。また、実施の形態3では、実行周期およびスケジューリング優先度を持つ3以上の演算タスクがOSによって優先度スケジューリングされる例を示して説明するが、実行周期を持たない、あるいは優先度スケジューリングされない演算タスクに対しても、実施の形態3を適用することができる。
Embodiment 3.
A program execution device and a program execution method according to the third embodiment will be described below. In the following description, components similar to those described in the first and second embodiments will be denoted by the same reference numerals, and detailed description thereof will be omitted as appropriate. In the third embodiment, an example will be described in which three or more computation tasks each having an execution period and a scheduling priority are prioritized by the OS, but the third embodiment can also be applied to computation tasks that do not have an execution period or are not prioritized.

 実施の形態1,2では、演算プログラムが2つの演算タスクを内包し、これらがすべて単一プロセッサコアに割り付けられて実行される場合のプログラム実行装置について説明した。実施の形態3では、演算プログラムが3以上のタスクを内包し、これらがすべて単一プロセッサコアに割り付けられて実行される場合のプログラム実行装置およびプログラム実行方法について説明する。特に、実施の形態3は実施の形態1をベースとして、演算タスク数を3以上に拡大した場合のプログラム実行装置である。実施の形態3において、チェックポイントは、実施の形態1と同様、クリティカルセクションを特定するための単なる目印、ラベルであり、プロセッサコア1100-1~1100-4によって何の処理も実行されない。 In the first and second embodiments, a program execution device was described for a case in which a computation program includes two computation tasks, all of which are assigned to a single processor core for execution. In the third embodiment, a program execution device and program execution method will be described for a case in which a computation program includes three or more tasks, all of which are assigned to a single processor core for execution. In particular, the third embodiment is based on the first embodiment and is a program execution device in which the number of computation tasks is expanded to three or more. In the third embodiment, as in the first embodiment, checkpoints are simply marks or labels for identifying critical sections, and no processing is performed by processor cores 1100-1 to 1100-4.

 まず、実施の形態3の基本的なアイデアを述べる。実施の形態1では、演算タスク数が2であったため、一方(第2演算タスク1312)が割り込まれる演算タスクであり、他方(第1演算タスク1311)が割り込む演算タスクであった。そのため、第2演算タスク1312の実行中における実行権移譲要求の同時発生数は高々1であった。これに対し、実施の形態3では、演算タスク数が3以上であるため、割り込む演算タスクが2以上存在することになる。つまり、ある演算タスクの実行中における実行権移譲要求の同時発生数が2以上となるケースが想定される。 First, the basic idea of embodiment 3 will be described. In embodiment 1, the number of calculation tasks was two, so one (second calculation task 1312) was the calculation task to be interrupted, and the other (first calculation task 1311) was the calculation task that interrupted. Therefore, the number of simultaneous execution right transfer requests during execution of the second calculation task 1312 was at most one. In contrast, in embodiment 3, the number of calculation tasks is three or more, so there will be two or more interrupting calculation tasks. In other words, it is possible to imagine a case where the number of simultaneous execution right transfer requests during execution of a certain calculation task will be two or more.

 上記で示した多重に実行権移譲要求が発生し得るケースを深掘りすると、実施の形態1の図10において、実行権移譲要求の発生時点から第1演算タスク1311の実行開始時点までの期間に別の実行権移譲要求が発生すると不具合が発生する。この期間では、元々実行中であった第2演算タスク1312中のチェックポイントをタスク切替部1324のエントリポイントにジャンプする命令に書き換えられる。もし、この期間に別の実行権移譲要求が発生したとすると、第2演算タスク1312中の同一のチェックポイントが二重に書き換えられたり、書き換え対象のチェックポイントのアドレスを取得できなかったりするケースが起こり得る。これらのケースを回避するために、この期間では別の実行権移譲要求を受け付けない仕組みとする。 Digging deeper into the cases where multiple execution right transfer requests can occur as shown above, in Figure 10 of embodiment 1, a malfunction occurs if another execution right transfer request occurs during the period from the time an execution right transfer request is made until the time the first operation task 1311 starts executing. During this period, the checkpoint in the second operation task 1312 that was originally being executed is rewritten with an instruction to jump to the entry point of the task switching unit 1324. If another execution right transfer request occurs during this period, it may happen that the same checkpoint in the second operation task 1312 is rewritten twice, or that the address of the checkpoint to be rewritten cannot be obtained. To avoid these cases, a mechanism is used that does not accept another execution right transfer request during this period.

 図15は、実施の形態3にかかるプログラム実行装置1000の演算プログラム15000の構成の一例を示すブロック図である。演算プログラム15000は、N個のタスクを内包し、第1演算タスク15100と、第h演算タスク15200と、第i演算タスク15300とを含む(1<h<i≦N)。第h演算タスク15200が請求の範囲の第2演算タスクに対応し、第i演算タスク15300が請求の範囲の第3演算タスクに対応する。 FIG. 15 is a block diagram showing an example of the configuration of a calculation program 15000 of a program execution device 1000 according to the third embodiment. The calculation program 15000 includes N tasks, including a first calculation task 15100, an h-th calculation task 15200, and an i-th calculation task 15300 (1<h<i≦N). The h-th calculation task 15200 corresponds to the second calculation task in the claims, and the i-th calculation task 15300 corresponds to the third calculation task in the claims.

 図16は、実施の形態3において、演算プログラム15000の実行時の動作の一例を示すタイムチャートである。第1演算タスク15100は、第1実行周期16110を持ち、第1スケジューリング優先度16120を持つ。第h演算タスク15200は、第h実行周期16210を持ち、第1スケジューリング優先度16120より低い第hスケジューリング優先度16220を持つ。第i演算タスク15300は、第i実行周期16310を持ち、第hスケジューリング優先度16220より低い第iスケジューリング優先度16320を持つ。第1演算タスク15100と第h演算タスク15200と第i演算タスク15300とは、OSのスケジューラによってそれぞれのスケジューリング優先度にもとづき、マイクロプロセッサ1100に具備される単一のプロセッサコア1100-nに割り付けられ実行されるものとする。 Figure 16 is a time chart showing an example of the operation during execution of the computation program 15000 in embodiment 3. The first computation task 15100 has a first execution period 16110 and a first scheduling priority 16120. The h-th computation task 15200 has an h-th execution period 16210 and an h-th scheduling priority 16220 that is lower than the first scheduling priority 16120. The i-th computation task 15300 has an i-th execution period 16310 and an i-th scheduling priority 16320 that is lower than the h-th scheduling priority 16220. The first computation task 15100, the h-th computation task 15200, and the i-th computation task 15300 are allocated to a single processor core 1100-n provided in the microprocessor 1100 and executed by the OS scheduler based on their respective scheduling priorities.

 第i演算タスク15300が実行中のときに、第h演算タスク15200の第h実行周期16210の開始時点でタイマ割込み等が入る。すると、第i演算タスク15300の実行が中断され、第hスケジューリング優先度16220の方が第iスケジューリング優先度16320より高いため、OSによって第h演算タスク15200が実行される。第h演算タスク15200の実行が終了すると、第i演算タスク15300が割り込まれた地点から実行が再開される。 When the i-th computation task 15300 is being executed, a timer interrupt or the like occurs at the start of the h-th execution cycle 16210 of the h-th computation task 15200. This causes the execution of the i-th computation task 15300 to be suspended, and because the h-th scheduling priority 16220 is higher than the i-th scheduling priority 16320, the h-th computation task 15200 is executed by the OS. When the execution of the h-th computation task 15200 ends, execution of the i-th computation task 15300 resumes from the point where it was interrupted.

 第h演算タスク15200が実行中のときに、第1演算タスク15100の第1実行周期16110の開始時点でタイマ割込み等が入る。すると、第h演算タスク15200の実行が中断され、第1スケジューリング優先度16120の方が第hスケジューリング優先度16220より高いため、OSによって第1演算タスク15100が実行される。第1演算タスク15100の実行が終了すると、第h演算タスク15200が割り込まれた地点から実行が再開される。 When the h-th calculation task 15200 is being executed, a timer interrupt or the like occurs at the start of the first execution cycle 16110 of the first calculation task 15100. This causes the execution of the h-th calculation task 15200 to be suspended, and because the first scheduling priority 16120 is higher than the h-th scheduling priority 16220, the OS executes the first calculation task 15100. When the execution of the first calculation task 15100 ends, execution of the h-th calculation task 15200 resumes from the point where it was interrupted.

 図17は、実施の形態3において、クリティカルセクション17400-nを含む第h演算タスク15200のC言語記述の一例を示す図である(1≦h<i≦N)。図17では、第h演算タスク15200が実行中であるか否かを示すrunning_h変数17100が定義される。running_h変数17100の値が「true」であれば実行中であることを示し、「false」であれば実行中でないことを示す。また、第h演算タスク15200によって実行されるルーチンとしてtask_h()関数17200が定義されており、第h演算タスク15200の生成時にこのルーチンのエントリポイントが第h演算タスク15200に紐づけられることが想定される。図17では、task_h()関数17200の実装として、while文にて多数のクリティカルセクション17400-nを高密度に含むコードブロックを反復処理する例を示す。while文のブロックの先頭にてwaitUntilDispatched()関数を用い、タスク切替部1324から実行権を与えられて実行中の状態になるまで待機する。待機が解除されると、running_h変数17100に「true」を設定し、実行権移譲要求の受け付けを許可し、while文のブロックの末尾でrunning_h変数17100に「false」を設定する。 Figure 17 is a diagram showing an example of a C language description of the h-th operation task 15200 including a critical section 17400-n in embodiment 3 (1≦h<i≦N). In Figure 17, a running_h variable 17100 is defined, which indicates whether the h-th operation task 15200 is running. If the value of the running_h variable 17100 is "true", it indicates that it is running, and if it is "false", it indicates that it is not running. In addition, a task_h() function 17200 is defined as a routine executed by the h-th operation task 15200, and it is assumed that the entry point of this routine is linked to the h-th operation task 15200 when the h-th operation task 15200 is generated. Figure 17 shows an example of an implementation of the task_h() function 17200, in which a while statement is used to repeatedly process a code block that includes a large number of critical sections 17400-n densely. The waitUntilDispatched() function is used at the beginning of the while block to wait until execution rights are granted by the task switching unit 1324 and the task enters a running state. When the wait is released, the running_h variable 17100 is set to "true", allowing acceptance of the execution rights transfer request, and the running_h variable 17100 is set to "false" at the end of the while block.

 各クリティカルセクション17400-nの先頭には、チェックポイント17300-nとしてラベルが記述される。 At the beginning of each critical section 17400-n, a label is written as a checkpoint 17300-n.

 図18は、実施の形態3において、クリティカルセクション18400-nを含む第i演算タスク15300のC言語記述の一例を示す図である(1≦h<i≦N)。図18では、第i演算タスク15300が実行中であるか否かを示すrunning_i変数18100が定義される。running_i変数18100の値が「true」であれば実行中であることを示し、「false」であれば実行中でないことを示す。また、第i演算タスク15300によって実行されるルーチンとしてtask_i()関数18200が定義されており、第i演算タスク15300の生成時にこのルーチンのエントリポイントが第i演算タスク15300に紐づけられることが想定される。図18では、task_i()関数18200の実装として、while文にて多数のクリティカルセクション18400-nを高密度に含むコードブロックを反復処理する例を示す。while文のブロックの先頭にてwaitUntilDispatched()関数を用い、OSから実行権を与えられて実行中の状態になるまで待機する。待機が解除されると、running_i変数18100に「true」を設定し、実行権移譲要求の受け付けを許可し、while文のブロックの末尾でrunning_i変数18100に「false」を設定する。 Figure 18 is a diagram showing an example of a C language description of the i-th operation task 15300 including a critical section 18400-n in embodiment 3 (1≦h<i≦N). In Figure 18, a running_i variable 18100 is defined, which indicates whether the i-th operation task 15300 is running. If the value of the running_i variable 18100 is "true", it indicates that it is running, and if it is "false", it indicates that it is not running. In addition, a task_i() function 18200 is defined as a routine executed by the i-th operation task 15300, and it is assumed that the entry point of this routine is linked to the i-th operation task 15300 when the i-th operation task 15300 is created. Figure 18 shows an example of an implementation of the task_i() function 18200, in which a while statement is used to repeatedly process a code block that includes a large number of critical sections 18400-n densely. The waitUntilDispatched() function is used at the beginning of the while block to wait until execution permission is granted by the OS and the process enters a running state. When the wait is released, the running_i variable 18100 is set to "true", allowing the request to transfer execution permission to be accepted, and the running_i variable 18100 is set to "false" at the end of the while block.

 各クリティカルセクション18400-nの先頭には、チェックポイント18300-nとしてラベルが記述される。 At the beginning of each critical section 18400-n, a label is written as a checkpoint 18300-n.

 図19は、実施の形態3にかかるプログラム実行装置1000のシステムプログラム1320のタスク修正部1323の動作の一例を示すフローチャートである。タスク修正部1323は、実行権移譲要求が発生したときに呼び出され、実行中であった演算タスク中のチェックポイントに対して必要に応じ修正を行う。ここで、実行権移譲要求には、例えば割込みまたはセマフォを利用し、演算プログラム15000が割り付けられたプロセッサコア1100-nとは別のプロセッサコア1100-mに割り付けられたタスクから、第i演算タスク15300に対して通知を行うことができる。割込みを利用する場合は、タスク修正部1323を割込みハンドラとして実装してもよい。セマフォを利用する場合は、タスク修正部1323をタスクとして実装してもよい。 FIG. 19 is a flowchart showing an example of the operation of the task modification unit 1323 of the system program 1320 of the program execution device 1000 according to the third embodiment. The task modification unit 1323 is called when a request for transfer of execution rights occurs, and modifies the checkpoint in the calculation task that was being executed as necessary. Here, the execution rights transfer request can be made using, for example, an interrupt or a semaphore, and a notification can be sent to the i-th calculation task 15300 from a task assigned to a processor core 1100-m other than the processor core 1100-n to which the calculation program 15000 is assigned. When an interrupt is used, the task modification unit 1323 may be implemented as an interrupt handler. When a semaphore is used, the task modification unit 1323 may be implemented as a task.

 ステップS19101では、演算プログラム15000が割り付けられたプロセッサコア1100-nにおいて実行権移譲要求の受け付けが禁止される。実行権移譲要求に割込みを利用する場合は、特定のID(Identification)を持つ割込みをマスクするか、すべての割込みそのものを禁止すればよい。実行権移譲要求にセマフォを利用する場合も、同様の措置を取ればよい。セマフォを解放することで特定のタスクを起動する場合には、通常、OSが当該プロセッサコアに対して割込みをかけて、タスクの実行切り替えを実行しているためである。 In step S19101, processor core 1100-n to which computing program 15000 is assigned is prohibited from accepting requests to transfer execution rights. If an interrupt is used for the request to transfer execution rights, interrupts with a specific ID (Identification) can be masked, or all interrupts can be prohibited. Similar measures can be taken when a semaphore is used for the request to transfer execution rights. This is because when a specific task is started by releasing a semaphore, the OS usually issues an interrupt to the processor core in question to switch the task execution.

 ステップS19102では、タスク修正部1323が呼び出される直前に実行中であった演算タスクの次に実行する演算タスクのタスクIDを特定する。ここでは、実行権移譲要求は次に実行する演算タスクに1対1で対応していることを前提としている。割込みを利用する場合は、1つのタスクに対して1つの割込みIDを紐づける。セマフォを利用する場合は、1つのタスクに対して1つのセマフォを紐づける。これにより、タスク修正部1323は、割込みIDまたはセマフォを参照することで、次に実行する演算タスクのタスクIDを特定することができる。 In step S19102, the task modification unit 1323 identifies the task ID of the calculation task to be executed next after the calculation task that was being executed immediately before being called. Here, it is assumed that the execution right transfer request corresponds one-to-one with the calculation task to be executed next. When an interrupt is used, one interrupt ID is linked to one task. When a semaphore is used, one semaphore is linked to one task. In this way, the task modification unit 1323 can identify the task ID of the calculation task to be executed next by referring to the interrupt ID or semaphore.

 ステップS19103では、すべての演算タスクのrunning変数の値が「true」であるか「false」であるかを参照し、任意の演算タスクが実行中であるか否かを判断する。実行中であればステップS19104が次に処理され、実行中でなければステップS19201が次に処理される。 In step S19103, the value of the running variable for all calculation tasks is checked to see if it is "true" or "false," and it is determined whether any calculation task is currently running. If it is currently running, step S19104 is processed next; if it is not currently running, step S19201 is processed next.

 ステップS19104では、実行権移譲要求によりタスク修正部1323が起動されたことにより第i演算タスク15300の実行が中断された時点のPC値を取得する。 In step S19104, the PC value at the time when the execution of the i-th calculation task 15300 was interrupted due to the task correction unit 1323 being activated in response to a request to transfer execution rights is obtained.

 ステップS19105では、ステップS19104で取得したPC値をアドレス算出部1321に渡し、実行中であった演算タスク中の次に実行されるチェックポイント18300-nのアドレスを取得する。なお、アドレス算出部1321に具備されるアドレステーブル5100は、図6の説明で述べた手法を用いて、例えば各演算タスクの初期化処理にてチェックポイントのアドレスを取得し、各エントリ6100-nに取得したアドレスを装填してもよい。 In step S19105, the PC value acquired in step S19104 is passed to the address calculation unit 1321, and the address of the checkpoint 18300-n to be executed next in the currently running computation task is acquired. Note that the address table 5100 provided in the address calculation unit 1321 may use the method described in the explanation of Figure 6 to acquire the address of the checkpoint during the initialization process of each computation task, for example, and load the acquired address into each entry 6100-n.

 ステップS19106では、ステップS19105で取得した次のチェックポイント18300-nのアドレスとチェックポイント18300-nのアドレスが指す位置に配置された命令との対である次のチェックポイント情報を、チェックポイント情報保持レジスタ1322に格納する。 In step S19106, the next checkpoint information, which is a pair of the address of the next checkpoint 18300-n obtained in step S19105 and the instruction located at the location indicated by the address of checkpoint 18300-n, is stored in the checkpoint information holding register 1322.

 ステップS19107では、ステップS19106で取得した次のチェックポイント18300-nのアドレスが指す位置を、タスク切替部1324のエントリポイントを呼び出す命令に書き換える。 In step S19107, the location pointed to by the address of the next checkpoint 18300-n obtained in step S19106 is rewritten to an instruction to call the entry point of the task switching unit 1324.

 ステップS19108では、タスク修正部1323の実行が終了し、実行中であった第i演算タスク15300の実行が再開される。 In step S19108, execution of the task correction unit 1323 ends, and execution of the i-th calculation task 15300 that was being executed is resumed.

 ステップS19201では、ステップS19103で任意の演算タスクが1つも実行中でないと判断されたため、タスク修正部1323から直接タスク切替部1324を呼び出し、タスクIDで指定された演算タスクを起動する。 In step S19201, since it was determined in step S19103 that no calculation tasks were currently being executed, the task modification unit 1323 directly calls the task switching unit 1324 and starts the calculation task specified by the task ID.

 図20は、実施の形態3にかかるプログラム実行装置1000のシステムプログラム1320のタスク切替部1324の動作の一例を示すフローチャートである。タスク切替部1324は、タスク修正部1323によって修正された実行中の演算タスク中のチェックポイントに対して原状回復を行う。また、OSの機能を利用してスケジューリング優先度の低いタスクから高いタスクに実行権を移す。なお、タスク切替部1324は、演算タスクのタスクIDがタスク修正部1323から受け渡されるものとする。 FIG. 20 is a flowchart showing an example of the operation of the task switching unit 1324 of the system program 1320 of the program execution device 1000 according to the third embodiment. The task switching unit 1324 restores the checkpoint in the running computation task that has been corrected by the task correction unit 1323. It also uses the OS functions to transfer the execution right from a task with a low scheduling priority to a task with a high scheduling priority. It is assumed that the task switching unit 1324 receives the task ID of the computation task from the task correction unit 1323.

 ステップS20101では、任意の演算タスクが実行中であるか否かを判断する。例えば、すべての演算タスクのrunning変数の値が「true」であるか「false」であるかを参照して判断してもよい。任意の演算タスクが実行中であればステップS20102が次に処理され、実行中でなければステップS20104が次に処理される。 In step S20101, it is determined whether any calculation task is running. For example, this determination may be made by checking whether the value of the running variable for all calculation tasks is "true" or "false." If any calculation task is running, step S20102 is processed next; if not, step S20104 is processed next.

 ステップS20102では、チェックポイント情報保持レジスタ1322から、タスク修正部1323によって修正されたチェックポイントのアドレスとチェックポイントのアドレスが指す位置に配置されていた命令との対を取得する。 In step S20102, the pair of the checkpoint address corrected by the task correction unit 1323 and the instruction located at the location indicated by the checkpoint address is obtained from the checkpoint information holding register 1322.

 ステップS20103では、ステップS20102で取得したアドレスが指す位置を、ステップS20102で取得した命令に書き換える。 In step S20103, the location pointed to by the address obtained in step S20102 is rewritten to the command obtained in step S20102.

 ステップS20104では、実行中の演算タスクからタスクIDで指定された演算タスクに対して実行権を移譲する。例えば、より低い第iスケジューリング優先度16320を持つ第i演算タスク15300から、より高い第hスケジューリング優先度16220を持つ第h演算タスク15200に対して実行権を移譲する。 In step S20104, the execution right is transferred from the currently running calculation task to the calculation task specified by the task ID. For example, the execution right is transferred from the i-th calculation task 15300, which has a lower i-th scheduling priority 16320, to the h-th calculation task 15200, which has a higher h-th scheduling priority 16220.

 ステップS20105では、タスクIDで指定された演算タスクの実行が完了するまで待機する。 In step S20105, the process waits until the execution of the calculation task specified by the task ID is completed.

 ステップS20106では、ステップS20102で取得したアドレスにリターンし、前に実行中であった演算タスクの実行を再開する。 In step S20106, the process returns to the address obtained in step S20102 and resumes execution of the previously running computation task.

 図21は、実施の形態3にかかるプログラム実行装置1000の各構成要素の一連の動作の一例を示すシーケンス図である。図21では、第i演算タスク15300中のクリティカルセクション18400-2の実行中に、第h演算タスク15200への実行権移譲要求が発生し、その後、さらに第h演算タスク15200中のクリティカルセクション17400-1の実行中に、第1演算タスク15100への実行権移譲要求が発生したときの、第1演算タスク15100と、第h演算タスク15200と、第i演算タスク15300と、タスク修正部1323と、タスク切替部1324とが相互作用して動作する様子を示している。 FIG. 21 is a sequence diagram showing an example of a series of operations of the components of the program execution device 1000 according to the third embodiment. FIG. 21 shows how the first operation task 15100, the hth operation task 15200, the ith operation task 15300, the task modification unit 1323, and the task switching unit 1324 interact and operate when a request to transfer execution rights to the hth operation task 15200 occurs during execution of the critical section 18400-2 in the ith operation task 15300, and then a request to transfer execution rights to the first operation task 15100 occurs during execution of the critical section 17400-1 in the hth operation task 15200.

 まず、第i演算タスク15300中のクリティカルセクション18400-2の実行中に、第h演算タスク15200への実行権移譲要求が発生すると、タスク修正部1323が起動し、その先頭で実行権移譲要求の受け付けを禁止した後、次のクリティカルセクション18400-3の先頭に位置するチェックポイント18300-3からタスク切替部1324を呼び出すように修正する。タスク修正部1323の実行が終了し、第i演算タスク15300中の実行中であったクリティカルセクション18400-2の未実行部分が実行される。次のクリティカルセクション18400-3の先頭のチェックポイント18300-3に実行が到達し、タスク切替部1324が呼び出される。タスク切替部1324は、チェックポイント18300-3からタスク切替部1324を呼び出さないように修正し、第i演算タスク15300から第h演算タスク15200に実行権を移し、第h演算タスク15200が実行され、その先頭で実行権移譲要求の受け付けを許可する。 First, when a request to transfer execution rights to the h-th operation task 15200 occurs during execution of critical section 18400-2 in the i-th operation task 15300, the task correction unit 1323 is activated and prohibits acceptance of execution rights transfer requests at the beginning of the critical section, and then corrects the task so that the task switch unit 1324 is called from checkpoint 18300-3 located at the beginning of the next critical section 18400-3. Execution of the task correction unit 1323 ends, and the unexecuted part of critical section 18400-2 that was being executed in the i-th operation task 15300 is executed. Execution reaches checkpoint 18300-3 at the beginning of the next critical section 18400-3, and the task switch unit 1324 is called. The task switching unit 1324 is modified so that it is not called from checkpoint 18300-3, and the execution right is transferred from the i-th operation task 15300 to the h-th operation task 15200. The h-th operation task 15200 is executed, and the execution right transfer request is accepted at the beginning of the task.

 次に、第h演算タスク15200中のクリティカルセクション17400-1の実行中に、第1演算タスク15100への実行権移譲要求が発生すると、タスク修正部1323が起動し、その先頭で実行権移譲要求の受け付けを禁止した後、次のクリティカルセクション17400-2の先頭に位置するチェックポイント17300-2からタスク切替部1324を呼び出すように修正する。タスク修正部1323の実行が終了し、第h演算タスク15200中の実行中であったクリティカルセクション17400-1の未実行部分が実行される。次のクリティカルセクション17400-2の先頭のチェックポイント17300-2に実行が到達し、タスク切替部1324が呼び出される。タスク切替部1324は、チェックポイント17300-2からタスク切替部1324を呼び出さないように修正し、第h演算タスク15200から第1演算タスク15100に実行権を移し、第h演算タスク15200が実行され、その先頭で実行権移譲要求の受け付けを許可した後、後続の処理が実行される。 Next, when a request to transfer execution rights to the first operation task 15100 occurs during execution of critical section 17400-1 in the h-th operation task 15200, the task correction unit 1323 is activated and prohibits acceptance of the execution rights transfer request at the beginning of the critical section, and then corrects the task so that the task switch unit 1324 is called from checkpoint 17300-2 located at the beginning of the next critical section 17400-2. Execution of the task correction unit 1323 ends, and the unexecuted part of critical section 17400-1 that was being executed in the h-th operation task 15200 is executed. Execution reaches checkpoint 17300-2 at the beginning of the next critical section 17400-2, and the task switch unit 1324 is called. The task switching unit 1324 is modified so that it is not called from checkpoint 17300-2, and the execution right is transferred from the h-th operation task 15200 to the first operation task 15100. The h-th operation task 15200 is executed, and after accepting the execution right transfer request at the beginning of the task, subsequent processing is executed.

 第1演算タスク15100の実行が終了すると、タスク切替部1324に実行権が戻り、第h演算タスク15200にリターンされ、第h演算タスク15200の実行がクリティカルセクション17400-2の先頭から再開される。第h演算タスク15200の実行が終了すると、第i演算タスク15300にリターンされ、第i演算タスク15300の実行がクリティカルセクション18400-3の先頭から再開される。 When execution of the first operation task 15100 is completed, execution rights are returned to the task switching unit 1324, and the execution is returned to the h-th operation task 15200, and execution of the h-th operation task 15200 is resumed from the beginning of the critical section 17400-2. When execution of the h-th operation task 15200 is completed, the execution is returned to the i-th operation task 15300, and execution of the i-th operation task 15300 is resumed from the beginning of the critical section 18400-3.

<実施の形態3の効果>
 実施の形態3では、多数のクリティカルセクションを高密度に含む3以上のスレッドもしくはタスクを単一のプロセッサコア1100-n上で実行する場合に、実行権移譲要求の発生時に、タスク修正部1323によって実行中のタスク中のチェックポイントからタスク切替部1324を呼び出すように修正し、修正されたチェックポイントを起点として別タスクに実行切り替えすることで排他制御を実現する。実行権移譲要求が発生していないときは、タスク修正部1323は実行中のタスクに対して何も修正を加えず、元のタスクはプロセッサコア1100-nによって何も処理されないチェックポイント(ラベル)が挿入されているだけなので、実行時の性能劣化は原理上ゼロである。また、必ずチェックポイントを起点としてタスクの実行切り替えを行うため、ユーザが意図しない応答時間の伸長を防止する効果がある。
<Effects of Third Embodiment>
In the third embodiment, when three or more threads or tasks containing a large number of closely spaced critical sections are executed on a single processor core 1100-n, when a request for transfer of execution rights occurs, the task modification unit 1323 modifies the currently executing task to call the task switching unit 1324 from a checkpoint in the currently executing task, and exclusive control is achieved by switching execution to another task starting from the modified checkpoint. When a request for transfer of execution rights does not occur, the task modification unit 1323 does not modify the currently executing task, and the original task simply has a checkpoint (label) inserted that is not processed by the processor core 1100-n, so performance degradation during execution is, in principle, zero. Furthermore, because task execution switching is always performed starting from a checkpoint, there is an effect of preventing an unintended extension of response time.

実施の形態4.
 以下、実施の形態4に関するプログラム実行装置およびプログラム実行方法について説明する。なお、以下の説明においては、実施の形態1~3で説明された構成要素と同様の構成要素については同じ符号を付して図示し、その詳細な説明を適宜省略するものとする。また、実施の形態4では、実行周期とスケジューリング優先度とを持つ3以上の演算タスクがOSによって優先度スケジューリングされる例を示して説明するが、実行周期を持たない、あるいは優先度スケジューリングされない演算タスクに対しても、実施の形態4を適用することができる。
Embodiment 4.
A program execution device and a program execution method according to the fourth embodiment will be described below. In the following description, components similar to those described in the first to third embodiments will be denoted by the same reference numerals, and detailed description thereof will be omitted as appropriate. In the fourth embodiment, an example will be described in which three or more computation tasks each having an execution period and a scheduling priority are prioritized by the OS, but the fourth embodiment can also be applied to computation tasks that do not have an execution period or are not prioritized.

 実施の形態4では、実施の形態3と同様に、演算プログラムが3以上の演算タスクを内包し、これらがすべて単一プロセッサコアに割り付けられて実行される場合のプログラム実行装置およびプログラム実行方法について説明する。特に、実施の形態4は、実施の形態2をベースとして、演算タスク数を3以上に拡大した場合のプログラム実行装置である。 In the fourth embodiment, similar to the third embodiment, a program execution device and a program execution method will be described for a case in which an arithmetic program contains three or more arithmetic tasks, all of which are assigned to and executed by a single processor core. In particular, the fourth embodiment is a program execution device based on the second embodiment, in which the number of arithmetic tasks is expanded to three or more.

 図22は、実施の形態4において、クリティカルセクション22400-nを含む第h演算タスク15200のC言語記述の一例を示す図である。図22では、チェックポイントとして関数ポインタ22200が定義され、「0」で初期化される。関数ポインタ22200は、タスク修正部11100によってタスク切替部11200のエントリポイントのアドレスが代入される。図22では、task_h()関数22300の実装として、while文にて多数のクリティカルセクション22400-nを高密度に含むコードブロックを反復処理する例を示す。while文のブロックの先頭にてwaitUntilDispatched()関数を用い、タスク切替部11200から実行権を与えられて実行中の状態になるまで待機する。待機が解除されると、running_h変数22100に「true」を設定し、実行権移譲要求の受け付けを許可し、while文のブロックの末尾でrunning_h変数22100に「false」を設定する。 FIG. 22 is a diagram showing an example of a C language description of the h-th operation task 15200 including a critical section 22400-n in embodiment 4. In FIG. 22, a function pointer 22200 is defined as a checkpoint and initialized to "0." The task modification unit 11100 assigns the address of the entry point of the task switcher 11200 to the function pointer 22200. FIG. 22 shows an example of an implementation of the task_h() function 22300 in which a code block including a high density of multiple critical sections 22400-n is repeatedly processed using a while statement. The waitUntilDispatched() function is used at the beginning of the while statement block to wait until the task switcher 11200 grants execution rights and the task enters the running state. When the wait is released, the running_h variable 22100 is set to "true," allowing acceptance of a request to transfer execution rights, and the running_h variable 22100 is set to "false" at the end of the while statement block.

 各クリティカルセクション22400-nの先頭には、チェックポイント22200-1~3として、関数ポインタ22200の値が「0」でないことをチェックし、関数ポインタ22200を参照してタスク切替部11200を呼び出すためのコードが記述される。このように、実施の形態4において、チェックポイント22200-1~3は、実施の形態2と同様、関数ポインタを参照してタスク切替部11200を呼び出すためのコードであり、実行時はチェックポイントで関数ポインタの値に応じて条件分岐する分のオーバヘッドが発生する。 At the beginning of each critical section 22400-n, code is written as checkpoints 22200-1 to 22200-3 to check that the value of function pointer 22200 is not "0" and to call task switcher 11200 by referencing function pointer 22200. As in embodiment 2, checkpoints 22200-1 to 22200-3 are thus code for referencing the function pointer and calling task switcher 11200, and during execution, overhead is generated for conditional branching depending on the value of the function pointer at the checkpoint.

 図23は、実施の形態4において、クリティカルセクション23400-nを含む第i演算タスク15300のC言語記述の一例を示す図である。図23では、チェックポイントとして関数ポインタ23200が定義され、「0」で初期化される。関数ポインタ23200は、タスク修正部11100によってタスク切替部11200のエントリポイントのアドレスが代入される。図23では、task_i()関数23300の実装として、while文にて多数のクリティカルセクションを高密度に含むコードブロックを反復処理する例を示す。while文のブロックの先頭にてwaitUntilDispatched()関数を用い、OSから実行権を与えられて実行中の状態になるまで待機する。待機が解除されると、running_i変数23100に「true」を設定し、実行権移譲要求の受け付けを許可し、while文のブロックの末尾でrunning_i変数23100に「false」を設定する。 FIG. 23 is a diagram showing an example of a C language description of the i-th operation task 15300 including critical section 23400-n in embodiment 4. In FIG. 23, a function pointer 23200 is defined as a checkpoint and initialized to "0." The task modification unit 11100 assigns the address of the entry point of the task switching unit 11200 to the function pointer 23200. FIG. 23 shows an example of an implementation of the task_i() function 23300 in which a code block containing a large number of densely packed critical sections is repeatedly processed using a while statement. The waitUntilDispatched() function is used at the beginning of the while statement block to wait until execution permission is granted by the OS and the task enters the running state. When the wait is released, the running_i variable 23100 is set to "true," allowing acceptance of a request to transfer execution permission, and the running_i variable 23100 is set to "false" at the end of the while statement block.

 各クリティカルセクション23400-nの先頭には、チェックポイント23200-1~3として、関数ポインタ23200の値が「0」でないことをチェックし、関数ポインタ23200を参照してタスク切替部11200を呼び出すためのコードが記述される。 At the beginning of each critical section 23400-n, code is written as checkpoints 23200-1 to 23200-3 to check that the value of the function pointer 23200 is not "0" and to call the task switcher 11200 by referencing the function pointer 23200.

 図24は、実施の形態4にかかるプログラム実行装置1000のシステムプログラム11000のタスク修正部11100の動作の一例を示すフローチャートである。タスク修正部11100は、実行権移譲要求が発生したときに呼び出され、実行中であった演算タスク中のチェックポイントに対して必要に応じ修正を行う。 FIG. 24 is a flowchart showing an example of the operation of the task correction unit 11100 of the system program 11000 of the program execution device 1000 according to the fourth embodiment. The task correction unit 11100 is called when a request to transfer execution rights occurs, and corrects the checkpoints in the computation task that was being executed as necessary.

 ステップS24101では、演算プログラム16000が割り付けられたプロセッサコア1100-nにおいて実行権移譲要求の受け付けを禁止する。 In step S24101, the processor core 1100-n to which the computing program 16000 is assigned is prohibited from accepting a request to transfer execution rights.

 ステップS24102では、タスク修正部11100が呼び出される直前に実行中であった演算タスクの次に実行する演算タスクのタスクIDを特定する。ここでは、実行権移譲要求は次に実行する演算タスクに1対1で対応していることを前提としている。割込みを利用する場合は、1つのタスクに対して1つの割込みIDを紐づける。セマフォを利用する場合は、1つのタスクに対して1つのセマフォを紐づける。これにより、タスク修正部11100は、割込みIDまたはセマフォを参照することで、次に実行する演算タスクのタスクIDを特定することができる。 In step S24102, the task modification unit 11100 identifies the task ID of the computation task to be executed next after the computation task that was being executed immediately before being called. Here, it is assumed that the execution right transfer request corresponds one-to-one with the computation task to be executed next. When an interrupt is used, one interrupt ID is linked to one task. When a semaphore is used, one semaphore is linked to one task. This allows the task modification unit 11100 to identify the task ID of the computation task to be executed next by referring to the interrupt ID or semaphore.

 ステップS24103では、すべての演算タスクのrunning変数の値が「true」であるか「false」であるかを参照し、任意の演算タスクが実行中であるか否かを判断する。実行中であればステップS24104が次に処理され、実行中でなければステップS24201が次に処理される。 In step S24103, the value of the running variable for all calculation tasks is checked to see if it is "true" or "false," and it is determined whether any calculation task is currently running. If it is currently running, step S24104 is processed next; if it is not currently running, step S24201 is processed next.

 ステップS24104では、実行中であった演算タスクにおけるチェックポイントに相当する関数ポインタにタスク切替部11200のエントリポイントのアドレスを、当該関数ポインタ型にキャストし代入する。実施の形態1,3とは異なり、タスク修正部11100は修正対象の位置を特定する必要はなく、関数ポインタの値を書き換えるのみでよい。 In step S24104, the task switching unit 11200's entry point address is cast to the function pointer corresponding to the checkpoint in the computation task that was being executed, and assigned to that function pointer type. Unlike embodiments 1 and 3, the task correction unit 11100 does not need to identify the location to be corrected; it only needs to rewrite the value of the function pointer.

 ステップS24105では、タスク修正部11100の実行が終了し、実行中であった演算タスクの実行が再開される。 In step S24105, execution of the task correction unit 11100 ends, and execution of the calculation task that was being executed is resumed.

 ステップS24201では、ステップS24103で任意の演算タスクが1つも実行中でないと判断されたため、タスク修正部11100から直接タスク切替部11200を呼び出し、タスクIDで指定された演算タスクを起動する。 In step S24201, since it was determined in step S24103 that no arbitrary calculation tasks were currently being executed, the task modification unit 11100 directly calls the task switching unit 11200 and starts the calculation task specified by the task ID.

 図25は、実施の形態4にかかるプログラム実行装置1000のシステムプログラム11000のタスク切替部11200の動作の一例を示すフローチャートである。タスク切替部11200は、タスク修正部11100によって修正された実行中の演算タスク中のチェックポイントに対して原状回復を行い、OSの機能を利用してスケジューリング優先度の低いタスクから高いタスクに実行権を移す。タスク切替部11200は、例えば関数として実装してもよい。 FIG. 25 is a flowchart showing an example of the operation of the task switching unit 11200 of the system program 11000 of the program execution device 1000 according to the fourth embodiment. The task switching unit 11200 restores the checkpoint in the currently running computation task corrected by the task correction unit 11100, and uses the OS functions to transfer execution rights from a task with a low scheduling priority to a task with a high scheduling priority. The task switching unit 11200 may be implemented as a function, for example.

 ステップS25101では、任意の演算タスクが実行中であるか否かを判断する。例えば、すべての演算タスクのrunning変数の値が「true」であるか「false」であるかを参照して判断してもよい。任意の演算タスクが実行中であればステップS25102が次に処理され、実行中でなければステップS25103が次に処理される。 In step S25101, it is determined whether any calculation task is currently running. For example, this determination may be made by checking whether the value of the running variable for all calculation tasks is "true" or "false." If any calculation task is currently running, step S25102 is processed next; if not, step S25103 is processed next.

 ステップS25102では、タスク修正部11100によって修正されたチェックポイントに相当する関数ポインタに「0」を代入する。 In step S25102, the task correction unit 11100 assigns "0" to the function pointer corresponding to the checkpoint corrected.

 ステップS25103では、実行中の演算タスクからタスクIDで指定された演算タスクに対して実行権を移譲する。例えば、より低い第iスケジューリング優先度16320を持つ第i演算タスク15300から、より高い第hスケジューリング優先度16220を持つ第h演算タスク15200に対して実行権を移譲する。 In step S25103, execution rights are transferred from the currently running computation task to the computation task specified by the task ID. For example, execution rights are transferred from the i-th computation task 15300, which has a lower i-th scheduling priority 16320, to the h-th computation task 15200, which has a higher h-th scheduling priority 16220.

 ステップS25104では、タスクIDで指定された演算タスクの実行が完了するまで待機する。 In step S25104, the process waits until the execution of the calculation task specified by the task ID is completed.

 ステップS25105では、前に実行中であった演算タスク中のチェックポイントにリターンし、その演算タスクの実行を再開する。タスク切替部11200を関数として実装する場合は、本ステップは通常の関数からのリターン操作である。 In step S25105, the process returns to the checkpoint in the previously executing calculation task and resumes execution of that calculation task. If the task switching unit 11200 is implemented as a function, this step is a normal return operation from the function.

<実施の形態4の効果>
 実施の形態4では、多数のクリティカルセクションを高密度に含む3以上のスレッドもしくはタスクを単一のプロセッサコア1100-n上で実行する場合に、実行権移譲要求の発生時に、タスク修正部11100によって実行中のタスク中のチェックポイントからタスク切替部11200を呼び出すように修正し、修正されたチェックポイントを起点として別タスクに実行切り替えすることで排他制御を実現する。実施の形態4では、実施の形態3と比べて、実行時はチェックポイントで関数ポインタの値に応じて条件分岐する分のオーバヘッドはあるが、条件分岐方向のヒントをコンパイラに与える等の工夫により性能劣化は最小限に抑えられる。実施の形態4では、応答時間の伸長については、実施の形態3と同様の効果がある。加えて、実施の形態4では、タスク修正部11100は主記憶装置1200上にロードされたテキスト領域を書き換える操作は行わないため、実行時に悪意のあるコードブロックを挿入され実行され得るセキュリティホールを塞ぐ効果がある。
<Effects of Fourth Embodiment>
In the fourth embodiment, when three or more threads or tasks containing a large number of closely spaced critical sections are executed on a single processor core 1100-n, when a request for transfer of execution rights occurs, the task modification unit 11100 modifies the currently executing task so that the task switching unit 11200 is called from a checkpoint in the currently executing task, and exclusive control is achieved by switching execution to another task starting from the modified checkpoint. Compared to the third embodiment, the fourth embodiment has overhead during execution due to conditional branching based on the value of a function pointer at a checkpoint, but performance degradation is minimized by measures such as providing a hint to the compiler regarding the direction of the conditional branch. The fourth embodiment has the same effect as the third embodiment in terms of extending response time. Additionally, the fourth embodiment does not rewrite the text area loaded on the main memory device 1200, which effectively closes security holes that could allow malicious code blocks to be inserted and executed during execution.

 なお、本開示の範囲内において、各実施の形態を自由に組み合わせたり、各実施の形態を適宜、変形、省略したりすることが可能である。本開示は詳細に説明されたが、上記した説明は、すべての態様において、例示であって、限定的なものではない。例示されていない無数の変形例が想定され得るものと解される。 Furthermore, within the scope of this disclosure, it is possible to freely combine the various embodiments, and to modify or omit various embodiments as appropriate. This disclosure has been described in detail, but the above description is illustrative in all aspects and is not limiting. It is understood that countless variations not illustrated can be envisioned.

 以上の実施の形態に示した構成は、本開示の内容の一例を示すものであり、別の公知の技術と組み合わせることも可能であるし、実施の形態同士を組み合わせることも可能であるし、本開示の要旨を逸脱しない範囲で、構成の一部を省略、変更することも可能である。 The configurations shown in the above embodiments are examples of the content of this disclosure, and may be combined with other known technologies, or different embodiments may be combined with each other. Parts of the configuration may also be omitted or modified without departing from the spirit of this disclosure.

 1000 プログラム実行装置、1100 マイクロプロセッサ、1100-1~1100-4,1100-n,1100-m プロセッサコア、1200 主記憶装置、1300 二次記憶装置、1310,15000 演算プログラム、1311,15100 第1演算タスク、1312 第2演算タスク、1320,11000 システムプログラム、1321 アドレス算出部、1322 チェックポイント情報保持レジスタ、1323,11100 タスク修正部、1324,11200 タスク切替部、3100,12100 running変数、3200,12300 task2()関数、3300-n,4100-n,12200-n,17300-n,18300-n,22200-n,23200-n チェックポイント、3400-n,12400-n,17400-n,18400-n,22400-n,23400-n クリティカルセクション、5100 アドレステーブル、6100-n エントリ、7100 アドレスフィールド、7200 命令フィールド、12200,22200,23200 関数ポインタ、15200 第h演算タスク、15300 第i演算タスク、17100,22100 running_h変数、17200,22300 task_h()関数、18100,23100 running_i変数、18200,22300,23300 task_i()関数。 1000 Program execution unit, 1100 Microprocessor, 1100-1 to 1100-4, 1100-n, 1100-m Processor core, 1200 Main memory, 1300 Secondary memory, 1310, 15000 Calculation program, 1311, 15100 First calculation task, 1312 Second calculation task, 1320, 11000 System program, 1321 Address calculation unit, 1322 Checkpoint information holding register, 1323, 11100 Task correction unit, 1324, 11200 Task switching unit, 3100, 12100 Running variable, 3200, 12300 Task2() function, 3300-n, 4100-n, 12200-n, 17300 -n, 18300-n, 22200-n, 23200-n Checkpoint, 3400-n, 12400-n, 17400-n, 18400-n, 22400-n, 23400-n Critical section, 5100 Address table, 6100-n Entry, 7100 Address field, 7200 Instruction field, 12200, 22200, 23200 Function pointer, 15200 hth operation task, 15300 ith operation task, 17100, 22100 Running_h variable, 17200, 22300 Task_h() function, 18100, 23100 Running_i variable, 18200, 22300, 23300 Task_i() function.

Claims (8)

 演算プログラムおよびシステムプログラムを格納する記憶装置と、1以上のプロセッサコアを備え、前記演算プログラムおよび前記システムプログラムを実行するマイクロプロセッサと、を備えるプログラム実行装置であって、
 前記演算プログラムは、第1演算タスクおよび前記第1演算タスクより低いスケジューリング優先度を持つ第2演算タスクを含み、前記マイクロプロセッサにおける単一の前記プロセッサコア上で実行され、
 前記第2演算タスクは、複数のクリティカルセクションと、各クリティカルセクションの先頭に位置するチェックポイントとを含み、
 前記第2演算タスクが実行中であれば前記第2演算タスクから前記第1演算タスクに実行権を移すタスク切替部と、
 前記第2演算タスクの実行中に前記第1演算タスクへの実行権移譲要求があったとき、前記第2演算タスクの実行を中断し、前記記憶装置上の前記第2演算タスクにおける次の前記チェックポイントに対して前記タスク切替部を呼び出すよう修正し、前記第2演算タスクにおける中断箇所から前記第2演算タスクの実行を再開させるタスク修正部と、
 を備えるプログラム実行装置。
A program execution device comprising: a storage device that stores an arithmetic program and a system program; and a microprocessor that has one or more processor cores and executes the arithmetic program and the system program,
the computing program includes a first computing task and a second computing task having a scheduling priority lower than that of the first computing task, and is executed on a single processor core in the microprocessor;
the second computing task includes a plurality of critical sections and a checkpoint located at the beginning of each critical section;
a task switching unit that transfers execution rights from the second computation task to the first computation task if the second computation task is currently being executed;
a task modification unit that, when a request for transfer of execution right to the first calculation task is made during the execution of the second calculation task, suspends the execution of the second calculation task, modifies the second calculation task on the storage device so as to call the task switching unit at the next checkpoint in the second calculation task, and resumes the execution of the second calculation task from the interruption point in the second calculation task;
A program execution device comprising:
 前記システムプログラムは、プログラムカウンタ値から次の前記チェックポイントのアドレスを算出するアドレス算出部と、チェックポイント情報保持レジスタと、を備え、
 前記タスク修正部は、前記第2演算タスクの実行中に前記実行権移譲要求があったとき、前記第2演算タスクの実行を中断し、中断地点のプログラムカウンタ値を取得し、前記アドレス算出部から次の前記チェックポイントのアドレスを取得し、前記チェックポイントのアドレスと前記アドレスが指す位置にある命令との対を前記チェックポイント情報保持レジスタに格納し、前記記憶装置上の前記チェックポイントを前記タスク切替部を呼び出す命令に書き換える
 請求項1に記載のプログラム実行装置。
the system program includes an address calculation unit that calculates the address of the next checkpoint from a program counter value, and a checkpoint information holding register;
2. The program execution device according to claim 1, wherein when the execution right transfer request is made during execution of the second calculation task, the task modification unit suspends execution of the second calculation task, obtains a program counter value at the suspension point, obtains the address of the next checkpoint from the address calculation unit, stores a pair of the checkpoint address and the instruction at the position pointed to by the address in the checkpoint information holding register, and rewrites the checkpoint on the storage device to an instruction that calls the task switching unit.
 前記アドレス算出部は、前記第2演算タスクに含まれる前記チェックポイントのアドレスを格納するアドレステーブルを持ち、
 前記アドレステーブルを前記プログラムカウンタ値で索引して、前記第2演算タスクにおける次の前記チェックポイントのアドレスを算出する
 請求項2に記載のプログラム実行装置。
the address calculation unit has an address table that stores addresses of the checkpoints included in the second operation task,
The program execution device according to claim 2 , wherein the address table is searched for using the program counter value to calculate the address of the next checkpoint in the second operation task.
 前記タスク切替部は、前記第2演算タスクから前記第1演算タスクに実行権を移す前に、前記チェックポイント情報保持レジスタから前記チェックポイントのアドレスと命令の対を取得し、
 前記記憶装置上の前記第2演算タスクにおける前記アドレスが指す位置を前記命令に書き換える
 請求項2に記載のプログラム実行装置。
the task switching unit acquires a pair of an address and an instruction of the checkpoint from the checkpoint information holding register before transferring execution right from the second calculation task to the first calculation task;
The program execution device according to claim 2 , wherein the location pointed to by the address in the second operation task on the storage device is rewritten to the instruction.
 前記第2演算タスクにおける前記チェックポイントは、前記クリティカルセクションの先頭に挿入された前記タスク切替部を参照可能なポインタであり、
 前記タスク修正部は、前記第2演算タスクの実行中に前記実行権移譲要求があったとき、前記第2演算タスクの実行を中断し、前記第2演算タスクにおける中断箇所の次の前記チェックポイントに前記タスク切替部のエントリポイントのアドレスを設定する
 請求項1に記載のプログラム実行装置。
the checkpoint in the second computation task is a pointer that can refer to the task switching unit inserted at the beginning of the critical section,
2. The program execution device according to claim 1, wherein the task modification unit suspends the execution of the second operation task when the execution right transfer request is received during the execution of the second operation task, and sets the address of the entry point of the task switching unit to the checkpoint next to the suspension point in the second operation task.
 前記タスク切替部は、前記第2演算タスクにおける前記チェックポイントに無効な値を設定した後に、前記第2演算タスクから前記第1演算タスクに実行権を移す
 請求項5に記載のプログラム実行装置。
The program execution device according to claim 5 , wherein the task switching unit transfers the execution right from the second computation task to the first computation task after setting an invalid value to the checkpoint in the second computation task.
 前記演算プログラムは、前記第2演算タスクより低いスケジューリング優先度を持ち、複数のクリティカルセクションと、各クリティカルセクションの先頭に位置するチェックポイントとを有する第3演算タスクを含み、
 前記タスク切替部は、前記第3演算タスクが実行中であれば、前記第1演算タスクまたは前記第2演算タスクに実行権を移し、
 前記タスク修正部は、前記第3演算タスクの実行中に、第1演算タスクまたは第2演算タスクへの実行権移譲要求があったとき、単一の前記プロセッサコアでの実行権移譲要求の受け付けを禁止して、前記第3演算タスクの実行を中断し、前記記憶装置上の前記第3演算タスクにおける次の前記チェックポイントに対して前記タスク切替部を呼び出すよう修正し、前記第3演算タスクにおける前記中断箇所から前記第3演算タスクの実行を再開させ、
 前記タスク切替部は、第1演算タスクまたは第2演算タスクが実行状態となったら、処理の先頭で単一の前記プロセッサコアでの実行権移譲要求の受け付けを許可する
 請求項1から6の何れか一つに記載のプログラム実行装置。
the computing program includes a third computing task having a scheduling priority lower than that of the second computing task, the third computing task having a plurality of critical sections and a checkpoint located at the beginning of each critical section;
the task switching unit, if the third computation task is being executed, transfers execution rights to the first computation task or the second computation task;
the task modification unit, when a request for transfer of execution right to the first or second computation task is made during the execution of the third computation task, prohibits acceptance of the execution right transfer request by a single processor core, suspends the execution of the third computation task, modifies the third computation task on the storage device to call the task switching unit at the next checkpoint in the third computation task, and resumes the execution of the third computation task from the interruption point in the third computation task;
7. The program execution device according to claim 1, wherein the task switching unit allows a single processor core to accept a request to transfer execution rights at the beginning of processing when the first computation task or the second computation task is in an execution state.
 演算プログラムおよびシステムプログラムを格納する記憶装置と、1以上のプロセッサコアを備え、前記演算プログラムおよび前記システムプログラムを実行するマイクロプロセッサと、を用いたプログラム実行方法であって、
 前記演算プログラムは、第1演算タスクおよび前記第1演算タスクより低いスケジューリング優先度を持つ第2演算タスクを含み、前記マイクロプロセッサにおける単一の前記プロセッサコア上で実行され、
 前記第2演算タスクは、複数のクリティカルセクションと、各クリティカルセクションの先頭に位置するチェックポイントとを含み、
 前記第2演算タスクが実行中であれば前記第2演算タスクから前記第1演算タスクに実行権を移すタスク切替ステップと、
 前記第2演算タスクの実行中に前記第1演算タスクへの実行権移譲要求があったとき、前記第2演算タスクの実行を中断し、前記記憶装置上の前記第2演算タスクにおける次の前記チェックポイントに対して前記タスク切替ステップを呼び出すよう修正し、前記第2演算タスクにおける中断箇所から前記第2演算タスクの実行を再開させるタスク修正ステップと、
 を備えるプログラム実行方法。
A program execution method using a storage device that stores an arithmetic program and a system program, and a microprocessor that has one or more processor cores and executes the arithmetic program and the system program, comprising:
the computing program includes a first computing task and a second computing task having a scheduling priority lower than that of the first computing task, and is executed on a single processor core in the microprocessor;
the second computing task includes a plurality of critical sections and a checkpoint located at the beginning of each critical section;
a task switching step of transferring execution rights from the second computation task to the first computation task if the second computation task is currently being executed;
a task modification step of suspending the execution of the second calculation task when a request for transfer of execution right to the first calculation task is made during the execution of the second calculation task, modifying the second calculation task on the storage device so as to call the task switching step at the next checkpoint in the second calculation task, and resuming the execution of the second calculation task from the interruption point in the second calculation task;
A program execution method comprising:
PCT/JP2024/022531 2024-06-21 2024-06-21 Program execution device and program execution method Pending WO2025262913A1 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
JP2024562328A JP7642174B1 (en) 2024-06-21 2024-06-21 PROGRAM EXECUTION DEVICE AND PROGRAM EXECUTION METHOD
PCT/JP2024/022531 WO2025262913A1 (en) 2024-06-21 2024-06-21 Program execution device and program execution method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/JP2024/022531 WO2025262913A1 (en) 2024-06-21 2024-06-21 Program execution device and program execution method

Publications (1)

Publication Number Publication Date
WO2025262913A1 true WO2025262913A1 (en) 2025-12-26

Family

ID=94825636

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/JP2024/022531 Pending WO2025262913A1 (en) 2024-06-21 2024-06-21 Program execution device and program execution method

Country Status (2)

Country Link
JP (1) JP7642174B1 (en)
WO (1) WO2025262913A1 (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2004078322A (en) * 2002-08-09 2004-03-11 Internatl Business Mach Corp <Ibm> Task management system, program, recording medium, and control method
US20070136730A1 (en) * 2002-01-04 2007-06-14 Microsoft Corporation Methods And System For Managing Computational Resources Of A Coprocessor In A Computing System
US20090006403A1 (en) * 2007-06-29 2009-01-01 International Business Machines Corporation Efficiently boosting priority of read-copy update readers while resolving races with exiting and unlocking processes
US20090198389A1 (en) * 2005-10-07 2009-08-06 Guenther Kirchhof-Falter Method for Controlling/Regulating At Least One Task

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8627030B2 (en) * 2007-11-07 2014-01-07 Intel Corporation Late lock acquire mechanism for hardware lock elision (HLE)
WO2016063511A1 (en) * 2014-10-21 2016-04-28 日本電気株式会社 Preemption control device, preemption control system, preemption control method, and recording medium having preemption control program stored therein

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070136730A1 (en) * 2002-01-04 2007-06-14 Microsoft Corporation Methods And System For Managing Computational Resources Of A Coprocessor In A Computing System
JP2004078322A (en) * 2002-08-09 2004-03-11 Internatl Business Mach Corp <Ibm> Task management system, program, recording medium, and control method
US20090198389A1 (en) * 2005-10-07 2009-08-06 Guenther Kirchhof-Falter Method for Controlling/Regulating At Least One Task
US20090006403A1 (en) * 2007-06-29 2009-01-01 International Business Machines Corporation Efficiently boosting priority of read-copy update readers while resolving races with exiting and unlocking processes

Also Published As

Publication number Publication date
JP7642174B1 (en) 2025-03-07

Similar Documents

Publication Publication Date Title
CN102156661B (en) Method, device and system for activating online patch
KR101673990B1 (en) Programmable exception processing latency
US10853071B2 (en) Simulation of exclusive instructions
CN111414626B (en) Real-time guaranteeing method and system based on TEE expansion
CN111858004A (en) Real-time application dynamic loading method and system for computer security world based on TEE extension
WO1997017654A1 (en) A system and method for fast context switching between tasks
WO2015036867A2 (en) Method and system for instruction scheduling
US6260191B1 (en) User controlled relaxation of optimization constraints related to volatile memory references
US7613912B2 (en) System and method for simulating hardware interrupts
JP2022503899A (en) Validating the stack pointer
Cox et al. Xv6, a simple Unix-like teaching operating system
CN103218262A (en) Activation method, activation device and activation system of online patches
US20070204271A1 (en) Method and system for simulating a multi-CPU/multi-core CPU/multi-threaded CPU hardware platform
JP6838223B2 (en) Vehicle control device
JP2006092042A (en) Information processor and context switching method
US8677101B2 (en) Method and apparatus for cooperative software multitasking in a processor system with a partitioned register file
JP2021057007A (en) Methods of hardware and software coordinated opt-in to advanced features on hetero isa platforms
US9009020B1 (en) Automatic identification of interesting interleavings in a multithreaded program
JP2005521937A (en) Context switching method and apparatus in computer operating system
JP5999216B2 (en) Data processing device
JP7642174B1 (en) PROGRAM EXECUTION DEVICE AND PROGRAM EXECUTION METHOD
JP6882320B2 (en) Vector instruction processing
JP6495290B2 (en) IC wireless device
Coffing An x86 protected mode virtual machine monitor for the mit exokernel
US11144329B2 (en) Processor microcode with embedded jump table