WO2007020739A1 - スケジューリング方法およびスケジューリング装置 - Google Patents

スケジューリング方法およびスケジューリング装置 Download PDF

Info

Publication number
WO2007020739A1
WO2007020739A1 PCT/JP2006/310907 JP2006310907W WO2007020739A1 WO 2007020739 A1 WO2007020739 A1 WO 2007020739A1 JP 2006310907 W JP2006310907 W JP 2006310907W WO 2007020739 A1 WO2007020739 A1 WO 2007020739A1
Authority
WO
WIPO (PCT)
Prior art keywords
execution unit
identifier
information
thread
executed
Prior art date
Application number
PCT/JP2006/310907
Other languages
English (en)
French (fr)
Inventor
Keisuke Inoue
Seiji Murata
Original Assignee
Sony Computer Entertainment Inc.
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 Sony Computer Entertainment Inc. filed Critical Sony Computer Entertainment Inc.
Priority to EP06756827A priority Critical patent/EP1923784A4/en
Priority to CN2006800179477A priority patent/CN101180609B/zh
Priority to US11/996,361 priority patent/US8375390B2/en
Publication of WO2007020739A1 publication Critical patent/WO2007020739A1/ja

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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
    • G06F9/526Mutual exclusion algorithms
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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/461Saving or restoring of program or task context
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues

Definitions

  • the present invention relates to a method and apparatus for scheduling execution units of parallel processing in a multiprocessor system.
  • An operating system that supports recent multitasking realizes a multitasking environment in which multiple processes can be executed simultaneously, and these processes create multiple threads in the process to execute parallel processing. Equipped with multi-thread technology that can Processes are allocated specific resources and address space at runtime and can not access the area of other processes. Threads, on the other hand, are units of execution created inside the process, and each thread can freely access the area in the process.
  • a thread is a basic execution unit to which the operating system allocates execution time of a CPU (central processing unit). In this specification, we will schedule thread allocation and! /.
  • processing can be executed in parallel or in cooperation to achieve high-speed processing of the entire processing.
  • executable threads are held in a shared memory called a task queue in shared memory. These threads are assigned to one of the processors and executed.
  • the method of allocating threads changes the performance such as process execution speed and memory consumption, so a multiprocessor system needs a scheme different from scheduling in a single processor system.
  • a method may be considered in which a management unit in charge of managing threads communicates with each processor and schedules threads to be assigned to each processor.
  • interrupts are not prohibited during scheduling, interrupts will be accepted while the scheduler locks the task queue. In this case, scheduling will not be executed until the interrupt processing is completed and the lock is released, leading to a reduction in system efficiency.
  • the kernel thread executing the user level scheduler is scheduled by the kernel level scheduler on each processor and may be preempted by other kernel threads, task queue locking is more likely to occur. It can cause serious problems.
  • the user level scheduler operating on the kernel thread acquires a lock, and if so, the user level scheduler operating on a thread of another processor is scheduled until the lock is released. You will not be able to ring.
  • the present invention has been made in view of the above circumstances, and an object thereof is to provide a multiprocessor system. It is an object of the present invention to provide a scheduling technique capable of improving processing efficiency by controlling the order in which execution units of parallel processing in a system are assigned to processors.
  • An aspect of the present invention relates to a method of scheduling an execution unit to be an execution target of a processor in a multiprocessor system.
  • This scheduling method assigns an identifier to each execution unit to be executed by a plurality of processors included in a multiprocessor system, and executes each unit in which each execution unit is in an executable state. It holds execution unit information that includes executability information that is shown in association with the above identifier, and latest execution information that indicates the identifier of the most recently executed execution unit among each execution unit.
  • an identifier of any executable execution unit under the restriction of preferentially selecting an identifier other than the identifier of the execution unit executed most recently, the execution unit executed by the processor It is selected as an identifier of, and the execution unit information is updated.
  • This aspect of the present invention may be applied to a system for scheduling by a management unit, and may be applied to a system for scheduling by each processor itself.
  • this aspect of the present invention may be applied to a system using user level scheduling that operates on threads provided by schedulers on each processor that are not limited to schedulers operating directly on each processor.
  • the executability information is held as a bit string to which one bit is allocated as an identifier for each execution unit, and the selection of bits and the update of the execution unit information are performed by an indivisible operation, ie, by an atomic operation. Let me do it.
  • Indivisible operation means the smallest unit of operation that can not be divided further, and is an operation that is guaranteed to be executed in a multiprocessor system without interaction with operations performed by other processors. is there.
  • the present invention is advantageous in scheduling execution units of parallel processing in a multiprocessor system.
  • FIG. 1 shows a multiprocessor system according to an embodiment of the present invention.
  • FIG. 2 is a diagram showing a task queue of the multiprocessor system shown in FIG.
  • FIG. 3 A diagram showing a configuration of thread information included in the task queue shown in FIG.
  • FIG. 4 is a diagram for explaining the details of thread information shown in FIG. 3;
  • FIG. 5 A flowchart showing a process of selecting a thread by a processor.
  • FIG. 6 A diagram showing a change in thread information accompanying the processing shown in FIG.
  • FIG. 7 A flowchart showing processing of adding a thread by a processor.
  • FIG. 8 A diagram showing changes in thread information accompanying the processing shown in FIG.
  • FIG. 9 is a diagram showing an example of a multiprocessor system using a user level scheduler.
  • FIG. 10 is a diagram showing an example of thread grouping in the multiprocessor system shown in FIG. 9;
  • FIG. 11 is a diagram showing an example of thread scheduling in the multiprocessor system shown in FIG. 9;
  • 10 processing unit, 12 ⁇ ⁇ ⁇ processor, 14 ... local memory, 16 ⁇ ⁇ memory control unit,
  • each processor execution unit for example, a thread
  • the task queue needs to be locked to prevent the task-one queue storing the thread from being modified by another processor.
  • An identifier is assigned to each thread, and executability information indicating whether or not each of these threads is in an executable state in association with the identifier of the thread, and most recently executed among the threads. Holds thread information including the latest execution information indicating the thread identifier. Then, based on the thread information, an identifier of a thread that assigns an identifier of one of the executable threads to the processor under the constraint of preferentially selecting an identifier other than the identifier of the most recently executed thread. Elect as.
  • thread entity! / the entity of a thread
  • a thread entity may be stored in association with an identifier, and each thread entity may be stored in a predetermined area of its memory, and the start address of the area where the thread entity is stored. Let's associate it with its identifier and save it in memory.
  • This technology divides a thread entity and thread information necessary to select which thread to execute, and stores the information in a memory. Therefore, when scheduling, it is possible to eliminate the dilemma as to whether or not to disable interrupts during scheduling without having to lock the area storing the thread entity.
  • This technique can solve the above dilemma and also solve the problem due to the user level scheduler even in a system that executes the user level scheduler.
  • a user level thread may be received on a kernel thread provided by the OS operating on each processor. It is considered that creating self-dominated scheduling, that is, using user-level scheduling, is an effective way to improve the processing efficiency of multiprocessor systems. In this method, there is a problem of scheduling failure and flooding caused by using a user level scheduler.
  • threads executing a user level scheduler may be scheduled by the kernel scheduler on each processor and preempted by other kernel threads.
  • the user-level scheduler operating on that thread acquires a lock, and if so, the user-level scheduler operating on threads of other processors is released until the lock is released. It will not be able to play, reducing the processing efficiency of the processor. Furthermore, the time until the lock is released depends on the situation and is difficult to estimate, which can be a cause of system instability.
  • processor A copies the task queue to its own memory and updates the task queue force to delete thread 1 from the task queue after selecting thread 1 for example. Perform processing and write the updated task queue back to main memory.
  • the task queue is locked to prevent the task queue on shared memory from being modified by another processor from when the copying of the task queue starts until the writing back of the task queue ends. While the task queue is locked, other processors can not use the task queue even if they become ready to execute threads in the task queue, so the longer the lock period, the more Processing efficiency decreases.
  • the scheduler operating on processor A may be preempted by an interrupt as described above. If processor A is preempted with the task queue locked, the other processors can not perform scheduling until processor A returns its interrupt handling power and the lock is released. It can not be performed. This can reduce the processing efficiency and make the system unstable.
  • the above description is for the processor A, ⁇ ⁇ ⁇ , the user ’s operating on the processor A ⁇ ⁇ ⁇ ⁇
  • a thread for example, thread a, ⁇ ⁇ ⁇
  • it can be applied to a system that executes a user level scheduler.
  • a thread a executing a user level scheduler operating on processor A may also be preempted by an interrupt.
  • thread a is preempted with the task queue locked, other threads can not perform scheduling until thread a returns to its interrupt handling capability and the lock is released.
  • each processor should be included in each processing unit.
  • These processing units can be divided into PPU (Power Process Unit) and SPU (Synergistic Processing Unit). All of the SPUs may be implemented using the same architecture or may have different configurations.
  • the PPU may be located locally to the SPU, eg on the same chip as the SPU, on the same package, on the same circuit board, on the same product, or remotely on the SPU, eg on the bus or the Internet. It may be located in different products that can be connected via communication networks, etc. Similarly, SPUs may be located locally or remotely from one another.
  • the multiprocessor system shown in FIG. 9 includes a plurality of processing units 110 and a main memory 130, which are connected to a main bus 120.
  • Each processing unit 110 includes a processor 112, a local memory 114, and a memory control unit 116.
  • Processor 112 can read and write data to local memory 114.
  • the memory control unit 116 is an interface for referring to data in the local memory 114 from the processors 112 of other processing units 110. In addition to providing a phase, it also provides memory synchronization and exclusive control functions.
  • thread group 1 includes three threads thla, thlb, and t hlc.
  • Thread group 2 includes one thread th2a. Even if there is only one such thread, it is treated as a thread group.
  • thread group 3 includes two threads th3a and th3b.
  • Thread group 4 includes one thread th4a.
  • Scheduling of these threads is performed on the condition that all threads belonging to the same thread group are simultaneously assigned to any processor 112.
  • the first thread group is assigned to the processor 112
  • One or two of the three threads thla, thlb, thlc are assigned to the processor 112 and the rest are saved in the main memory 130, so no situation is created.
  • FIG. 11 is a diagram for explaining how threads are assigned to the processor 112 in units of thread groups. This figure shows the assignment of threads belonging to the four thread groups shown in FIG. 10 to the processors 112 in a multiprocessor system having four processors in total.
  • three threads t hla, thlb, and thlc belonging to the first thread group are respectively assigned to the first processor, the second processor, and the third processor, and one thread th2a belonging to the second thread group is Allocated to the 4th processor.
  • Two threads th3a and th3b belonging to the other third thread group and one thread th4a belonging to the fourth thread group are saved in the main memory 112.
  • a plurality of threads belonging to one thread group should be assigned to one of the processors at the same time.
  • the scheduling prohibition interval can be limited.
  • PPU thread The PPU thread (hereinafter referred to as PPU thread) and the SPU thread are asynchronously scheduled.
  • PPU thread In a user environment, if PPU and SPU threads share the same task queue, the following problems may occur. If one PPU thread gets locked on the task queue and is preempted by another PPU thread, the SPU thread has to wait until this PPU thread is re-executed, thus limiting the scheduling prohibited section. You will not be able to
  • thread information and thread entities are stored separately, and the processor may load only thread information when selecting which thread to execute.
  • the thread information is updated (specifically, the process of changing the identifier of the most recently executed thread to the identifier of the selected thread, and the identifier of the selected thread corresponding to the identifier) If the process of modifying the thread to indicate that it can not be executed is completed, the updated thread information is stored in the main memory. Then, while the processor copies the thread entity corresponding to the selected identifier, other processors can use thread information while copying. By doing this, since thread information is occupied by one processor in a short time, it is possible to reduce the decrease in processing efficiency of the entire system even if the thread information is locked.
  • the inventor proposes to hold the executability information as a bit string to which one bit is assigned as an identifier for each thread. By doing this, it is possible to perform thread selection, update of thread information, etc. using atomic operation and atomic instruction, and a task queue without lock operation, that is, a lockless task queue can be realized. If there is no lock operation, each problem caused by the task queue lock described above is solved.
  • FIG. 1 shows the configuration of a multiprocessor system 100 according to an embodiment of the present invention.
  • the multiprocessor system 100 has a plurality of processing units 10 and a main memory 30, which are connected to the main bus 20.
  • Each processing unit 10 includes a processor 12, a memory 14, and a memory control unit 16.
  • the processor 12 can read and write data to the local memory 14.
  • the memory control unit 16 provides an interface for referring to data in the local memory 14 from the processor 12 of another processing unit 10, and also provides a function of memory synchronization and exclusive control.
  • Any one of the processing units 10 plays the role of a service unit for other processing units with respect to thread scheduling. As the role of the service unit
  • the allocation of the main memory 30 and the first memory related to a thread in the main memory 30 can be, for example, to determine an area to be allocated to thread information, a capacity of the area, or a memory capacity to be allocated to an entity of a thread.
  • this service unit may be in charge of any processing unit 10.
  • one thread operates in each processor 12, and a plurality of threads are executed in parallel in the entire multiprocessor system 100.
  • a thread operating in each processor 12 can occupy and use all the resources such as the local memory 14 in the processing unit 10 and the registers in the memory control unit 16.
  • the context of a thread is the state of all resources it occupies within the processing unit 10 in which the thread was executed, the set of values held in various registers when the thread is running on the processor 12, local memory The data stored in 14 and the internal states of various registers of the memory control unit 16 are shown.
  • the context of the thread is copied to main memory 30, and when it can be processed again by processor 12, the context is read from main memory 30 and processed. Can continue.
  • the context of a thread corresponds to a thread entity.
  • FIG. 2 shows information on threads stored by the main memory 30. These pieces of information are thread information 40, thread address information 50, and thread entities 60, and play a role of task queue in the multiprocessor system 100. The area in which the information is stored is allocated by the service unit and notified to the other processing units 10.
  • the thread information 40 includes executability information and latest execution information.
  • the executability information associates the identifier given to each thread with the information indicating whether or not each thread is ready to execute.
  • Figure 3 details thread information 40 Indicates
  • the bit string (isSchedulable) is executability information, and 1 bit contained in it corresponds to one thread, and the bit number corresponds to the thread number.
  • the multiprocessor system 100 uses the bit number itself as the thread number to simplify the process.
  • each bit of the bit string isSchedulable indicates whether or not the thread corresponding to that bit is in an executable state.
  • the bit value "1" indicates that execution is possible, and "0" indicates that execution is not possible.
  • the number of bits included in the bit string isSchedulable corresponds to the capacity of the area allocated for holding the executability information, and is 128 bits in this case.
  • lastScheduled is a variable that takes an integer value indicating the number of the most recently executed bit among the bits included in the bit string isSchedulable.
  • isSchedulable and lastScheduled indicate the number of executable threads and the number of the most recently executed thread.
  • there are three bits (bits indicated by arrows B, C, and D in the figure) of the bit string isSche dulable, and the thread corresponding to these three bit numbers is executed. It is a possible thread. The threads corresponding to those other bits whose value is "0" are not executable. Also, the thread corresponding to the bit number (the number of the bit indicated by the arrow A in the figure), which is equal to the value of lastSchedu led, is the thread that has been executed most recently, and its state is not executable.
  • the thread address information 50 corresponds to the number of each thread.
  • the number of the bit included in the bit string isSchedulable is associated with the start address of the area in which the thread entity corresponding to the number is stored.
  • the service unit determines which number thread entity to store in which address area.
  • the thread waiting for processing is in the state! /, And the value of each bit of the bit string isSchedulable of the thread information 40 is “0”.
  • Processing of the processing unit 10 proceeds and a thread is generated.
  • the generated thread is also executed by any processing unit 10.
  • the task queue is used when a thread waiting for processing occurs.
  • a process of selecting a thread to be executed next by the processing unit 10 and a process of updating thread information associated with this selection will be described with reference to the flowchart of FIG.
  • each processing unit 10 of the multiprocessor system 100 has a thread being processed and there are three executable threads waiting to be processed. Each entity is stored in the main memory 30.
  • the processor 12 of the processing unit 10 selects a bit string included in the thread information 40 in order to select a thread to be executed next.
  • the processing unit 10 performs processing related to the thread information 40 using an atomic command.
  • "lwarx" or “getllar” is used as a command for loading the thread information 40.
  • the bit string isSchedulable shown in column A of FIG. 6 is the bit string isSche dulable shown in FIG.
  • the processor 12 causes the loaded bit string isSchedulable (bit string shown in column A of FIG. 6) to have an arrow with its numbered bit equal to the value of lastScheduled (bit indicated by arrow A1 in FIG. 6). It rotates in the direction indicated by L, that is, in the left direction (S14). As a result, the bit string isSchedulable in the A column of FIG. 6 becomes the bit string isSchedulable in the B column of FIG.
  • bit of the (lastScheduled + 1) number (the bit indicated by the arrow B1) is located at the beginning of the force bit string isSchedulable, and the bit of the lastScheduled number (the bit indicated by the arrow B3) is the end of the bit string isSchedulable. become.
  • the processor 12 sequentially searches the bit string isSchedulable, which has been rotated, from the top for bits having the value “1”, and detects the bit detected first (the bit indicated by the arrow B2).
  • the number is obtained as the number of the thread to be executed next (S 18).
  • “Count Leading Zero” can be used which counts the number of bits having a value of “0” which is continuous with the leading power of the bit string isSchedulable. "The value obtained by adding (lastScheduled + 1) to the value obtained by Count L eiding ZeroJ (4 in the example of bit string isSchedulable in column B shown in FIG. 6) is selected as the number of the thread to be executed next. Ru.
  • the processor 12 sets the value of the bit of the selected number to “0”, sets the last Scheduled to this number, and updates the thread information 40 (S20).
  • the updated thread information 40 is stored in the main memory 30 (S24).
  • the bit value is updated using the 128-bit bit string shown in column C of FIG.
  • the bit string in column C has 128 bits, and only the bit of the same number as the number selected in step S18 (the bit indicated by arrow C1) has a value of "1".
  • the processor 12 updates the bit string isSchedulable of the B column by calculating the bit string isSchedulable of the B column of FIG. 6 and the bit string of the C column by the “AtomicAndc” command.
  • the command for storing the updated bit string isSchedulable can be, for example, "stwcx" or "putllc".
  • Column D in FIG. 6 shows updated thread information 40.
  • the bit selected as the thread to be executed next (the bit indicated by the arrow D1) is a bit indicating the most recently executed thread, and its value is changed from “1" to "0".
  • the processor 12 refers to the thread address information 50 to obtain the start address of the thread entity 60 corresponding to the selected thread, and the area strength indicated by the start address. Are loaded into the local memory 14 and processed.
  • the processor 12 of the processing unit 10 loads the bit string isSchedulable included in the thread information 40 into the local memory 14 in order to add a newly executable thread to the task queue (S50).
  • This bit string isSchedulable is, for example, a bit string isSchedulable shown in column A of FIG.
  • the processor 12 selects the number of any bit (for example, the bit indicated by the arrow A1) having the value “0” among the bits of the bit string isSchedulable of column A as the bit number of the thread to be added. .
  • the processor 12 calculates the bit string isSchedulable in the A column and the bit string shown in the B column by the “AtomicOr” command to obtain a bit string isSchedulable shown in the C column (S 54).
  • the bit string shown in column B of FIG. 8 has 128 bits, and only the bit of the same number as the number selected by the processor 12 (the bit indicated by the arrow B1) has a value of “1”.
  • processor 12 receives the bit string isSchedulable obtained in step S54 (FIG. 8).
  • the bit string of column C) is stored in the main memory 30, and updating of the thread information 40 for adding a thread is completed (S58).
  • the processor 12 copies the entity of the thread to be added to the area assigned to the bit number selected in step S54, and ends the process of adding a thread.
  • thread information and thread entities are divided and stored, and it is possible to select and update threads using only thread information, so that more efficient Good, realizing a multiprocessor system.
  • the multiprocessor system 100 shown in FIG. 1 is a multiprocessor system using only the kernel scheduler, but the scheduling method used for the multiprocessor system 100 operates on each processor.
  • the present invention can also be applied to a system using a user level scheduler implemented on a thread. In that case, it is possible to eliminate the dilemma as to whether or not to receive an interrupt during scheduling, and to solve the problem caused by using the user level scheduler described above.
  • the present invention has been described above based on the embodiments. The embodiment is an exemplification, and it is to be understood by those skilled in the art that a combination of each component and each processing process is possible, and that various modifications are possible, and such a modification is also within the scope of the present invention. It is understood.
  • FIG. 1 is a system in which each processor performs scheduling autonomously
  • the scheduling method of the present invention is not limited to such a system, and for example, it may be performed by one management unit. It can be applied to the scheduling system.
  • a device to which the present invention is applied is also within the scope of the present invention.
  • These devices include not only personal computers and servers, but also cell phones, game consoles, commodity computers, personal digital assistants (PDAs), digital televisions, etc.
  • PDAs personal digital assistants
  • the present invention is applicable to electronic devices such as computers, mobile phones, and game machines that process a plurality of processes in parallel.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Multi Processors (AREA)
  • Memory System Of A Hierarchy Structure (AREA)

Abstract

 図1において、スレッド情報をメインメモリ30に保持する。スレッド情報はビット列と直近実行情報を含む。ビット列の各ビットはそれぞれ1つのスレッドに割り当てられており、ビットの番号と値はそれぞれスレッドの番号と、スレッドが実行可能な状態にあるか否かを示す。直近実行情報は直近に実行されたスレッドの番号である。プロセッサ12は、直近に実行されたスレッドを示すビットがビット列の末尾になるようにビット列をローテートし、ローテートされたビット列の先頭から順に、実行可能状態にあるスレッドに対応するビットを検索し、最も先に得たビットの番号を、次に実行するスレッドの番号として選出する。そして、この番号のビットの値を、実行不可であることを示すように変更するとともに、直近実行情報を、このビットの番号にセットしてスレッド情報を更新する。この操作は、アトミックコマンドを用いてなされる。

Description

明 細 書
スケジューリング方法およびスケジューリング装置
技術分野
[0001] 本発明は、マルチプロセッサシステムにおける並列処理の実行単位のスケジユーリ ング方法および装置に関する。
背景技術
[0002] 最近のマルチタスクをサポートするオペレーティングシステムは、複数のプロセスを 同時に実行することができるマルチタスク環境を実現するとともに、これらのプロセス がプロセス内部で複数のスレッドを生成して並行処理を行うことができるマルチスレツ ド技術を搭載して ヽる。プロセスは実行時に固有のリソースやアドレス空間が割り当て られ、他のプロセスの領域にアクセスすることができない。これに対してスレッドは、プ ロセス内部で生成される実行単位であり、各スレッドはプロセス内の領域に互いに自 由にアクセスすることができる。スレッドは、オペレーティングシステムが CPU (Centr al Processing Unit)の実行時間を割り当てる基本的な実行単位となる。本明細 書にぉ 、て、スレッドの割り当てをスケジューリングと!/、う。
[0003] 1つのシステム内に複数のプロセッサを搭載したマルチプロセッサシステムでは、並 列に、あるいは協調して処理を実行して処理全体の高速ィ匕を図ることができる。通常 、マルチプロセッサシステムにおいて、共有メモリにタスクキューと呼ばれる待ち行列 に実行可能なスレッドが保持される。これらのスレッドは 、ずれかのプロセッサに割り 当てられて、実行される。スレッドを割り当てる方法によって、プロセスの実行速度ゃメ モリ消費量などの性能が変わってくるため、マルチプロセッサシステムでは、シングル プロセッサシステムにおけるスケジューリングと異なった工夫が必要となる。
[0004] マルチプロセッサシステムにおけるスケジューリングについて、たとえば、スレッドを 管理する役割を担う管理ユニットが各プロセッサと通信し、それぞれのプロセッサに 割り当てるスレッドをスケジューリングする方法が考えられる。
[0005] 管理ユニットによってスケジューリングを行うこの方法では、管理ユニットとプロセッ サ間の通信において、メッセージ遅延が起きることが多ぐスレッドの実行を遅延させ てしまうという問題がある。この問題を解決するために、各プロセッサによって自己支 配的にスケジューリングする方法が考えられる。この方法では各プロセッサ上でおの おのスケジューラを実行し、共有メモリにあるタスクキューにアクセスして、実行するス レッドを選択する。
[0006] この方法では、各プロセッサがスケジューラを実行している間、すなわちスケジユー リング中において、共有メモリ上のタスクキューが他のプロセッサによって修正される ことを防ぐために、スケジューラがタスクキューをロックする。この間、割り込みを禁止 するか否かはシステムの設計者にとってジレンマである。
[0007] スケジューリング中に割り込みを禁止しない場合には、スケジューラがタスクキュー をロックしている最中に、割り込みを受け付けてしまう。この場合、割り込み処理が終 了し、ロックが開放されるまで、スケジューリングが実行されない結果になってしまい、 システムの効率低下につながる。
[0008] 一方、スケジューリング中に割り込みを禁止すると、システムの割り込み応答性能が 低下してしまう問題がある。これらの問題はこれまで述べたマルチプロセッサ上で動 作するカーネルスケジューラだけの問題でなぐマルチプロセッサ 'マルチスレッド環 境でのユーザレベルスケジューラ(すなわち、各プロセッサで動作するスレッド上でス ケジユーラを実行することで、ユーザレベルにお 、てマルチスレッドを実現する方式) の場合も同様である。
[0009] 特に、ユーザレベルスケジューラを実行しているカーネルスレッドは各プロセッサ上 のカーネルレベルスケジューラによってスケジューリングされ、他のカーネルスレッド によってプリェンブト (横取り)される可能性があるため、タスクキューのロックはより深 刻な問題を引き起しかねない。この場合、横取りされた際にそのカーネルスレッドで 動作するユーザレベルスケジューラがロックを取得して 、た場合には、他のプロセッ サのスレッド上で動作するユーザレベルスケジューラがロックが解除されるまでスケジ ユーリングすることができなくなる。
発明の開示
発明が解決しょうとする課題
[0010] 本発明は上記事情に鑑みてなされたものであり、その目的は、マルチプロセッサシ ステムにおける並列処理の実行単位をプロセッサに割り当てる順序を制御して処理 効率を向上させることができるスケジューリング技術を提供することにある。
課題を解決するための手段
[0011] 本発明に力かる態様は、マルチプロセッサシステムにおいて、プロセッサの実行対 象となる実行単位をスケジューリングする方法に関する。このスケジューリング方法は 、マルチプロセッサシステムに含まれる複数のプロセッサの実行対象となる各実行単 位に識別子を付与し、各実行単位のそれぞれが実行可能な状態にある力ゝ否カゝを実 行単位の識別子に対応づけて示す実行可否情報と、各実行単位のうちの、直近に 実行された実行単位の識別子を示す直近実行情報とを含む実行単位情報を保持す る。そして、実行単位情報に基づいて、直近に実行された実行単位の識別子以外の 識別子を優先的に選出する制約の下でいずれかの実行可能な実行単位の識別子 を、プロセッサによって実行される実行単位の識別子として選出するとともに、実行単 位情報を更新する。
[0012] 本発明のこの態様は、管理ユニットによってスケジューリングするシステムに適用し てもよく、各プロセッサ自身によってスケジューリングを行うシステムに適用してもよい
[0013] また、本発明のこの態様は、各プロセッサ上で直接動作するスケジューラだけでは なぐ各プロセッサ上のスケジューラが提供するスレッド上で動作するユーザレベルス ケジユーリングを用いるシステムに適用してもよい。
[0014] ここで、実行可否情報は、各実行単位について識別子として 1ビットを割り当てたビ ット列として保持され、ビットの選出および実行単位情報の更新を不可分操作、すな わちアトミック操作によって行うようにしてもょ ヽ。
[0015] 「不可分操作」は、これ以上分割できな 、最小単位の操作を意味し、マルチプロセ ッサシステムにおいて、他のプロセッサが行う操作との相互作用なしに実行されること が保証される操作である。
[0016] なお、以上の構成要素の任意の組合せ、本発明をシステム、プログラム、プログラム を記憶した記憶媒体として表現したものも、本発明の態様としては有効である。
発明の効果 [0017] 本発明は、マルチプロセッサシステムにおける並列処理の実行単位をスケジユーリ ングすることにお 、て有利である。
図面の簡単な説明
[0018] [図 1]本発明に力かる実施形態のマルチプロセッサシステムを示す図である。
[図 2]図 1に示すマルチプロセッサシステムのタスクキューを示す図である。
[図 3]図 2に示すタスクキューに含まれるスレッド情報の構成を示す図である。
[図 4]図 3に示すスレッド情報の詳細を説明するための図である。
[図 5]プロセッサによりスレッドを選出する処理を示すフローチャートである。
[図 6]図 5に示す処理に伴うスレッド情報の変化を示す図である。
[図 7]プロセッサによりスレッドを追加する処理を示すフローチャートである。
[図 8]図 7に示す処理に伴うスレッド情報の変化を示す図である。
[図 9]ユーザレベルスケジューラを用いるマルチプロセッサシステムの例を示す図で ある。
[図 10]図 9に示すマルチプロセッサシステムにおけるスレッドのグルーピング例を示す 図である。
[図 11]図 9に示すマルチプロセッサシステムにおけるスレッドのスケジューリング例を 示す図である。
符号の説明
[0019] 10…処理ユニット、 12· ··プロセッサ、 14…ローカルメモリ、 16· ··メモリ制御部、
20· ··メインバス、 30· "メインメモリ、 40· ··スレッド情報、 50· ··スレッドアドレス情 報、 60…スレッド実体、 100…マルチプロセッサシステム、 110…処理ユニット、 112…プロセッサ、 114· ··メモリ制御部、 120· ··メインバス、 130· "メインメモリ 発明を実施するための最良の形態
[0020] マルチプロセッサシステムにおいて、各プロセッサの実行単位たとえばスレッドのス ケジユーリング中に、スレッドを記憶したタスク一キューがほかのプロセッサにより修正 されることを防ぐために、タスクキューをロックする必要があった。
[0021] このロックによって、スケジューリング中に、割り込みを禁止するとシステムの割り込 み応答性能が低下し、割り込みを禁止しないと、割り込み処理が終わり、ロックが解除 されるまでスケジューリングができな 、と!/、うジレンマがあった。
[0022] 上述した問題を解決するために、本発明者は、下記の技術を提案する。
[0023] 各スレッドに識別子を付与し、これらのスレッドのそれぞれが実行可能な状態にある か否かをスレッドの識別子に対応づけて示す実行可否情報と、各スレッドのうちの、 直近に実行されたスレッドの識別子を示す直近実行情報とを含むスレッド情報を保 持する。そして、スレッド情報に基づいて、直近に実行されたスレッドの識別子以外の 識別子を優先的に選出するという制約の下で、いずれかの実行可能なスレッドの識 別子を、プロセッサに割り当てるスレッドの識別子として選出する。
[0024] ここで、スレッドの実体 (以下スレッド実体と!/、う)を、プロセッサが選出された識別子 に基づ!/、て取得することができる 、かなる方法で保持してもよ 、。たとえばスレッド実 体を識別子と対応づけて保存するようにしてもよ!ヽし、各スレッド実体をメモリのそれ ぞれの所定の領域に保存するとともに、スレッド実体が保存された領域の開始アドレ スとその識別子とを対応づけてメモリに保存するようにしてもょ 、。
[0025] この技術は、スレッド実体と、いずれのスレッドを実行するかの選出を行うために必 要なスレッド情報とに分けてメモリに保存する。そのために、スケジューリングする際に 当たって、スレッド実体を記憶した領域をロックする必要がなぐスケジューリング中に 割り込みを禁止する力否かのジレンマを解消することができる。
[0026] この技術は、ユーザレベルスケジューラを実行するシステムにおいても、上記ジレン マを解消することができるとともに、ユーザレベルスケジューラゆえの問題も解決する ことができる。
[0027] たとえば、マルチプロセッサシステム、特に OS (オペレーティングシステム)機能を 実行できるプロセッサが限られるような非対称のマルチプロセッサシステムにおいて は、各プロセッサで動作する OSが提供するカーネルスレッド上にユーザレベルスレツ ドを作成して、自己支配的にスケジューリングする方法、すなわちユーザレベルスケ ジユーラを用いる方法は、マルチプロセッサシステムの処理効率を向上させる有効な 方法であると考えられる。この方法では、ユーザレベルスケジューラを用いることに起 因するスケジューリングの破淀と ヽぅ問題がある。 [0028] たとえば、ユーザレベルスケジューラを実行しているスレッドは、各プロセッサの上の カーネルスケジューラによってスケジューリングされ、ほかのカーネルスレッドによって プリェンブトされる可能性がある。そのため、プリェンブトされた際にそのスレッドで動 作するユーザレベルスケジューラがロックを取得して 、た場合には、ほかのプロセッ サのスレッド上で動作するユーザレベルスケジューラがロックが解除されるまで、スケ ジユーリングができなくなり、プロセッサの処理効率を下げてしまう。さらに、ロックが解 除されるまでの時間は、状況に依存してしまい、見積もることが困難になるため、シス テムの不安定を引き起こす原因にもなりえる。
[0029] ここで、マルチプロセッサシステムにお 、て各プロセッサが自律的に動作するカー ネルスケジューラを実行する従来のシステムについて考える。タスクキューにスレッド 1、スレッド 2、スレッド 3が入っており、複数のプロセッサのうちのプロセッサ Aは、タス クキューにあるスレッドを実行することができる状態になった場合を想定する。
[0030] プロセッサ Aは、実行するスレッドを選出するために、タスクキューをー且自分の口 一カルメモリにコピーし、タスクキュー力も例えばスレッド 1を選出した後に、タスクキュ 一からスレッド 1を削除する更新処理を行って、更新されたタスクキューをメインメモリ に書き戻す。タスクキューのコピーが開始するときから、タスクキューの書戻しが終了 するまでの間、共有メモリ上のタスクキューが他のプロセッサによって修正されることを 防ぐために、タスクキューをロックする。タスクキューがロックされている間、他のプロセ ッサは、タスクキューに入ったスレッドを実行できる状態になったとしても、タスクキュ 一を利用することができないため、ロックの期間が長いほどシステムの処理効率が低 下する。
[0031] また、プロセッサ Aで動作するスケジューラは前述したように割り込みによってプリエ ンプトされる可能性がある。プロセッサ Aがタスクキューをロックした状態でプリェンプ トされると、ほかのプロセッサは、プロセッサ Aが割り込み処理力も復帰し、ロックが解 除されるまでスケジューリングを行うことができず、スレッド 2、 3を実行することが不可 能となる。これでは、システムは処理効率が低下するとともに、不安定にもなりかねな い。
なお、上記説明は、プロセッサ A、 · · ·を、プロセッサ A、 · · ·上で動作するユーザレ ベルスケジューラを実行するスレッド(たとえばスレッド a、 · · ·)に置き換えれば、ユー ザレベルスケジューラを実行するシステムにも適用することができる。具体的には、ュ 一ザレベルスケジューラを実行するシステムにお 、て、たとえばプロセッサ A上で動 作するユーザレベルスケジューラを実行するスレッド aも、割り込みによってプリェンプ トされる可能性がある。スレッド aが、タスクキューがロックされた状態でプリェンブトさ れると、ほかのスレッドは、スレッド aが割り込み処理力 復帰し、ロックが解除されるま でスケジューリングを行うことができない。すなわち、ユーザレベルスケジューラを用い るシステムにおいても同じように、タスクキューのロック起因して、システムは処理効率 が低下し、不安定になりかねない問題がある。
[0032] また、マルチプロセッサシステムにお 、ては、各々のプロセッサがそれぞれの処理 ユニットに含まれる开で存在する。これらの処理ユニットは PPU (Power Processin g Unit)と SPU (Synergistic Processing Unit)とに分けることができる。 SPU のすべてが同一のアーキテクチャを用いて実現されてもよぐそれぞれ異なる構成を 有してもよい。 PPUは、 SPUに対してローカルに、たとえば SPUと同一のチップ、同 一のパッケージ、同一の回路基板、同一の製品に位置してもよいし、 SPUに対してリ モートに、たとえばバスやインターネットなどの通信ネットワークを介して接続可能な 異なる製品に位置してもよい。同様に、 SPUは、互いにローカルにまたはリモートに 位置してちょい。
[0033] スケジューリング禁止区間の存在と禁止時間の見積もりの困難さはマルチプロセッ サシステムの処理効率を下げる要因になる。ユーザレベルスケジューラを実行するス レッドのすべてが SPUのスレッド(以下 SPUスレッドという)であれば、この問題を解決 する方法としては、スレッドをグループ化してグループ単位でスケジューリングする方 法が考えられる。ここで、図 9に示すマルチプロセッサシステムを例にして説明する。
[0034] 図 9に示すマルチプロセッサシステムは、複数の処理ユニット 110とメインメモリ 130 と有し、それらはメインバス 120に接続されている。各処理ユニット 110は、プロセッサ 112、ローカルメモリ 114、メモリ制御部 116を有する。プロセッサ 112は、ローカルメ モリ 114に対してデータを読み書きすることができる。メモリ制御部 116は、他の処理 ユニット 110のプロセッサ 112からローカルメモリ 114のデータを参照するときのインタ 一フェースを与えるとともに、メモリの同期、排他制御の機能を提供する。
[0035] ここで、メインメモリ 130に設けられたタスクキューに SPUスレッドのみが記憶されて いる場面について考える。この場合、タスクキュー内のスレッドが図 10に示すようにグ ルーピングされる。図 10において、スレッドグループ 1は 3つのスレッド thla、 thlb、 t hlcを含む。スレッドグループ 2は、 1つのスレッド th2aを含む。このようなスレッドが 1 つだけの場合もスレッドグループとして扱う。同様に、スレッドグループ 3は、 2つのス レッド th3a、 th3bを含む。スレッドグループ 4は、 1つのスレッド th4aを含む。
[0036] これらのスレッドのスケジューリングは、同一スレッドグループに属するすべてのスレ ッドを同時にいずれかのプロセッサ 112に割り当てることを条件として行われる。第 1 スレッドグループがプロセッサ 112に割り当てられるときは、第 1スレッドグループに属 する 3つのスレッド thla、 thlb、 thlcが同時にいずれかのプロセッサ 112に割り当て ることができる場合に限られる。 3つのスレッド thla、 thlb、 thlcの 1つまたは 2つが プロセッサ 112に割り当てられ、残りがメインメモリ 130に退避して 、る t 、う状況は作 らない。
[0037] 図 11は、スレッドグループ単位でスレッドがプロセッサ 112に割り当てられる様子を 説明する図である。同図は、プロセッサ総数 4のマルチプロセッサシステムにおいて、 図 10に示した 4つのスレッドグループに属するスレッドのプロセッサ 112への割り当て 状態を示している。ある時刻において、第 1スレッドグループに属する 3つのスレッド t hla、 thlb、 thlcは、それぞれ第 1プロセッサ、第 2プロセッサ、第 3プロセッサに割り 当てられ、第 2スレッドグループに属する 1つのスレッド th2aは、第 4プロセッサに割り 当てられている。それ以外の第 3スレッドグループに属する 2つのスレッド th3a、 th3b 、および第 4スレッドグループに属する 1つのスレッド th4aはメインメモリ 112に退避さ れている。
[0038] このようなシステムによれば、 1つのスレッドグループ内に所属する複数のスレッドを 必ず同時に 、ずれかのプロセッサに割り当てるようにする。スレッドグループ内にお いて、ロックを取ったスレッドだけがプリェンブトされることがないため、スケジユーリン グの禁止区間を限定することができる。
[0039] し力し、 PPUのスレッド(以下 PPUスレッドという)と SPUスレッドが非同期にスケジ ユーリングされる環境では、 PPUスレッドと SPUスレッドで同じタスクキューを共有した 場合には下記の問題が生じうる。ある PPUスレッドがタスクキューのロックを取ったま ま他の PPUスレッドにプリェンブトされると、 SPUスレッドはこの PPUスレッドが再実 行されるまで待たざるを得ないため、スケジューリングの禁止区間を限定することがで きなくなってしまう。
[0040] 本発明者が提案したスケジューリング技術は、スレッド情報とスレッド実体を分けて 保存し、プロセッサは、いずれのスレッドを実行するかの選出を行う際、スレッド情報 のみをロードすればよい。選出を終え、スレッド情報の更新 (具体的には、直近に実 行されたスレッドの識別子を、選出されたスレッドの識別子に変更する処理と、選出さ れたスレッドの識別子を該識別子の対応するスレッドが実行不可であることを示すよう に修正する処理)を終了すれば、更新されたスレッド情報をメインメモリにストアする。 その後、プロセッサは、選出した識別子に対応するスレッド実体をコピーする力 コピ 一する間、他のプロセッサは、スレッド情報を利用することができる。こうすることによつ て、スレッド情報は 1つのプロセッサに占有される時間が短いため、スレッド情報をロッ クしたとしても、システム全体の処理効率の低下を軽減させることができる。
[0041] さらに、本発明者は、実行可否情報を、各スレッドについて識別子として 1ビットを割 り当てたビット列として保持することを提案する。こうすることによって、スレッドの選出 、スレッド情報の更新などを、アトミック操作やアトミック命令を用いて行うことができ、 ロック操作を伴わな 、すなわちロックレスのタスクキューを実現することができる。ロッ ク操作がなければ、上述した、タスクキューのロックに起因するおのおのの問題も解 消される。
[0042] 図 1は、本発明の実施形態となるマルチプロセッサシステム 100の構成を示す。マ ルチプロセッサシステム 100は、複数の処理ユニット 10とメインメモリ 30とを有し、そ れらはメインバス 20に接続されている。各処理ユニット 10は、プロセッサ 12、ロー力 ルメモリ 14、メモリ制御部 16を有する。プロセッサ 12は、ローカルメモリ 14に対してデ ータを読み書きすることができる。メモリ制御部 16は、他の処理ユニット 10のプロセッ サ 12からローカルメモリ 14のデータを参照するときのインターフェースを与えるととも に、メモリの同期、排他制御の機能を提供する。 [0043] 処理ユニット 10のうちのいずれか 1つは、スレッドのスケジューリングに関して他の 処理ユニットに対するサービスユニットの役割を担う。サービスユニットの役割としては
、たとえばメインメモリ 30の割当てや、メインメモリ 30内のスレッドに関する最初の記 憶に関わることなどである。メインメモリ 30の割当ては、たとえばスレッド情報に割り当 てられる領域、領域の容量や、スレッドの実体に割り当てられるべきメモリ容量を決定 することなどとすることができる。
[0044] なお、このサービスユニットは、いずれの処理ユニット 10によって担当されてもよい。
[0045] ある時刻において、各プロセッサ 12には 1つのスレッドが動作し、マルチプロセッサ システム 100全体で並列に複数のスレッドが実行される。各プロセッサ 12において動 作しているスレッドは、処理ユニット 10内のローカルメモリ 14やメモリ制御部 16内のレ ジスタなどのすべての資源を占有して使用することができる。
[0046] この状態において、処理待ちしているスレッドは、そのコンテキストがメインメモリ 30 に保持される。スレッドのコンテキストは、そのスレッドが実行された処理ユニット 10内 で占有するすべての資源の状態であり、スレッドがプロセッサ 12において動作してい るときに各種レジスタに保持されている値の集合、ローカルメモリ 14に保持されたデ ータ、メモリ制御部 16の各種レジスタの内部状態などである。スレッドがプロセッサ 12 上で動作していないときは、そのスレッドのコンテキストをメインメモリ 30にコピーして おき、再度プロセッサ 12によって処理可能となったときに、そのコンテキストをメインメ モリ 30から読み込んで、処理を継続することができる。スレッドのコンテキストは、スレ ッド実体に該当する。
[0047] 図 2は、メインメモリ 30により記憶された、スレッドに関する情報を示す。これらの情 報は、スレッド情報 40、スレッドアドレス情報 50と、スレッド実体 60であり、マルチプロ セッサシステム 100におけるタスクキューの役割を担う。なお、これらの情報が記憶さ れる領域は、サービスユニットによって割り当てられ、ほかの処理ユニット 10に通知さ れる。
[0048] スレッド情報 40は、実行可否情報と直近実行情報とを含む。実行可否情報は、各 スレッドに対してそれぞれ付与された識別子を、それぞれのスレッドが実行可能な状 態にあるカゝ否かを示す情報に対応づけたものである。図 3は、スレッド情報 40の詳細 を示す。
[0049] ビット列(isSchedulable)は、実行可否情報であり、それに含まれる 1ビットが 1つの スレッドに対応し、ビット番号はスレッドの番号に対応する。なお、マルチプロセッサシ ステム 100は、ビット番号そのものをスレッドの番号として用いて処理の簡潔化を図る
[0050] ビット列 isSchedulableの各ビットの値はそのビットに対応するスレッドが実行可能 状態にある力否かを示している。ここで、ビットの値の「1」は実行可能であることを示し 、「0」は実行不可であることを示すようにされている。ビット列 isSchedulableに含ま れるビットの数は、実行可否情報の保持用に割り当てられた領域の容量に相当し、こ こでは 128ビットとする。
[0051] lastScheduledは、ビット列 isSchedulableに含まれる各ビットのうち、直近に実行 されたビットの番号を示す整数値を取る変数である。
[0052] isSchedulableと lastScheduledによって、図 4の例のように、実行可能なスレッド の番号、直近に実行されたスレッドの番号が示される。図 4の例では、ビット列 isSche dulableのうち、値力「1」であるビット(図中矢印 B、 C、 Dが示すビット)が 3つあり、こ の 3つのビット番号に対応するスレッドは実行可能スレッドである。値が「0」であるほか のビットについて、それらに対応するスレッドは、実行不可である。また、 lastSchedu ledの値に等し 、ビット番号(図中矢印 Aが示すビットの番号)に対応するスレッドは、 直近に実行されたスレッドであり、その状態は実行不可である。
[0053] スレッドアドレス情報 50は、各スレッドの番号ここではビット列 isSchedulableに含ま れるビットの番号と、その番号に対応するスレッドの実体が保存された領域の開始ァ ドレスとを対応づけたものである。どの番号のスレッド実体を、どのアドレスの領域に 保存するかについては、サービスユニットによって決められる。
[0054] 処理待ちのスレッドがな!/、状態にぉ 、て、スレッド情報 40のビット列 isSchedulable の各ビットの値が「0」である。
[0055] 処理ユニット 10の処理が進み、スレッドが生成される。生成されたスレッドは、またい ずれかの処理ユニット 10によって実行される。処理待ちのスレッドが生じた際に、タス クキューが利用される。ここで、例として図 4に示すタスクキューの状態を起点にして、 処理ユニット 10が次に実行するスレッドを選出する処理、およびこの選出に伴うスレツ ド情報の更新処理を図 5のフローチャートを用いて説明する。
[0056] 図 4に示す状態では、マルチプロセッサシステム 100の各処理ユニット 10は、それ ぞれ処理中のスレッドがあり、処理待ちしている実行可能なスレッドは 3つあり、この 3 つのスレッドのそれぞれの実体は、メインメモリ 30に記憶されている。
[0057] この状態において、ある処理ユニット 10において、処理中のスレッドの処理が終了 すると、この処理ユニット 10のプロセッサ 12は、次に実行するスレッドを選出するため に、スレッド情報 40に含まれるビット列 isSchedulableと lastScheduledを、ローカル メモリ 14にロードする(S10)。マルチプロセッサシステム 100において、処理ユニット 10は、スレッド情報 40に関わる処理をアトミックコマンドを用いて行い、ここでは、スレ ッド情報 40をロードするためのコマンドとして、たとえば「lwarx」または「getllar」を用 いる。なお、図 6の A欄に示すビット列 isSchedulableは、図 4に示すビット列 isSche dulableである。
[0058] プロセッサ 12は、ロードしたビット列 isSchedulable (図 6の A欄に示すビット列)を、 lastScheduledの値に等しい番号のビット(図 6の矢印 A1が示すビット)が末尾にな るように、矢印 Lが示す方向、すなわち左方向にローテートする(S 14)。これによつて 、図 6の A欄のビット列 isSchedulableは、同図の B欄のビット列 isSchedulableにな る。図示のように、(lastScheduled+ 1)の番号のビット(矢印 B1が示すビット)力 ビ ット列 isSchedulableの先頭に位置し、 lastScheduledの番号のビット(矢印 B3が示 すビット)がビット列 isSchedulableの末尾になる。
[0059] プロセッサ 12は、続いてローテートされたビット列 isSchedulableに対して先頭から 順に、値力 「l」であるビットの検索を行い、最も先に検出したビット (矢印 B2が示すビ ット)の番号を、次に実行するスレッドの番号として得る(S 18)。ビットの検索に用いる コマンドとして、たとえばビット列 isSchedulableの先頭力も連続した、「0」の値を有 するビットの数を数える「Count Leading Zero」を用いることができる。「Count L eading ZeroJにより得られた値(図 6に示す B欄のビット列 isSchedulableの例では 4)に(lastScheduled + 1)を加算して得た値は、次に実行するスレッドの番号として 選出される。 [0060] そして、プロセッサ 12は、選出した番号のビットの値を「0」にセットするとともに、 last Scheduledをこの番号にセットして、スレッド情報 40の更新を行う(S20)。更新され たスレッド情報 40は、メインメモリ 30にストアされる(S24)。ここで、ビットの値の更新 は、図 6の C欄に示す 128ビットのビット列を用いて行う。 C欄のビット列は、 128ビット を有し、ステップ S 18において選択された番号と同じ番号のビット(矢印 C1が示すビ ット)のみが「1」の値を有する。プロセッサ 12は、図 6の B欄のビット列 isSchedulable と、 C欄のビット列とを、「AtomicAndc」コマンドで演算することによって B欄のビット 列 isSchedulableを更新する。また、更新されたビット列 isSchedulableのストアに用 V、るコマンドは、たとえば「stwcx」または「putllc」とすることができる。
[0061] 図 6の D欄は、更新されたスレッド情報 40を示す。ここで、次に実行するスレッドとし て選出されたビット (矢印 D1が示すビット)は、直近に実行されたスレッドを示すビット となり、その値が「1」から「0」になっている。
[0062] その後、プロセッサ 12は、スレッドアドレス情報 50を参照して、選出した番号のスレ ッドに対応するスレッド実体 60の開始アドレスを取得するとともに、この開始アドレス により示される領域力 スレッド実体 60をローカルメモリ 14にロードして処理する。
[0063] 次に図 7のフローチャートを用いて、タスクキューに実行可能となったスレッドを追カロ する処理につ!、て説明する。
[0064] 処理ユニット 10のプロセッサ 12は、新たに実行可能となったスレッドをタスクキュー に追加するために、スレッド情報 40に含まれるビット列 isSchedulableをローカルメモ リ 14にロードする(S50)。このビット列 isSchedulableはたとえば図 8の A欄に示すビ ット列 isSchedulableである。プロセッサ 12は、 A欄のビット列 isSchedulableの各ビ ットのうちの、値が「0」であるいずれかのビット(たとえば矢印 A1が示すビット)の番号 を、追加するスレッドのビット番号として選出する。そして、プロセッサ 12は、 A欄のビ ット列 isSchedulableと、 B欄に示すビット列とを「AtomicOr」コマンドで演算して C 欄に示すビット列 isSchedulableを得る(S54)。図 8の B欄に示すビット列は、 128ビ ットを有し、プロセッサ 12により選出された番号と同じ番号のビット (矢印 B1が示すビ ット)のみが「1」の値を有する。
[0065] 続いて、プロセッサ 12は、ステップ S54により得られたビット列 isSchedulable (図 8 の C欄のビット列)をメインメモリ 30にストアして、スレッドを追加するためのスレッド情 報 40の更新を終了する(S58)。
[0066] プロセッサ 12は、この後、追加するスレッドの実体を、ステップ S54において選出し たビット番号に対して割り当てられた領域にコピーして、スレッドを追加する処理を終 了する。
[0067] このように、図 1に示すマルチプロセッサシステム 100によれば、各プロセッサ 12自 身によって、タスクキューからスレッドを選出する処理、タスクキューを更新する処理を 行っているので、システム全体の処理効率を向上させることができる。
[0068] また、タスクキューを構成する際に、スレッド情報とスレッド実体とに分けて保存し、 スレッドの選出、更新は、スレッド情報のみを用いて行うことができるようにしたので、 より効率の良 、マルチプロセッサシステムを実現して 、る。
[0069] さらに、スレッド情報としてビット列 isSchedulableと、 lastScheduledとの 2つの変 数を用いることによって、スレッドの選出と更新を、アトミックコマンドで行うことを可能と した。これによつて、ロックレスのタスクキューを実現している。
[0070] ロックレスのタスクキューの実現により、スケジューリング中に割り込みを受け付ける か否かのジレンマを解消することができる。
[0071] また、直近に実行されたスレッドの情報が保持され、スレッドを選出する際に、直近 に実行されたスレッド以外のスレッドを優先的に選出するとともに、この選出に伴って 当該情報を更新する。これにより、直近に実行されたスレッドがまた実行可能になつ ても、他の実行可能なスレッドが優先的に実行されるため、スレッドのスケジユーリン グにお 、て重要な公平性を保つことができる。
[0072] ここで、図 1に示すマルチプロセッサシステム 100は、カーネルスケジューラのみを を用 、るマルチプロセッサシステムであるが、マルチプロセッサシステム 100に用いら れたスケジューリング方法は、各プロセッサ上で動作するスレッド上で実現されたュ 一ザレベルスケジューラを用いたシステムにも適用することができる。その場合、スケ ジユーリング中に割り込みを受け付けるか否かのジレンマを解消することができるとと もに、前述した、ユーザレベルスケジューラを用いることに起因する問題も解消するこ とがでさる。 [0073] 以上、本発明を実施の形態をもとに説明した。実施の形態は例示であり、それらの 各構成要素や各処理プロセスの組合せに 、ろ 、ろな変形例が可能なこと、またそうし た変形例も本発明の範囲にあることは当業者に理解されるところである。
[0074] また、図 1に示す実施形態は、各プロセッサが自律的にスケジューリングを行うシス テムであるが、本発明のスケジューリング方法は、このようなシステムに限らず、たとえ ばひとつの管理ユニットによってスケジューリングするシステムにも適用することがで きる。
[0075] また、本発明を適用したデバイスも、本発明の範囲にある。これらのデバイスには、 パーソナルコンピュータやサーバなどに限らず、携帯電話、ゲーム機、モノくイルコン ピュータ、個人携帯情報機器 (PDA)、デジタルテレビなどが含まれる。
産業上の利用可能性
[0076] 以上のように本発明は、複数のプロセスを並列に処理するコンピュータ、携帯電話 、ゲーム機器などの電子機器に利用可能である。

Claims

請求の範囲
[1] マルチプロセッサシステムに含まれる複数のプロセッサの実行対象となる各実行単 位に識別子を付与し、
各実行単位のそれぞれが実行可能な状態にあるカゝ否カゝを実行単位の識別子に対 応づけて示す実行可否情報と、各実行単位のうちの、直近に実行された実行単位の 識別子を示す直近実行情報とを含む実行単位情報を保持し、
実行単位情報に基づ 、て、直近に実行された実行単位の識別子以外の識別子を 優先的に選出する制約の下でいずれかの実行可能な実行単位の識別子を、プロセ ッサによって実行される実行単位の識別子として選出するとともに、実行単位情報を 更新することを特徴とするスケジューリング方法。
[2] 前記実行単位情報が、各プロセッサがアクセス可能なメモリに保持され、
前記選出および更新は、選出された識別子に対応する実行単位を実行するプロセ ッサ自身によって行われることを特徴とする請求項 1記載のスケジューリング方法。
[3] 実行可否情報は、各実行単位について識別子として 1ビットを割り当てたビット列と して保持され、
前記選出および更新は、不可分操作によって行われることを特徴とする請求項 1ま たは 2記載のスケジューリング方法。
[4] 直近に実行された実行単位に対応するビットが末尾になるようにビット列をローテ一 トし、
ローテートされたビット列の先頭力も順に実行可能な実行単位のビットを検索するこ とによって前記選出を行うことを特徴とする請求項 3記載のスケジューリング方法。
[5] 前記選出および更新は、選出された識別子に対応する実行単位を実行するプロセ ッサに対応するローカルメモリに前記実行単位情報をロードしたうえで行われ、 さらに、前記更新が完了した後、前記実行単位情報を前記メモリに格納することを特 徴とする請求項 2に記載のスケジューリング方法。
[6] 前記識別子と、当該識別子に対応する実行単位のコンテキストの前記メモリにおけ る格納先のアドレスとを対応づけたアドレス情報を前記メモリにさらに保持し、 前記実行単位情報を前記メモリに格納した後、前記アドレス情報を参照して、選出 された識別子に対応する実行単位のコンテキストを前記メモリから読み出すことにより 当該実行単位を実行することを特徴とする請求項 5に記載のスケジューリング方法。
[7] マルチプロセッサシステムに含まれる複数のプロセッサの実行対象となる各実行単 位のそれぞれが実行可能な状態にあるか否かを、それぞれの実行単位に対して付 与された識別子に対応づけて示す実行可否情報と、各実行単位のうちの、直近に実 行された実行単位の識別子を示す直近実行情報とを含む実行単位情報を保持する 実行単位情報保持部と、
前記実行単位情報に基づ!、て、直近に実行された実行単位の識別子以外の識別 子を優先的に選出する制約の下でいずれかの実行可能な実行単位の識別子を、プ 口セッサによって実行される実行単位の識別子として選出する実行単位選出部と、 前記選出に伴!ヽ、前記実行単位情報を更新する実行単位情報更新部とを備えるこ とを特徴とするスケジューリング装置。
[8] 前記実行単位情報保持部は、各プロセッサがアクセス可能なメモリに前記実行単 位情報を保持し、
前記実行単位選出部および前記実行単位情報更新部は、選出された識別子に対 応する実行単位を実行するプロセッサ自身により構成されることを特徴とする請求項 7記載のスケジューリング装置。
[9] 前記実行単位情報保持部は、実行可否情報を、各実行単位につ!、て識別子とし て 1ビットを割り当てたビット列として保持し、
前記実行単位選出部および前記実行単位情報更新部は、不可分操作によって前 記選出および前記更新を行うことを特徴とする請求項 7または 8記載のスケジユーリン グ装置。
[10] 前記実行単位選出部は、直近に実行された実行単位に対応するビットが末尾にな るようにビット列をローテートし、
ローテートされたビット列の先頭力も順に実行可能な実行単位のビットを検索するこ とによって前記選出を行うことを特徴とする請求項 9記載のスケジューリング装置。
[11] マルチプロセッサシステムに含まれる複数のプロセッサの実行対象となる各実行単 位のそれぞれが実行可能な状態にあるか否かを、それぞれの実行単位に対して付 与された識別子に対応づけて示す実行可否情報と、各実行単位のうちの、直近に実 行された実行単位の識別子を示す直近実行情報とを含む実行単位情報を保持する 機能と、
前記実行単位情報に基づ!、て、直近に実行された実行単位の識別子以外の識別 子を優先的に選出する制約の下でいずれかの実行可能な実行単位の識別子を、プ 口セッサによって実行される実行単位の識別子として選出するとともに、前記実行単 位情報を更新する機能とをコンピュータに実行せしめることを特徴とするプログラム。 プログラムを記憶した記憶媒体であって、
前記プログラムは、
マルチプロセッサシステムに含まれる複数のプロセッサの実行対象となる各実行単 位のそれぞれが実行可能な状態にあるか否かを、それぞれの実行単位に対して付 与された識別子に対応づけて示す実行可否情報と、各実行単位のうちの、直近に実 行された実行単位の識別子を示す直近実行情報とを含む実行単位情報を保持する 機能と、
前記実行単位情報に基づ!、て、直近に実行された実行単位の識別子以外の識別 子を優先的に選出する制約の下でいずれかの実行可能な実行単位の識別子を、プ 口セッサによって実行される実行単位の識別子として選出するとともに、前記実行単 位情報を更新する機能とをコンピュータに実行せしめること特徴とする記憶媒体。
PCT/JP2006/310907 2005-08-15 2006-05-31 スケジューリング方法およびスケジューリング装置 WO2007020739A1 (ja)

Priority Applications (3)

Application Number Priority Date Filing Date Title
EP06756827A EP1923784A4 (en) 2005-08-15 2006-05-31 SCHEDULING PROCEDURE AND SCHEDULING EQUIPMENT
CN2006800179477A CN101180609B (zh) 2005-08-15 2006-05-31 调度方法以及调度装置
US11/996,361 US8375390B2 (en) 2005-08-15 2006-05-31 Scheduling method and scheduling apparatus

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
JP2005-235582 2005-08-15
JP2005235582A JP4963018B2 (ja) 2005-08-15 2005-08-15 スケジューリング方法およびスケジューリング装置

Publications (1)

Publication Number Publication Date
WO2007020739A1 true WO2007020739A1 (ja) 2007-02-22

Family

ID=37757408

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/JP2006/310907 WO2007020739A1 (ja) 2005-08-15 2006-05-31 スケジューリング方法およびスケジューリング装置

Country Status (5)

Country Link
US (1) US8375390B2 (ja)
EP (1) EP1923784A4 (ja)
JP (1) JP4963018B2 (ja)
CN (1) CN101180609B (ja)
WO (1) WO2007020739A1 (ja)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7647483B2 (en) 2007-02-20 2010-01-12 Sony Computer Entertainment Inc. Multi-threaded parallel processor methods and apparatus

Families Citing this family (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8589943B2 (en) 2007-08-15 2013-11-19 Sony Computer Entertainment Inc. Multi-threaded processing with reduced context switching
JP5324934B2 (ja) * 2009-01-16 2013-10-23 株式会社ソニー・コンピュータエンタテインメント 情報処理装置および情報処理方法
US8352946B2 (en) * 2009-08-11 2013-01-08 International Business Machines Corporation Managing migration ready queue associated with each processor based on the migration ready status of the tasks
CN101996082B (zh) * 2009-08-28 2014-06-11 国际商业机器公司 协处理器系统和在本地存储器上加载应用程序的方法
US8056080B2 (en) * 2009-08-31 2011-11-08 International Business Machines Corporation Multi-core/thread work-group computation scheduler
US9594660B2 (en) 2014-03-27 2017-03-14 International Business Machines Corporation Multithreading computer system and program product for executing a query instruction for idle time accumulation among cores
US9218185B2 (en) 2014-03-27 2015-12-22 International Business Machines Corporation Multithreading capability information retrieval
US9921848B2 (en) 2014-03-27 2018-03-20 International Business Machines Corporation Address expansion and contraction in a multithreading computer system
US9354883B2 (en) 2014-03-27 2016-05-31 International Business Machines Corporation Dynamic enablement of multithreading
US9417876B2 (en) 2014-03-27 2016-08-16 International Business Machines Corporation Thread context restoration in a multithreading computer system
US9804846B2 (en) 2014-03-27 2017-10-31 International Business Machines Corporation Thread context preservation in a multithreading computer system
US10102004B2 (en) 2014-03-27 2018-10-16 International Business Machines Corporation Hardware counters to track utilization in a multithreading computer system
US10101963B2 (en) * 2016-08-16 2018-10-16 Hewlett Packard Enterprise Development Lp Sending and receiving data between processing units

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH02242434A (ja) * 1989-03-16 1990-09-26 Hitachi Ltd タスクのスケジューリング方法
JPH0424828A (ja) * 1990-05-21 1992-01-28 Fuji Xerox Co Ltd マルチタスク管理方式
EP1544738A1 (en) 2003-12-19 2005-06-22 STMicroelectronics, Inc. Accelerator for multi-processing system and method

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
FR2253428A5 (ja) * 1973-11-30 1975-06-27 Honeywell Bull Soc Ind
US4796178A (en) * 1985-10-15 1989-01-03 Unisys Corporation Special purpose processor for off-loading many operating system functions in a large data processing system
JP2505526B2 (ja) * 1988-04-11 1996-06-12 沖電気工業株式会社 タスクのビットマップ管理方法
JP2804478B2 (ja) * 1988-05-26 1998-09-24 株式会社日立製作所 タスク制御方式及びオンライン・トランザクション・システム
JPH07146799A (ja) 1993-11-22 1995-06-06 Hitachi Ltd マルチタスク・システムにおけるタスク切り換え方法
US20030110203A1 (en) * 2000-02-17 2003-06-12 Brenner Larry Bert Apparatus and method for dispatching fixed priority threads using a global run queue in a multiple run queue system
CN1152306C (zh) * 2001-01-23 2004-06-02 英业达股份有限公司 防止多处理器计算机中各处理器间进程发生冲突的方法
US7802255B2 (en) * 2003-12-19 2010-09-21 Stmicroelectronics, Inc. Thread execution scheduler for multi-processing system and method

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH02242434A (ja) * 1989-03-16 1990-09-26 Hitachi Ltd タスクのスケジューリング方法
JPH0424828A (ja) * 1990-05-21 1992-01-28 Fuji Xerox Co Ltd マルチタスク管理方式
EP1544738A1 (en) 2003-12-19 2005-06-22 STMicroelectronics, Inc. Accelerator for multi-processing system and method

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP1923784A4

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7647483B2 (en) 2007-02-20 2010-01-12 Sony Computer Entertainment Inc. Multi-threaded parallel processor methods and apparatus
US7979680B2 (en) 2007-02-20 2011-07-12 Sony Computer Entertainment Inc. Multi-threaded parallel processor methods and apparatus

Also Published As

Publication number Publication date
US8375390B2 (en) 2013-02-12
JP4963018B2 (ja) 2012-06-27
CN101180609B (zh) 2011-06-08
EP1923784A1 (en) 2008-05-21
EP1923784A4 (en) 2010-02-17
US20090031315A1 (en) 2009-01-29
JP2007052511A (ja) 2007-03-01
CN101180609A (zh) 2008-05-14

Similar Documents

Publication Publication Date Title
WO2007020739A1 (ja) スケジューリング方法およびスケジューリング装置
JP4526412B2 (ja) マルチプロセッサシステムにおけるタスク管理方法および装置
US7565653B2 (en) Methods and apparatus for processor task migration in a multi-processor system
US9779042B2 (en) Resource management in a multicore architecture
US8713573B2 (en) Synchronization scheduling apparatus and method in real-time multi-core system
JP5643190B2 (ja) 局所的集合内のタスクを汎用的集合に割り当てるための方法及びコンピュータ読取可能記録媒体
EP2857968B1 (en) Task processor
US10402223B1 (en) Scheduling hardware resources for offloading functions in a heterogeneous computing system
EP2056198A1 (en) Task processing device
JP2005284749A (ja) 並列処理コンピュータ
WO2012082330A1 (en) Non-blocking wait-free data-parallel scheduler
JP4127848B2 (ja) タスク処理装置
US20140068625A1 (en) Data processing systems
CN103729480A (zh) 一种多核实时操作系统多个就绪任务快速查找及调度方法
KR20230121884A (ko) 어드레스 매핑 인식 태스킹 메커니즘
JP3546694B2 (ja) マルチスレッド計算機システム及びマルチスレッド実行制御方法
US20220066831A1 (en) Lock-free work-stealing thread scheduler
JP7042105B2 (ja) プログラム実行制御方法および車両制御装置
KR102563648B1 (ko) 멀티 프로세서 시스템 및 그 구동 방법
CN116841751B (zh) 一种多任务线程池的策略配置方法、装置和存储介质
JP2008269597A (ja) タスク処理装置
JP2023179057A (ja) 演算処理装置および演算処理方法
GB2484708A (en) Data processing systems
GB2484707A (en) Data processing systems

Legal Events

Date Code Title Description
WWE Wipo information: entry into national phase

Ref document number: 200680017947.7

Country of ref document: CN

121 Ep: the epo has been informed by wipo that ep was designated in this application
WWE Wipo information: entry into national phase

Ref document number: 11996361

Country of ref document: US

NENP Non-entry into the national phase

Ref country code: DE

WWE Wipo information: entry into national phase

Ref document number: 2006756827

Country of ref document: EP