Implementation of Multiple Threads by Using Nested Functions

Bibliographic Information

Other Title
  • 入れ子関数を利用したマルチスレッドの実現
  • イレコ カンスウ オ リヨウ シタ マルチスレッド ノ ジツゲン

Search this article

Description

プログラム中に記述されたスレッドをすべてOS が提供するスレッドに対応させると大きなオーバヘッドが発生するため,ユーザレベルのマルチスレッドを使用することが有効である.本論文ではユーザレベルのスレッド,より正確には,言語処理系により実現される言語レベルのマルチスレッドの実現の方法として入れ子関数を用いる方法を提案する.入れ子関数は,定義されたときの環境でlexicalスコープの変数にアクセスすることができ,そのポインタは一種のクロージャとして利用することができる.各関数に自分と同等の計算を続けるための入れ子関数を持たせ,その入れ子関数のポインタを保存してスレッドの未処理の計算(継続)を先行して実行したい場合に呼び出せるようにすることによってマルチスレッドを実現する.また,これをGCC (GNU C Compiler )の入れ子関数をそのまま用いて実現するとオーバヘッドが無視できないので,それを改善する方法についても述べる.

Using OS-level threads for all threads described in a program incurs a large overhead. Thus it is better to use user-level threads. In this paper, we propose a method to implement user-level multiple threads, more precisely, high-level language threads realized by a language system by using nested functions. A nested function can access the lexically scoped variables in the definition-time environment and its pointer can be used as a kind of closure. To implement multiple threads, every function has its own nested function to continue its equivalent computation and save the pointer of the nested function to be called later to early execute the thread’s unprocessed computation (continuation). Since the naive implementation using GNU C Compiler’s nested functions incurs a considerable overhead, we also discuss an improvement to enhance performance.

Journal

Citations (4)*help

See more

References(8)*help

See more

Related Projects

See more

Keywords

Details 詳細情報について

Report a problem

Back to top