JPH0423137A - Thread generation system and parallel processing system - Google Patents

Thread generation system and parallel processing system

Info

Publication number
JPH0423137A
JPH0423137A JP12672190A JP12672190A JPH0423137A JP H0423137 A JPH0423137 A JP H0423137A JP 12672190 A JP12672190 A JP 12672190A JP 12672190 A JP12672190 A JP 12672190A JP H0423137 A JPH0423137 A JP H0423137A
Authority
JP
Japan
Prior art keywords
thread
threads
management table
stack
list
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
JP12672190A
Other languages
Japanese (ja)
Inventor
Tadashi Kamiwaki
正 上脇
Shinichiro Yamaguchi
伸一朗 山口
Masahiko Saito
雅彦 斉藤
Naoto Miyazaki
直人 宮崎
Yoshiki Kobayashi
芳樹 小林
Tomoaki Nakamura
智明 中村
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.)
Hitachi Ltd
Original Assignee
Hitachi Ltd
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 Hitachi Ltd filed Critical Hitachi Ltd
Priority to JP12672190A priority Critical patent/JPH0423137A/en
Publication of JPH0423137A publication Critical patent/JPH0423137A/en
Pending legal-status Critical Current

Links

Abstract

PURPOSE:To generate threads at a high speed by storings thread control table for ended threads and a stack and then reusing the stored information when the threads are generated within a same process. CONSTITUTION:A shared memory 53 stores the processes 1-1 - 1-2. In a process 1-1, for example, the threads 2-1 - 2-3 read and write the data 422-1 while executing a program 421-1. The threads that finished each processing are returned to an assembly 36 of idle threads and also added to an assembly 32-1 or 32-2 of the finished threads included in a process. If the threads are included in the assembly 32-1 when the threads are generated in a process, the threads of the assembly 32-1 are used. These threads have the small parts to be initialized on a thread control table and the stacks allocated with the memories. Thus the threads can be generated at a high speed.

Description

【発明の詳細な説明】 C産業上の利用分野〕 本発明は、独自に仮想空間を持つプロセスの内部に、プ
ログラムとデータを共有し、スタックとプログラムカウ
ンタとレジスタを個々に持つスレッドを複数持って、複
数のプログラムの流れを並行して実行するオペレーティ
ングシステムにおけるスレッド生成方式に関する。
[Detailed Description of the Invention] C Industrial Field of Application] The present invention provides a process that has a plurality of threads that share programs and data and each have a stack, a program counter, and a register, within a process that has its own virtual space. The present invention relates to a thread generation method in an operating system that executes multiple program flows in parallel.

特にマルチプロセッサにより該複数のスレッドを並列に
処理するシステムのオペレーティングシステムに適する
It is particularly suitable for an operating system of a system in which a plurality of threads are processed in parallel by a multiprocessor.

〔従来の技術〕[Conventional technology]

パナシークエント社、パラレルプログラミング講習資料
(C言語用)の6項では、サブプログラムをパラレルで
実行する関数として1nfork()が説明されている
。その説明の中で、アプリケーションの最初でmfor
k()が呼ばれたときは子プロセスを生成するが、2度
目以降は、最初のmfork()によって生成された子
プロセスを再使用することが示されている。これによれ
ば、2度目以降のプロセスの生成を高速化することが出
来る。
In Section 6 of Panasequent's Parallel Programming Training Materials (for C language), 1nfork() is explained as a function that executes subprograms in parallel. In that description, at the beginning of the application mfor
It is shown that when k() is called, a child process is generated, but from the second time onwards, the child process generated by the first mfork() is reused. According to this, it is possible to speed up the generation of processes from the second time onward.

従来、マルチプロセッサに於て並列処理をする際に処理
の単位となるプロセスを高速に生成することが性能を上
げる上で重要であるといわれてきた。これは、アプリケ
ーションのプログラムを実行する時間が並列処理により
大きく短縮されたとしても、プロセスの生成に時間が掛
かつてしまっては、全体として性能が向上しないからで
ある。
Conventionally, it has been said that when performing parallel processing in a multiprocessor, it is important to quickly generate a process as a unit of processing in order to improve performance. This is because even if the time to execute an application program is greatly reduced by parallel processing, if it takes time to generate a process, overall performance will not improve.

上記文献の方法は、プロセスの生成自体を高速化する方
法を示している。しかし、プロセスは切り替えの速度が
遅いために、プロセスを用いている限りは並列処理のた
めの仕事の分担を高速に行うことは不可能である。つま
り、生成の時間を短くしたとしても、その生成したプロ
セスを実行するためには、プロセス切り替えが必要であ
り、これが遅くては効果が得られない。
The method in the above document shows a method for speeding up process generation itself. However, since the switching speed of processes is slow, it is impossible to quickly share work for parallel processing as long as processes are used. In other words, even if the generation time is shortened, process switching is required to execute the generated process, and if this is slow, no effect will be obtained.

そのため、近年、切り替えが高速なスレッドが注目され
ている。プロセスは、個々に仮想空間を持っているため
プロセスを切り替えるためには。
Therefore, in recent years, threads that can switch quickly have attracted attention. In order to switch between processes, each process has its own virtual space.

この仮想空間を切り替える必要があり時間が掛かった。It took time to switch between virtual spaces.

スレッドの考え方は、従来のプロセスを仮想空間やファ
イルなどの資源を割り当てる単位である実行環境と、ス
レッドと呼ばれるCPU割り当て、もしくは制御フロー
の単位に分離したものである。
The idea of threads is to separate a conventional process into an execution environment, which is a unit for allocating resources such as virtual space and files, and a unit called a thread, which is a unit of CPU allocation or control flow.

スレッドは、スタックとレジスタは個々に持っているが
、仮想空間(プログラムやデータはこれに含まれる)を
共有している。そのため、同一プロセス内のスレッド同
士の切り替えは、仮想空間の切り替えが必要なく、高速
に行える。
Threads have individual stacks and registers, but they share virtual space (which includes programs and data). Therefore, switching between threads within the same process can be performed quickly without the need to switch virtual spaces.

〔発明が解決しようとする課題〕[Problem to be solved by the invention]

上記従来技術で述べた文献のプロセスを再使用する方法
は、仮想空間を独自にもつプロセスの再利用の方法につ
いて述べており、仮想空間を共有するスレッドを再使用
する点について配慮されていない。また、この文献の方
法は、処理の終了したプロセスをスピン状態、つまり実
行状態で待機させており、プロセッサを無駄に使用する
ことになる。
The method of reusing a process in the literature described in the above-mentioned prior art describes a method of reusing a process that has its own virtual space, and does not consider reusing threads that share a virtual space. Further, in the method of this document, a process that has completed processing is made to wait in a spin state, that is, a running state, which results in wasteful use of the processor.

本発明の目的は、仮想空間を共有するスレッドに対して
、終了したスレッドのスレッド管理テーブルとスタック
を再使用することにより生成を高速化する方法を提供す
ることにある。
An object of the present invention is to provide a method for speeding up the creation of threads that share a virtual space by reusing thread management tables and stacks of terminated threads.

また1本発明の別の目的は、終了したスレッドのスレッ
ド管理テーブルをプロセス毎に保存しておき、同じプロ
セス内にスレッドを生成する際には、保存されているス
レッド管理テーブルを再使用することによりスレッドの
生成を高速化する際に、空きスレッド管理テーブルが不
足したときには、他のプロセス用として保存さ九でいる
ものを横取りして利用できる方法を提供することにある
Another object of the present invention is to save a thread management table of terminated threads for each process, and reuse the saved thread management table when creating a thread within the same process. The purpose of this invention is to provide a method that allows thread management tables to be preempted and used for use by other processes when there is a shortage of free thread management tables when creating threads at high speed.

また、本発明の別の目的は、終了したスレッドのスタッ
ク領域を保存しておき、同一プロセス内にスレッドを生
成する際に、保存されているスタックを再使用して生成
を高速化する際に、生成時にメモリが不足したときには
、保存しであるスタック領域を解放する方法を提供する
ことにある。
Another object of the present invention is to save the stack area of terminated threads, and when creating threads in the same process, reuse the saved stack to speed up the creation. The purpose is to provide a method to save and release the stack area when there is insufficient memory during generation.

また1本発明の別の目的は、終了したスレッドのスレッ
ド管理テーブルとスタックを保存しておき、同一プロセ
ス内にスレッドを生成する際に、その保存したある情報
を再使用して生成することにより、スレッド管理テーブ
ルとスタックに対するアクセスのキャツシュヒツト率を
向上させることにある。
Another object of the present invention is to save thread management tables and stacks of terminated threads, and when creating threads within the same process, by reusing certain saved information to create threads. The objective is to improve the cache hit rate of accesses to the thread management table and stack.

〔課順を解決するための手段〕[Means for resolving lesson order]

上記目的を達成するためには、終了したスレッドのスレ
ッド管理テーブルとスタックをプロセス毎に保存、管理
し、そのプロセス内に再びスレッドを生成するときには
、保存されているそれらの情報を再使用する。
To achieve the above objective, the thread management table and stack of terminated threads are saved and managed for each process, and when a thread is generated again within that process, the saved information is reused.

上記のように終了したスレッドのスレッド管理テーブル
とスタックは、プロセス毎に管理しているが、システム
全体としてスレッド管理テーブルやメモリが足りなくな
ったときには、他のプロセスについて保存されているス
レッド管理テーブルとスタックを横取りできる。
As mentioned above, the thread management tables and stacks of threads that have terminated are managed for each process, but when the system as a whole runs out of thread management tables and memory, the thread management tables and stacks saved for other processes can be You can steal the stack.

〔作用〕[Effect]

各スレッド管理テーブルは、スレッドが使用するスタッ
ク領域を指示するポインタと、プロセス毎に終了したス
レッドの管理テーブルのリストを形成するポインタと、
使用されていない空きスレッド管理テーブルのリストを
形成するポインタを持っている。
Each thread management table includes a pointer that indicates the stack area used by the thread, a pointer that forms a list of management tables of threads that have terminated for each process,
Contains pointers forming a list of unused and free thread management tables.

スタック領域を指示するポインタにより、スレッド管理
テーブルと使用スタック領域の対応をとることができる
A pointer that indicates the stack area allows correspondence between the thread management table and the used stack area.

また、1つのスレッド管理テーブルが同時にプロセス毎
の保存リストとシステム全体のテーブルのリストにつな
がることが出来るので、メモリやスレッド管理テーブル
が不足したときの横取りが可能となる。
Furthermore, since one thread management table can be connected to the save list for each process and the table list for the entire system at the same time, it is possible to preempt the memory or thread management table when the memory or thread management table is insufficient.

〔実施例〕〔Example〕

以下図面を参照して本発明の一実施例について詳細に説
明する。
An embodiment of the present invention will be described in detail below with reference to the drawings.

第1図は、本発明の構成を示した図である。第1図に於
て51−1〜51−3はプロセッサ、52はバス、53
は共有メモリ、54−1〜54−3はレジスタ、55−
1〜55−3はキャッシュメモリ、1−1〜1−2はプ
ロセス、2−1〜2−10はスレッド、32−1〜32
−2はプロセス内で終了したスレッドの集合、36は空
きスレッドの集合、4.21−1〜421−2はプログ
ラム、4.22−1〜422−2はデータである。
FIG. 1 is a diagram showing the configuration of the present invention. In FIG. 1, 51-1 to 51-3 are processors, 52 is a bus, and 53
is shared memory, 54-1 to 54-3 are registers, 55-
1 to 55-3 are cache memories, 1-1 to 1-2 are processes, 2-1 to 2-10 are threads, 32-1 to 32
-2 is a set of threads that have ended within the process, 36 is a set of free threads, 4.21-1 to 421-2 are programs, and 4.22-1 to 422-2 are data.

第1図は複数のプロセッサ51−1〜51−3をバス5
2を介して、共有メモリ53に接続した密結合型マルチ
プロセッサとなっている。共有メモリには、オペレーテ
ィングシステムとユーザが使用する情報が記憶されてい
る。その内の一つがプロセス1−1〜1−2である。プ
ロセスは、ユーザのあるまとまった仕事の単位であり、
各々がプログラムとデータを持つ。また、各プロセスは
、一つ以上のスレッドを持っている。スレッドはプログ
ラムカウンタやスタックポインタを含むレジスタとスタ
ックを持ついわば論理プロセッサである。同一プロセス
内のスレッドはプログラムとデータを共有している。第
1図では2−1〜2−3のスレッドが全てのプログラム
421−1を実行しつつ4−22−1のデータを読み書
きする。複数あるスレッドを各プロセッサが受は持て実
行すれば簡単に並列処理を実現することが出来る。
FIG. 1 shows a plurality of processors 51-1 to 51-3 connected to a bus 5.
It is a tightly coupled multiprocessor connected to a shared memory 53 via 2. Shared memory stores information used by the operating system and users. One of them is processes 1-1 to 1-2. A process is a unit of a user's work,
Each has a program and data. Also, each process has one or more threads. A thread is a logical processor with a stack and registers including a program counter and a stack pointer. Threads within the same process share programs and data. In FIG. 1, threads 2-1 to 2-3 read and write data in 4-22-1 while executing all programs 421-1. Parallel processing can be easily achieved if each processor takes part in executing multiple threads.

プロセッサはスケジューリングプログラムを実行して次
に処理するスレッドを決定すると、そのスレッドが持っ
ているレジスタの値をプロセッサのレジスタにロードす
る。そして、そのロードしたプログラムカウンタの値が
指す所よりプログラムを実行する。第1図では、51−
1.51−2゜51−3の各プロセッサは、それぞれT
l、T2゜T3のスレッドを実行していることがわかる
When a processor executes a scheduling program and determines the next thread to process, it loads the register values of that thread into the processor's registers. Then, the program is executed from the location pointed to by the loaded program counter value. In Figure 1, 51-
1.51-2゜51-3 each processor has T
It can be seen that threads 1, T2° and T3 are being executed.

プロセスのスレッドは、動的に生成、終了が可能である
。システムを起動した状態では、全てのスレッドは、空
きスレッドの集合36に入っている。プロセスの中にス
レッドを生成するときは、この空きスレッドの集合から
スレッド取り出してくる。しかし、スレッドを空きスレ
ッドの集合より取り出した場合は、スレッドの管理テー
ブルを初期化したり、スタックのメモリを割り当てたり
する作成が必要であり、比較的時間が掛かる。第1図に
は本発明によるスレッド生成高速化の機構が組み込まれ
ている。処理を終了したスレッドは36の空きスレッド
の集合に戻される一方、プロセス内の終了したスレッド
の集合32−1または32−2にも加えられる。プロセ
ス内にスレッドを生成する際に終了したスレッドの集合
にスレッドが入っているときには、そのスレッドを用い
る。
Process threads can be dynamically created and terminated. When the system is started, all threads are included in the free thread set 36. When creating a thread in a process, the thread is extracted from this set of free threads. However, when a thread is extracted from a set of free threads, it is necessary to initialize a thread management table and allocate stack memory, which takes a relatively long time. In FIG. 1, a mechanism for speeding up thread generation according to the present invention is incorporated. The thread that has completed processing is returned to the set of 36 free threads, and is also added to the set of threads that have completed within the process 32-1 or 32-2. When a thread is created in a process, if the thread is included in the set of terminated threads, that thread is used.

これらのスレッドは、スレッド管理テーブルの初期化す
る部分が少なく、スタックにもメモリが割り当てられて
いる。このため高速にスレッドを生成することが出来る
。また、これらのスレッドは最近まで実行されていたた
め、管理テーブルの内容やスタックの内容がプロセット
のキャッシュメモリ55−1〜55−3に入っている可
能性が高く、それらに対するアクセスはキャツシュヒツ
ト率が高くなる。
These threads have fewer thread management tables to initialize, and memory is also allocated to the stack. Therefore, threads can be generated quickly. In addition, since these threads have been running until recently, there is a high possibility that the contents of the management table and the contents of the stack are in the cache memories 55-1 to 55-3 of the preset, and access to them is likely to occur at a high cache hit rate. It gets expensive.

第2図は、本発明の実施例のテーブルの管理を表した図
である。第2図に於て、1−]〜1−2はプロセスの管
理テーブル、2−1〜2−10はスレッド管理テーブル
、31−1〜31−2はプロセスに属するスレッドのリ
ストを指示するポインタ、32−1〜32−2はプロセ
ス内で終了したスレッドのリストを指示するポインタ、
33−1から33−2はプロセスの属するスレッドのリ
ストを形成するポインタ、34−1から34−3はプロ
セス内で終了したスレッドのリストを形成するポインタ
、35−1〜35−3は空きスレッド管理テーブルを形
成するポインタ、36は空きスレッド管理テーブルを指
示するポインタである。
FIG. 2 is a diagram showing table management according to the embodiment of the present invention. In FIG. 2, 1-] to 1-2 are process management tables, 2-1 to 2-10 are thread management tables, and 31-1 to 31-2 are pointers indicating a list of threads belonging to the process. , 32-1 to 32-2 are pointers indicating a list of threads that have ended within the process;
33-1 to 33-2 are pointers that form a list of threads to which the process belongs, 34-1 to 34-3 are pointers that form a list of threads that have ended within the process, and 35-1 to 35-3 are empty threads. A pointer 36 forming a management table is a pointer pointing to an empty thread management table.

プロセスやスレッドは、それぞれテーブルにより管理さ
れている。プロセスは管理するテーブルがプロセス管理
テーブルl−1〜1−2であり、スレッドを管理するテ
ーブルがスレッド管理テーブル2−1〜2−10である
。プロセス管理テーブルは構造体となっており、そのメ
ンバーの中にプロセスに属するスレッドのリストを指示
するポインタ31−1とプロセス内で終了したスレッド
のリストを指示するポインタ32−1がある。
Each process and thread is managed by a table. The tables for managing processes are process management tables l-1 to 1-2, and the tables for managing threads are thread management tables 2-1 to 2-10. The process management table is a structure, and its members include a pointer 31-1 that points to a list of threads belonging to a process and a pointer 32-1 that points to a list of threads that have ended within the process.

第1図に於てスレッド2−1〜2−3は、プロセス1−
1に属していた。第2図では、2−1〜2−3のスレッ
ド管理テーブルのリストの先頭をプロセス管理テーブル
1−1のポインタ31−1が指している。
In FIG. 1, threads 2-1 to 2-3 are processes 1-
It belonged to 1. In FIG. 2, the pointer 31-1 of the process management table 1-1 points to the top of the list of thread management tables 2-1 to 2-3.

また、第1図に於てプロセス1−1の中で終了したスレ
ッド2−4〜2−6を集合32−1としてまとめていた
。第2図ではスレッド管理テーブル2−4〜2−6のリ
ストをプロセス管理テーブルのポインタ32−1が指し
ている。プロセス1−2についても同様である。
Further, in FIG. 1, the threads 2-4 to 2-6 that terminated in the process 1-1 are grouped together as a set 32-1. In FIG. 2, a process management table pointer 32-1 points to a list of thread management tables 2-4 to 2-6. The same applies to process 1-2.

第1図に於て、使用されていない空きスレッドは、集合
36によりまとめられていた。第2図では36のポイン
タが未使用のスレッド管理テーブルのリストを指してい
る。この空きスレッド管理テーブルのリス1へに属して
いるスレッド管理テーブルは、プロセス内で終了したス
レッドの管理テーブルのリストにも同時に属することが
出来る。
In FIG. 1, unused free threads are grouped together by a set 36. In FIG. 2, pointer 36 points to a list of unused thread management tables. The thread management table belonging to list 1 of the free thread management table can also belong to the list of management tables of threads that have ended within the process.

スレッドの管理テーブルも構造体であり、そのメンバー
の中に二種類のポインタを持っている。
The thread management table is also a structure, and its members have two types of pointers.

一つは、プロセスに属するスレッドのリストを形成する
ポインタ33−1〜33−2とプロセス内で終了したス
レッドのリストを形成するポインタ34−1〜34−3
に使用される。もう一つは、空きスレッド管理テーブル
のリストを形成するポインタである。
One is pointers 33-1 to 33-2 that form a list of threads belonging to the process, and pointers 34-1 to 34-3 that form a list of threads that have ended within the process.
used for. The other is a pointer that forms a list of free thread management tables.

第3図は5本発明の一実施例に於ける仮想空間を表して
いる。第3図に於て40はプロセッサが使用する仮想空
間全体であり、41はシステム空間であり、42−1〜
42−2はユーザ空間である。
FIG. 3 shows a virtual space in one embodiment of the present invention. In FIG. 3, 40 is the entire virtual space used by the processor, 41 is the system space, and 42-1 to 42-1 are the entire virtual space used by the processor.
42-2 is a user space.

プロセッサのアドレスバスが32本であることから、プ
ロセッサが使用可能な仮想空間の大きさは2 ”= 4
 Gバイトである。この仮想空間の上2Gバイト、アド
レスでは2G〜4Gは、オペレーティングシステムが使
用するシステム空間になっている。第2図で述べたプロ
セス管理テーブルやスレッド管理テーブルは、この領域
に取られる。
Since the processor has 32 address buses, the size of the virtual space that can be used by the processor is 2'' = 4
That's G bytes. The upper 2G bytes of this virtual space, addresses 2G to 4G, are system space used by the operating system. The process management table and thread management table described in FIG. 2 are stored in this area.

仮想空間の下2Gバイト、アドレスでは0〜2Gはユー
ザプロセスが使用するユーザ空間となっている。ユーザ
空間はプロセス毎に独立になっており、第1図のプロセ
ス1−1のユーザ空間は42−1であり、プロセス1−
2のユーザ空間は42−2である。
The lower 2 Gbytes of the virtual space, addresses 0 to 2 G, are user space used by user processes. The user space is independent for each process, and the user space of process 1-1 in FIG. 1 is 42-1, and the user space of process 1-1 in FIG.
The user space of 2 is 42-2.

同一プロセスに屓するスレッドは全て同一のユーザ空間
を共有する。プロセス1−1に属するスレッド2−1.
2−2.2−3はユーザ空間42−1に対して読み書き
することとなる。
All threads belonging to the same process share the same user space. Thread 2-1 belonging to process 1-1.
2-2.2-3 reads and writes to the user space 42-1.

第4図は、第3図のシステム空間を詳細に表した図であ
る。第4図に於て1−1〜1−2はプロセス管理テーブ
ル、2−1〜2−4はスレッド管理テーブル、11は空
きスレッド管理テーブルのリストを指示するポインタで
ある。各プロセス管理テーブルは、複数のメンバーから
なる構造体であり、プロセスに属するスレッドのリスト
を形成するポインタや空きスレッド管理テーブルのリス
トを形成するポインタは、この構造対のメンバーの一つ
である。また、これらのスレッドを指示するポインタは
、スレッドテーブルの先頭の仮想空間アドレスが入る。
FIG. 4 is a diagram showing the system space of FIG. 3 in detail. In FIG. 4, 1-1 to 1-2 are process management tables, 2-1 to 2-4 are thread management tables, and 11 is a pointer that indicates a list of free thread management tables. Each process management table is a structure consisting of a plurality of members, and a pointer forming a list of threads belonging to a process and a pointer forming a list of free thread management tables is one member of this structure pair. Further, the virtual space address of the head of the thread table is entered as a pointer indicating these threads.

第5図は第3図のユーザ空間とスレッド管理テーブルの
関係を示している。第5図に於て2−1〜2−4はスレ
ッド管理テーブル、37−1〜37−4はUエリアを指
すポインタ、38−1〜38−4はユーザスタックを指
すポインタ、42−1はユーザ空間、421−1はプロ
グラム、422−1はデータ、424−1〜424−4
はユーザスタック、425−1〜425−4はりエリア
である。
FIG. 5 shows the relationship between the user space of FIG. 3 and the thread management table. In FIG. 5, 2-1 to 2-4 are thread management tables, 37-1 to 37-4 are pointers pointing to the U area, 38-1 to 38-4 are pointers pointing to the user stack, and 42-1 is a pointer pointing to the user stack. User space, 421-1 is a program, 422-1 is data, 424-1 to 424-4
is a user stack and 425-1 to 425-4 beam areas.

第3図で示した通り各プロセスは独自のユーザ空間を持
ている。第5図の42−1のユーザ空間はプロセス1−
1のユーザ空間を示している。各プロセスはブbグラム
とデータを持っていφ。これらはユーザ空間に置かれる
。第5図では42]−1と422−1がそれである。プ
ログラムとデータは同一プロセス内のスレッド間で共有
される。
As shown in Figure 3, each process has its own user space. The user space 42-1 in FIG. 5 is the process 1-
1 user space is shown. Each process has a program and data φ. These are placed in user space. In FIG. 5, these are 42]-1 and 422-1. Programs and data are shared between threads within the same process.

一方5 uエリアとユーザスタックは、各スレッド毎に
設けられる。Uエリア425−1〜425−4は、オペ
レーティングシステムが使用するデータの内、スレッド
が実行中の時に限り必要となるデータが入る領域である
。その内容は、オペレーティングシステム用のスタック
、システムコールの引き数、レジスタの退避領域なとで
ある。プロセス内の複数あるUエリアの内、先頭のもの
425−1は、スレッドに関する情報の他にプロセスに
関する情報も記憶される。その内容は、使用しているフ
ァイルなどである。
On the other hand, a 5U area and a user stack are provided for each thread. The U areas 425-1 to 425-4 are areas for storing data used by the operating system that is necessary only when a thread is running. Its contents include the operating system stack, system call arguments, and register save areas. Among the plurality of U areas within a process, the first one 425-1 stores information regarding the process as well as information regarding the thread. Its contents include the files being used.

ユーザスタックは、ユーザプログラム実行中に使用する
スタックである。各スレッドは独立にサブルーチン呼び
出しを行うためユーザスタックをそれぞれ持つ必要があ
る。
The user stack is a stack used during execution of a user program. Each thread must have its own user stack to call subroutines independently.

スレッド管理テーブルのメンバーの中には、そのスレッ
ドが使用するUエリアとユーザスタックを指すポインタ
(各々37−1〜37−4と38−1〜38−4)が含
まれる。
The members of the thread management table include pointers (37-1 to 37-4 and 38-1 to 38-4, respectively) pointing to the U area and user stack used by the thread.

2−4のスレッド管理テーブルのスレッドは既に終了し
ているが、スレッド管理テーブルがプロセス内の終了ス
レッドのリストにつながれている間は、そのスレッドの
Uエリアやユーザスタックの領域は解放されない。スレ
ッド管理テーブルのポインタも自分が使用していたUエ
リアとユーザスタックを指したままとなっている。スレ
ッド管理テーブル2−4を再使用してスレッドを生成す
るときには、それが指すUエリア425−4とユーザス
タック424−4も再使用される。
Although the thread in the thread management table 2-4 has already ended, the U area and user stack area of that thread will not be released while the thread management table is linked to the list of ended threads within the process. The thread management table pointer still points to the U area and user stack that it was using. When the thread management table 2-4 is reused to generate a thread, the U area 425-4 and user stack 424-4 pointed to by the thread management table 2-4 are also reused.

第6図は、第2図の状態に於て、プロセス1−1にスレ
ッドを生成した場合を示す、第2図ではプロセス1−1
の終了スレッドのリストにスレッドがあるので、先頭の
スレッド2−4を再使用してスレッドを生成することと
なる。まず、スレッド2−4を終了スレッドのリストか
ら外すためにポインタ32−1がスレッド2−5を指す
ようにする。次に空きスレッドのリストからスレッド管
理テーブルを外すためにポインタ35−2もスレラド2
−5を指すように変更する。そして、自由になったスレ
ッド管理テーブル2−4をプロセスに屑するリストの最
終に接続する。
FIG. 6 shows a case where a thread is generated in process 1-1 in the state shown in FIG.
Since there is a thread in the list of finished threads, the first thread 2-4 will be reused to generate a thread. First, in order to remove thread 2-4 from the list of finished threads, pointer 32-1 is made to point to thread 2-5. Next, in order to remove the thread management table from the list of free threads, the pointer 35-2 is also set to slerad 2.
-Change it to point to 5. Then, the freed thread management table 2-4 is connected to the end of the list of processes to be discarded.

第7図は、第2図の状態に於て、スレッド2−2が処理
を終了した場合を示す、まず、スレッド管理テーブル2
−2をプロセスに属するスレッドのリストから外すため
にポインタ33−1がスレッド管理テーブル2−3を指
すように変更する。
FIG. 7 shows a case where the thread 2-2 has finished processing in the state shown in FIG. 2. First, the thread management table 2
-2 from the list of threads belonging to the process, the pointer 33-1 is changed to point to the thread management table 2-3.

次に、その外したテーブルを終了したスレッドのリスト
の先頭に挿入する。このためにポインタ32−1がその
テーブルを指すようにし、テーブルのポインタ33−2
がスレッド管理テーブル2−5を指すようにする。テー
ブルをリストの先頭に挿入するのは、スレッド生成時に
最も最近終了したスレッドの管理テーブルやスタックを
再使用できるようにするためである。最近まで実行され
ていたスレッドのものであれば、その内容がキャッシュ
メモリに記憶されている可能性が高いからである。
Next, insert the removed table at the beginning of the list of terminated threads. For this purpose, the pointer 32-1 points to the table, and the table pointer 33-2
points to the thread management table 2-5. The table is inserted at the beginning of the list so that the management table and stack of the most recently terminated thread can be reused when creating a thread. This is because if the thread belongs to a thread that has been executed until recently, there is a high possibility that its contents are stored in the cache memory.

また、このテーブルを空きスレッドのリストにも加える
必要があるが、このときにはリストの最後に接続するよ
うにする。これは、終了スレッドのリストに接続されて
いるスレッドが他のプロセスのスレッドの生成に使われ
てしまうことをできるだけ避けるためである。図ではス
レッド2−9のポインタ35−6がスレッド管理テーブ
ル2−2を指すように変更している。
You will also need to add this table to the list of free threads, making sure to connect to the end of the list. This is to prevent threads connected to the terminated thread list from being used to create threads for other processes. In the figure, the pointer 35-6 of the thread 2-9 has been changed to point to the thread management table 2-2.

第8図は、第2図の状態に於て、新しいプロセス1−3
を生成し、さらにその中にスレッドを生成した場合を示
している。プロセスが新しい場合にはそのプロセスの終
了スレッドのりスト32−3にはスレッド管理テーブル
が接続されていない。
Figure 8 shows the new process 1-3 in the state of Figure 2.
This shows the case where a thread is created and a thread is created within it. If the process is new, no thread management table is connected to the end thread list 32-3 of the process.

そのため、スレッドを生成するときには空きスレッド管
理テーブルのリスト36からスレッド管理テーブルを取
り出してくる。取り出すときにはリストの先頭のテーブ
ルを取り出す、そのためにポインタ36がスレッド管理
テーブル2−8を指すように変更する。次に取り出した
テーブルをプロセスに属するスレッドのりスト31−3
に加える。
Therefore, when generating a thread, the thread management table is retrieved from the list 36 of free thread management tables. When taking out the table, the first table in the list is taken out, and therefore the pointer 36 is changed to point to the thread management table 2-8. Next, the retrieved table is stored in the thread list 31-3 belonging to the process.
Add to.

第9図は、第8図の状態に於て、プロセス1−3の中に
もうひとつスレッドを生成した場合を示す。この場合も
第8図の場合と同様に終了スレッドのリストが空なので
空きスレッド管理テーブルのリストからテーブルを取り
出してくることとなる。同様にリストの先頭からテーブ
ルを取り出そうとするが、先頭のスレッド管理テーブル
2−8は、他のプロセスの終了スレッドのリストにも属
している。そのため終了スレッドのリストからもスレッ
ド管理テーブルを外す必要がある。その後で、プロセス
に属するスレッドのリストに加える。
FIG. 9 shows a case where another thread is created in the process 1-3 in the state shown in FIG. In this case, as in the case of FIG. 8, the list of terminated threads is empty, so a table is taken out from the list of free thread management tables. Similarly, an attempt is made to retrieve a table from the top of the list, but the thread management table 2-8 at the top also belongs to the list of terminated threads of other processes. Therefore, it is necessary to remove the thread management table from the list of terminated threads. It is then added to the list of threads belonging to the process.

第10図は、スレッドを生成するときのアルゴリズムで
ある。まず、61でスレッドを生成しようとしているプ
ロセスの終了スレッドのリストが空かどうか調べる。も
し、空でなければ、65でその終了スレッドのリストの
先頭からスレッド管理テーブルを外し、66でそれをプ
ロセスに属するスレッドのリストに加えて使用する。
FIG. 10 shows an algorithm for generating threads. First, in step 61, it is checked whether the list of terminated threads of the process for which a thread is to be generated is empty. If it is not empty, the thread management table is removed from the head of the list of terminated threads at 65, and added to the list of threads belonging to the process at 66 for use.

61でリストが空だったときは、62で空きスレッド管
理テーブルのリストの先頭からスレッド管理テーブルを
取り出して使用する。ただし、63でそのスレッド管理
テーブルが他のプロセスの終了スレッドリストに属して
いる場合は、64のようにそのテーブルをそのリストか
ら外す必要がある。外したテーブルは、やはり66でプ
ロセスに属するスレッドのリストに加えられる。
If the list is empty in step 61, a thread management table is taken out from the top of the list of free thread management tables and used in step 62. However, if the thread management table in 63 belongs to the end thread list of another process, it is necessary to remove the table from the list as in 64. The removed table is added to the list of threads belonging to the process, again at 66.

第11図はスレッドを終了するアルゴリズムである。ま
ず、67でそのスレッドの管理テーブルをプロセスに属
するスレッドのリストより外す。
FIG. 11 is an algorithm for terminating a thread. First, in step 67, the management table for that thread is removed from the list of threads belonging to the process.

次に、68でそのテーブルを自プロセスの終了スレッド
のリストの先頭に挿入する。また、69のようにそのテ
ーブルを空きスレッドのリストの最後にも接続しておく
Next, in 68, the table is inserted at the beginning of the list of terminated threads of the own process. Further, the table is also connected to the end of the list of free threads as shown in 69.

第12図は、本発明を用いて並列処理プログラムを実行
した時のタイムチャートを示している。
FIG. 12 shows a time chart when a parallel processing program is executed using the present invention.

時間は左から右へ流れている。71のように最初スレッ
ドToのみが実行されている。72でT。
Time flows from left to right. As shown in 71, only thread To is initially being executed. T at 72.

がスレッドTl、T2.T3を生成する。この生成では
スレッド管理テーブルは、空きスレッドリストより取り
出す、TO〜T3は並列に各々処理73−1〜73−4
を実行する。T1〜T3の処理は74−2〜74−4で
終了する。これらのスレッドの管理テーブルはプロセス
の終了スレッドのリストにつながれる。75ではToの
みが実行される。76で再びスレッドを生成するときに
は終了スレッドのリストにつながれているスレッドを再
使用するため生成が高速であり、77−1〜77−4の
並列処理を効率よく実行できる。この様なスレッドの生
成と終了を繰り返し行う並列処理プログラムにおいて、
本発明を用いれば、2回目以降の生成を高速に行うこと
が出来る。
are threads Tl, T2. Generate T3. In this generation, the thread management table is extracted from the free thread list, and TO to T3 are processed in parallel, respectively 73-1 to 73-4.
Execute. The processing from T1 to T3 ends at steps 74-2 to 74-4. These thread management tables are linked to the process's list of termination threads. At 75, only To is executed. When threads are generated again in 76, the threads connected to the list of finished threads are reused, so generation is fast, and parallel processing in 77-1 to 77-4 can be efficiently executed. In a parallel processing program that repeatedly creates and terminates threads,
By using the present invention, the second and subsequent generation can be performed at high speed.

〔発明の効果〕〔Effect of the invention〕

本発明によれば、スレッドを生成する際に以前実行され
ていたスレッドの管理テーブルとスタックを再使用でき
るので、スレッドの生成を高速化できる。
According to the present invention, since the management table and stack of a previously executed thread can be reused when generating a thread, thread generation can be sped up.

また1本発明によれば、スレッドの生成を高速化できる
ため、スレッドの生成、終了を繰り返す並列処理プログ
ラムを効率よく実行することが出来る6 また1本発明によれば、以前実行していたスレッドのス
レッド管理テーブルとスタックを再使用できるので、そ
れらへのアクセスに対するキャツシュヒツト率を向上さ
せることが出来る。
In addition, according to the present invention, thread generation can be sped up, so a parallel processing program that repeatedly generates and terminates threads can be efficiently executed. Since the thread management table and stack of the thread management table and stack can be reused, the cache hit rate for accessing them can be improved.

【図面の簡単な説明】[Brief explanation of the drawing]

第1図は本発明の概要を示す図、第2図はテーブル構成
図、第3図は仮想空間のマツプを示す図、第4図はシス
テム空間のマツプを示す図、第5図はユーザ空間とスレ
ッド管理テーブルの関係図。 第6図はスレッドを生成したときのテーブルの操作を示
す図、第7図はスレッドが終了したときのテーブルの操
作を示す図、第8図はプロセスを生成したときのテーブ
ルの操作を示す図、第9図は第8図の新しいプロセスの
中に更にスレッドを生成したときのテーブルの操作を示
す図、第10図はスレッドを生成する時のアルゴリズム
を示す図、第11図はスレッドを終了するときのアルゴ
リズムを示す図、第12図は本発明を用いて並列処理プ
ログラムを実行した時のタイムチャートを示す図である
。 1−1〜1−3・・・プロセス、2−1〜2−10・・
・スレッド、31−1〜31−3・・プロセスに属する
スレッドのリストを指示するポインタ、32−1〜32
−3・・・終了スレッドのリストを指示するポインタ、
33−1〜33−3と34−1〜34−3・・・プロセ
スに属するスレッドのリストまたは終了スレッドのリス
トを形成するポインタ、35−1〜35−6・・・空き
スレッドのリストを形成するポインタ、36・・・空き
スレッドのリストを指示するポインタ、37−1〜37
−4・・・Uエリアを指すポインタ、38−1〜38−
4・・・ユーザスタックを指すポインタ、40・・・仮
想空間、41・・システム空間、42−1〜42−2・
・・ユーザ空間、51−1〜51−3・・・プロセッサ
、52・・バス、53・・・共有メモリ、54−1〜5
4−3・・・レジスタ、55−1〜55−3・・・キャ
ッシュ、61〜66・・・スレッド生成のための処理、
67〜68・・スレッド終了のための処理、71と73
−1〜73−4と75と77−1〜77−4・・・スレ
ッドの実行、72と76・・・スレッドの生成、74−
2〜74−4・・・スレッドの終了、421−1〜42
1−2・・・プログラム、 422−1〜422−2・・・デ ータ。 1〜424−4・・・ユーザスタック、第 図 第 図 第4図 第5図 第6図 第 7図 第8図 第9図 第10図 第11図 I゛ノー子 −9へ6一
Fig. 1 is a diagram showing an overview of the present invention, Fig. 2 is a table configuration diagram, Fig. 3 is a diagram showing a virtual space map, Fig. 4 is a diagram showing a system space map, and Fig. 5 is a diagram showing a user space. A diagram of the relationship between and thread management table. Figure 6 is a diagram showing table operations when a thread is created, Figure 7 is a diagram showing table operations when a thread is terminated, and Figure 8 is a diagram showing table operations when a process is created. , Figure 9 is a diagram showing the operation of the table when another thread is created in the new process of Figure 8, Figure 10 is a diagram showing the algorithm when creating a thread, and Figure 11 is a diagram showing how to terminate the thread. FIG. 12 is a diagram showing a time chart when a parallel processing program is executed using the present invention. 1-1 to 1-3...process, 2-1 to 2-10...
- Threads, 31-1 to 31-3...Pointers indicating a list of threads belonging to the process, 32-1 to 32
-3... Pointer indicating the list of terminated threads,
33-1 to 33-3 and 34-1 to 34-3... Pointers forming a list of threads belonging to a process or a list of terminated threads, 35-1 to 35-6... Forming a list of free threads. Pointer to point to, 36... Pointer to point to list of free threads, 37-1 to 37
-4... Pointer pointing to U area, 38-1 to 38-
4... Pointer pointing to user stack, 40... Virtual space, 41... System space, 42-1 to 42-2.
... User space, 51-1 to 51-3... Processor, 52... Bus, 53... Shared memory, 54-1 to 5
4-3...Register, 55-1 to 55-3...Cache, 61 to 66...Processing for thread generation,
67-68...Processing for thread termination, 71 and 73
-1 to 73-4 and 75 and 77-1 to 77-4...thread execution, 72 and 76...thread generation, 74-
2 to 74-4... End of thread, 421-1 to 42
1-2...Program, 422-1 to 422-2...Data. 1 to 424-4...User stack, Figure 4, Figure 5, Figure 6, Figure 7, Figure 8, Figure 9, Figure 10, Figure 11.

Claims (1)

【特許請求の範囲】 1、1つのオペレーティングシステムの下で1つ以上の
プロセスが動作し、該プロセスの各々が、プログラムと
データを共有し、レジスタとスタックを独自に持つ複数
のスレッドを有し、複数のプログラムの流れを並行して
実行できる計算機システムのスレッド生成方式において
、実行を終了したスレッドのスレッド管理テーブルとス
タックを保存して置き、再度同一プロセス内にスレッド
を生成するときには、保存されている該スレッドの管理
テーブルとスタックを利用することを特徴とするスレッ
ド生成方式。 2、1つのオペレーティングシステムの下で1つ以上の
プロセスが動作し、該プロセスの各々が、プログラムと
データを共有し、レジスタとスタックを独自に持つ複数
のスレッドを有し、複数のプログラムの流れを並行して
実行できる計算機システムのスレッド生成方式において
、実行を終了したスレッドのスタックを縮小して保存し
、再度同一プロセス内にスレッドを生成するときには、
保存されている該縮小されたスタックを用いることを特
徴とするスレッド生成方式。 3、請求項第1項又は第2項に於て、保存されているス
レッド管理テーブルがないプロセス内にスレッドを生成
する場合に於て、どのプロセスにも属していない空きス
レッド管理テーブルがシステムにないときには、他のプ
ロセスについて保存されているスレッドのテーブルを使
用できることを特徴としたスレッド生成方式。 4、請求項第1項又は第2項に於て、保存されているス
レッド管理テーブル及びスタックを使用することにより
、該スレッド管理テーブル及びスタックに対するアクセ
スのキャッシュヒット率を向上させたことを特徴とする
スレッド生成方式。 5、複数のプロセッサを有する計算機上で、1つのプロ
セス内に複数のスレッドを生成して、該複数のスレッド
各々を複数のプロセッサで実行させる並列処理方式に於
て、プログラムの並列性のある部分の前でスレッドを生
成して処理を分散し、該並列性のある部分の処理の終了
時に生成したスレッドを終了し、以後、プログラムの並
列性のある部分で上記のスレッド生成と終了を繰り返す
場合に、1度終了したスレッドに関する情報を保存して
おき、以後のスレッド生成では該保存されている情報を
利用してスレッドの生成を高速化し、処理の効率を向上
させたことを特徴とする並列処理方式。
[Claims] 1. One or more processes operate under one operating system, and each process has multiple threads that share programs and data and have their own registers and stacks. In a thread generation method for a computer system that can execute multiple program flows in parallel, the thread management table and stack of a thread that has finished execution are saved, and when a thread is generated again in the same process, the thread management table and stack are saved. A thread generation method characterized by using a management table and a stack of the thread. 2. One or more processes run under one operating system, each of which has multiple threads that share programs and data, has its own registers and stacks, and has multiple program flows. In a thread creation method for a computer system that can execute threads in parallel, when the stack of a thread that has finished execution is reduced and saved, and a thread is created again within the same process,
A thread generation method characterized by using the saved reduced stack. 3. According to claim 1 or 2, when a thread is created in a process for which there is no thread management table stored, an empty thread management table that does not belong to any process is stored in the system. A thread generation method characterized by the ability to use a table of threads stored for other processes when one is not available. 4. According to claim 1 or 2, the cache hit rate of access to the thread management table and stack is improved by using the stored thread management table and stack. Thread generation method. 5. On a computer with multiple processors, in a parallel processing method where multiple threads are generated within one process and each of the multiple threads is executed by multiple processors, a parallel part of the program is used. When a thread is generated in front of the program to distribute processing, the generated thread is terminated when the processing of the parallel part is completed, and the above thread generation and termination are repeated in the parallel part of the program thereafter. The parallel processing system is characterized in that information about threads that have completed once is saved, and the saved information is used in subsequent thread generation to speed up thread generation and improve processing efficiency. Processing method.
JP12672190A 1990-05-18 1990-05-18 Thread generation system and parallel processing system Pending JPH0423137A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP12672190A JPH0423137A (en) 1990-05-18 1990-05-18 Thread generation system and parallel processing system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP12672190A JPH0423137A (en) 1990-05-18 1990-05-18 Thread generation system and parallel processing system

Publications (1)

Publication Number Publication Date
JPH0423137A true JPH0423137A (en) 1992-01-27

Family

ID=14942229

Family Applications (1)

Application Number Title Priority Date Filing Date
JP12672190A Pending JPH0423137A (en) 1990-05-18 1990-05-18 Thread generation system and parallel processing system

Country Status (1)

Country Link
JP (1) JPH0423137A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH05313922A (en) * 1992-05-11 1993-11-26 Toshiba Corp Program execution control system
JP2009238103A (en) * 2008-03-28 2009-10-15 Internatl Business Mach Corp <Ibm> Apparatus and method for executing agent

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH05313922A (en) * 1992-05-11 1993-11-26 Toshiba Corp Program execution control system
JP2009238103A (en) * 2008-03-28 2009-10-15 Internatl Business Mach Corp <Ibm> Apparatus and method for executing agent
US8358773B2 (en) 2008-03-28 2013-01-22 International Business Machines Corporation Apparatus and method for executing agent
US9088537B2 (en) 2008-03-28 2015-07-21 International Business Machines Corporation Apparatus and method for executing agent

Similar Documents

Publication Publication Date Title
US9727338B2 (en) System and method for translating program functions for correct handling of local-scope variables and computing system incorporating the same
US4779194A (en) Event allocation mechanism for a large data processing system
US4796178A (en) Special purpose processor for off-loading many operating system functions in a large data processing system
US4685125A (en) Computer system with tasking
US5010482A (en) Multi-event mechanism for queuing happened events for a large data processing system
JP3745652B2 (en) Method for allocating memory in a parallel processing computing system
US4829422A (en) Control of multiple processors executing in parallel regions
JP3790681B2 (en) Parallel software processing system
Kaubisch et al. Quasiparallel programming
JPH03257644A (en) Main memory control method
EP0362903B1 (en) A special purpose processor for off-loading many operating system functions in a large data processing system
US20090187911A1 (en) Computer device with reserved memory for priority applications
CN112346835A (en) Scheduling processing method and system based on coroutine
US20070143436A1 (en) Method, apparatus and program storage device for providing light weight system calls to improve user mode performance
JPH0423137A (en) Thread generation system and parallel processing system
US8689230B2 (en) Determination of running status of logical processor
CN115098258B (en) Forth multitask scheduling method and device based on multi-core stack processor
Lohmann et al. Hard Real-Time Memory-Management in a Single Clock Cycle (on FPGAs)
JPS603229B2 (en) Information processing method
JPH11306040A (en) Emulator tracing device
JPH09167114A (en) Method for allocating stack of multi-thread task
WO1988007720A1 (en) Dynamically assignable shared register sets
JP2932547B2 (en) Communication register virtualization method
JP2535584B2 (en) Real memory fixed processing computer
JPH10334056A (en) Multiprocessor system