JP2014157434A - Program generation method, program execution method, program generation device, program generation program, program execution device, and program execution program - Google Patents
Program generation method, program execution method, program generation device, program generation program, program execution device, and program execution program Download PDFInfo
- Publication number
- JP2014157434A JP2014157434A JP2013027249A JP2013027249A JP2014157434A JP 2014157434 A JP2014157434 A JP 2014157434A JP 2013027249 A JP2013027249 A JP 2013027249A JP 2013027249 A JP2013027249 A JP 2013027249A JP 2014157434 A JP2014157434 A JP 2014157434A
- Authority
- JP
- Japan
- Prior art keywords
- program
- execution
- virtual space
- code
- data
- 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.)
- Granted
Links
Images
Landscapes
- Stored Programmes (AREA)
Abstract
Description
本発明は、例えば、プログラムの起動時間を短くするためのプログラム生成方法、プログラム実行方法、プログラム生成装置、プログラム生成プログラム、プログラム実行装置およびプログラム実行プログラムに関するものである。 The present invention relates to, for example, a program generation method, a program execution method, a program generation device, a program generation program, a program execution device, and a program execution program for shortening the startup time of a program.
CPU(Central Processing Unit)およびDRAM(Dynamic Random Access Memory)の急速な高性能化および大容量化に伴い、アプリケーションプログラムは、高機能になる一方で肥大化の一途を辿っている。特に、グラフィカルなユーザーインターフェース(GUI)を有するアプリケーションプログラムは、C++などの高級言語で記載され、総開発ステップ数が100万行を超えるものも珍しくない。 Along with the rapid increase in performance and capacity of CPUs (Central Processing Units) and DRAMs (Dynamic Random Access Memory), application programs have become highly functional and are steadily growing. In particular, an application program having a graphical user interface (GUI) is written in a high-level language such as C ++, and the total number of development steps exceeds 1 million lines is not uncommon.
しかし、プログラムが巨大化すると、高速化したCPUおよびDRAMに比して処理遅延が依存として大きいファイルシステムを介するディスクI/Oがプログラムの起動時に多大な回数必要になる。一度立ち上がってしまえば、その操作性に問題はないが、プログラムの起動時間に対してユーザーの不満が募っていた。 However, when the program becomes large, disk I / O through a file system that requires a large processing delay as a dependency on the high-speed CPU and DRAM is required many times when the program is started. Once launched, there was no problem with its operability, but users were frustrated with the startup time of the program.
そこで、ハードディスクに比べてI/O性能が格段に高いNAND型フラッシュメモリを使用する方法も考えられる。
しかし、フラッシュメモリはハードディスクに比べて依然として高価である。また、フラッシュメモリは、CMOS化(CMOS:Complementary Metal Oxide Semiconductor)において64キロバイトブロックでのデータ消去を必要とし、一つのブロックに対して10万回程度のデータの書き込みまたは消去を行うとビット情報を表す電荷膜の劣化によって使用できなくなることがある。
このため、ハードディスクの代わりにフラッシュメモリを使用した場合、アプリケーションの起動時間は大幅に短縮されるが、システムを構築するための選択として必ずしも良い選択にならない場合がある。
Therefore, a method of using a NAND flash memory that has remarkably higher I / O performance than a hard disk may be considered.
However, flash memory is still more expensive than hard disks. In addition, flash memory requires data erasure in 64 kilobyte blocks in CMOS (CMOS: Complementary Metal Oxide Semiconductor), and if bit data is written or erased about 100,000 times in one block, bit information is stored. It may become unusable due to deterioration of the charge film.
For this reason, when a flash memory is used instead of a hard disk, the startup time of an application is greatly shortened, but it may not always be a good choice for building a system.
特許文献1または特許文献2には、アクセス例外が発生したときの例外発生ブロックが共有ライブラリの実行関数部分だった場合、共有ライブラリのファイルから実行関数部分を物理ブロックに読み出すとの記載がある。
Patent Document 1 or
また、特許文献1には、ネットワークを経由してOS(Operating System)及びプログラムを主記憶装置に読み出すとの記載がある。 Japanese Patent Application Laid-Open No. 2004-228561 describes that an OS (Operating System) and a program are read out to a main storage device via a network.
また、利用機会が少ないと思われる共有ライブラリを遅延してロードするという工夫が常套的に行われている。 In addition, there is a common practice of delaying and loading a shared library that seems to have few opportunities for use.
本発明は、例えば、起動に要する時間が短いプログラムを生成できるようにすることを目的とする。 An object of the present invention is, for example, to be able to generate a program having a short time required for activation.
本発明のプログラム生成方法は、
プログラム生成部が、プログラムの実行が開始される前に仮想空間にマッピングするプログラムコードとしてメイン関数を含む一部のプログラムコードを含み、前記プログラムの実行が開始される前に仮想空間にマッピングするデータとして前記一部のプログラムコードを除いた残りのプログラムコードが記憶される補助記憶装置内の記憶領域を特定するための記憶領域情報を含み、前記プログラムの実行が開始される前に仮想空間にマッピングしないデータとして前記残りのプログラムコードを含むファイルを前記プログラムとして生成する。
The program generation method of the present invention includes:
Data including a part of program code including a main function as a program code to be mapped to the virtual space before the program execution is started, and mapped to the virtual space before the execution of the program is started Including storage area information for specifying a storage area in the auxiliary storage device in which the remaining program codes excluding the part of the program codes are stored, and mapped to the virtual space before the execution of the program is started A file including the remaining program code as data not to be generated is generated as the program.
本発明によれば、例えば、起動に要する時間が短いプログラムを生成することができる。 According to the present invention, for example, it is possible to generate a program that takes a short time to start.
実施の形態1.
起動に要する時間が短いプログラムを生成し、プログラムを早く起動できるようにする形態について説明する。
Embodiment 1 FIG.
A description will be given of a mode in which a program having a short startup time is generated so that the program can be started quickly.
図1は、実施の形態1における計算機システム100のハードウェア構成の一例を示す図である。
実施の形態1における計算機システム100のハードウェア構成の一例について、図1に基づいて説明する。
FIG. 1 is a diagram illustrating an example of a hardware configuration of a
An example of the hardware configuration of the
計算機システム100は、CPU101と、DRAM103と、ディスクコントローラ104と、ハードディスク105と、ネットワークコントローラ106とを備える。
CPU101は、バス108を介してDRAM103、ディスクコントローラ104およびネットワークコントローラ106と接続し、これらのハードウェアを制御する。
CPU101は、仮想メモリの仮想アドレスと物理メモリ(DRAM103)の物理アドレスとを相互に変換するメモリ管理ユニット(MMU102)を備える。
DRAM103は、プログラムを実行するための記憶領域として使用される主記憶装置(メモリ、物理メモリ、メインメモリともいう)である。
ハードディスク105は、プログラムまたはプログラムで使用するデータなどを記憶するための補助記憶装置である。
ディスクコントローラ104は、ハードディスク105を制御する装置である。
ネットワークコントローラ106は、ネットワーク107に接続するための装置である。
The
The
The
The
The
The
The
CPU101はCentral Processing Unitの略であり、DRAM103はDynamic Random Access Memoryの略である。
但し、計算機システム100のハードウェア構成は、図1に示した構成以外の構成であっても構わない。
However, the hardware configuration of the
図2は、実施の形態1における計算機システム100のソフトウェア構成の一例を示す図である。
実施の形態1における計算機システム100のソフトウェア構成の一例について、図2に基づいて説明する。
FIG. 2 is a diagram illustrating an example of a software configuration of the
An example of the software configuration of the
計算機システム100は、OS111と、コンパイラ113と、リンカ114と、プログラムソース115と、スタティックライブラリソース116と、共有ライブラリソース117と、実行プログラム120とを備える。
OS111は、実行プログラム120などのソフトウェアに対して計算機システム100の機能を提供するオペレーティングシステムである。
OS111は、実行プログラム120をハードディスク105またはネットワークから物理メモリにロードするプログラムローダー112を備える。
The
The OS 111 is an operating system that provides the functions of the
The OS 111 includes a
プログラムソース115は、実行プログラム120のソースコードである。
スタティックライブラリソース116は、スタティックライブラリ(例えば、標準ライブラリ)のソースコードである。
共有ライブラリソース117は、共有ライブラリのソースコードである。
The
The
The shared
コンパイラ113は、プログラムソース115と、スタティックライブラリソース116と、共有ライブラリソース117とをコンパイルするためのプログラムである。
以下、コンパイルされたプログラムソース115を「オブジェクトプログラム」という。
また、コンパイルされたスタティックライブラリソース116を「スタティックライブラリ」といい、コンパイルされた共有ライブラリソース117を「共有ライブラリ」という。
The
Hereinafter, the
The compiled
リンカ114は、オブジェクトプログラムと、スタティックライブラリと、共有ライブラリとを結合して実行プログラム120を生成するためのプログラムである。
The
実行プログラム120は、CPU101によって実行される実行形式のプログラムである。
The
図3は、実施の形態1における実行プログラム120の構成例を示す図である。
実施の形態1における実行プログラム120の構成例について、図3に基づいて説明する。
FIG. 3 is a diagram illustrating a configuration example of the
A configuration example of the
実行プログラム120は、エントリポイントテキスト121と、対応表122と、プログラムデータ123と、プログラムテキスト124とを備える。
The
エントリポイントテキスト121は、実行プログラム120のテキスト(プログラムコード、命令文、関数、ルーチンまたは機械語ともいう)のうちmain()関数を含む一部のテキストである。
エントリポイントテキスト121は、main()関数の他に、スタックポインタおよびヒープポインタを書き換える書き換えロジックと、メモリアクセス例外をハンドリングするシグナルハンドラとを含む。
エントリポイントテキスト121は、プログラムコードを格納するための.textセクションに格納される。
従来の実行プログラムでは、実行プログラム120の全てのテキストが.textセクションに格納される。
The
In addition to the main () function, the
The
In the conventional execution program, all the texts of the
プログラムデータ123は、実行プログラム120に定義されているデータの実体である。
例えば、プログラムデータ123には、エントリポイントテキスト121に定義されているデータと、スタティックライブラリに定義されているデータとが含まれる。
The
For example, the
プログラムテキスト124は、実行プログラム120のテキストのうちエントリポイントテキスト121を除く残りのテキストの実体である。
例えば、プログラムテキスト124にはスタティックライブラリが含まれる。
The
For example, the
プログラムデータ123およびプログラムテキスト124は、コメントを格納するための.commentセクションに格納される。
対応表122は、仮想メモリ(仮想空間または仮想アドレス空間ともいう)のアドレスと、実行プログラム120の.commentセクションに格納されているプログラムデータ123またはプログラムテキスト124が記憶されている記憶領域と、を対応付ける情報である。仮想メモリのアドレスを「仮想アドレス」という。
対応表122は、プログラムに定義されているデータを格納するための.dataセクションに格納される。
従来の実行プログラムでは、プログラムデータ123が.dataセクションに格納される。また、従来の実行プログラムは対応表122を備えない。
The correspondence table 122 includes the addresses of the virtual memory (also referred to as virtual space or virtual address space), the. This is information for associating the
The correspondence table 122 is a table for storing data defined in the program. Stored in the data section.
In the conventional execution program, the
図4は、実施の形態1における対応表122の一例を示す図である。
実施の形態1における対応表122について、図4に基づいて説明する。
FIG. 4 is a diagram showing an example of the correspondence table 122 in the first embodiment.
The correspondence table 122 in the first embodiment will be described with reference to FIG.
対応表122は、仮想アドレスと、実行プログラム120の.comenntセクションに格納されているプログラムデータ123またはプログラムテキスト124が記憶されている記憶領域とを対応付ける情報である。
対応表122は、「仮想アドレス」「開始オフセット」「ページ数」を対応付ける。
「仮想アドレス」は、仮想メモリの記憶領域のうちプログラムデータ123またはプログラムテキスト124がマッピングされる先頭の記憶領域を識別するアドレスを示す。
「開始オフセット」は、ハードディスク105の記憶領域のうち実行プログラム120の.commentセクションに格納されているプログラムデータ123またはプログラムテキスト124が記憶されている先頭のページを識別するページ番号を示す。
「ページ数」は、プログラムデータ123またはプログラムテキスト124が記憶されているページの数を示す。
The correspondence table 122 includes virtual addresses and. This is information for associating the
The correspondence table 122 associates “virtual address”, “start offset”, and “number of pages”.
The “virtual address” indicates an address for identifying the first storage area to which the
The “start offset” is the. A page number for identifying the first page in which
“Number of pages” indicates the number of pages in which
図5は、実施の形態1における実行プログラム120のプロセス空間130の一例を示す図である。
実施の形態1における実行プログラム120のプロセス空間130について、図5に基づいて説明する。
FIG. 5 is a diagram illustrating an example of the process space 130 of the
The process space 130 of the
プロセス空間130は、実行プログラム120を実行するプロセス用に割り当てられた仮想空間である。
プロセス空間130は、テキスト領域131と、スタック領域132と、ヒープ領域133と、bss領域134と、データ領域135とを備える。
テキスト領域131は、エントリポイントテキスト121と、プログラムテキスト124とがマッピングされる記憶領域である。
スタック領域132は、プログラムデータ123のうち局所変数の変数値がマッピングされる記憶領域である。
ヒープ領域133は、実行プログラム120の実行中に動的に確保される記憶領域である。
bss領域134は、プログラムデータ123のうち初期値が定義されていない大域変数の変数値がマッピングされる記憶領域である。
データ領域135は、プログラムデータ123のうち初期値が定義されている大域変数の変数値がマッピングされる記憶領域である。また、データ領域135には対応表122(図4参照)がマッピングされる。
The process space 130 is a virtual space allocated for a process that executes the
The process space 130 includes a
The
The
The
The
The
図6、図7は、実施の形態1における実行プログラム120の実行時のページ割り付け方法を示す概要図である。
実行プログラム120にプロセス空間130をマッピングし、プロセス空間130に対して物理ページを割り付けるページ割り付け方法の概要について、図6、図7に基づいて説明する。
6 and 7 are schematic diagrams showing a page allocation method at the time of execution of the
An overview of a page allocation method for mapping the process space 130 to the
実行プログラム120のプロセス空間130は複数の仮想ページで構成される。
プロセス空間130を構成する仮想ページのうち網掛けされている仮想ページは、実行プログラム120の一部がマッピングされ、物理メモリの記憶領域(物理ページ)が割り付けられた仮想ページを意味する。
プロセス空間130を構成する仮想ページのうち網掛けされていない仮想ページは、実行プログラム120がマッピングされておらず、物理ページが割り付けられていない仮想ページを意味する。
The process space 130 of the
A virtual page shaded among the virtual pages constituting the process space 130 means a virtual page to which a part of the
The virtual pages that are not shaded among the virtual pages constituting the process space 130 mean virtual pages to which the
テキスト領域131は、3つの領域「main text」「Libc text」「hoge text」を備える。
「main text」は、テキスト領域131にマッピングされるテキスト(プログラムコード)のうち、エントリポイントテキスト121がマッピングされる領域である。
「Libc text」は、テキスト領域131にマッピングされるテキストのうち、スタティックライブラリのテキスト(プログラムテキスト124の一部)がマッピングされる領域である。
「hoge text」は、テキスト領域131にマッピングされるテキストのうち、プログラムテキスト124(スタティックライブラリを除く。例えば、共有ライブラリ)がマッピングされる領域である。
The
“Main text” is an area to which the
“Libc text” is an area to which the text of the static library (part of the program text 124) is mapped among the texts mapped to the
The “hoge text” is an area to which program text 124 (excluding a static library, for example, a shared library) is mapped among texts mapped to the
データ領域135は、3つの領域「main data」「Libc data」「hoge data」を備える。
「main data」は、データ領域135にマッピングされるデータのうちエントリポイントテキスト121に定義されているデータがマッピングされる領域である。また、「main data」には対応表122もマッピングされる。
「Libc data」は、データ領域135にマッピングされるデータのうちスタティックライブラリに定義されているデータがマッピングされる領域である。
「hoge data」は、データ領域135の残りのデータがマッピングされる領域である。
The
“Main data” is an area to which data defined in the
“Libc data” is an area to which data defined in the static library among data mapped to the
“Hoge data” is an area to which the remaining data of the
実行プログラム120の実行が開始される前に、プログラムローダー112は、エントリポイントテキスト121を「main text」を構成する仮想ページにマッピングする。そして、OS111の仮想記憶機能は、「main text」を構成する仮想ページに物理メモリの物理ページを割り付け、割り付けた物理ページにエントリポイントテキスト121をロードする。
また、プログラムローダー112は、対応表122を「main data」を構成する仮想ページにマッピングする。そして、OS111の仮想記憶機能は、「main data」を構成する仮想ページに物理メモリの物理ページを割り付け、割り付けた物理ページに対応表122をロードする。
プログラムローダー112は、実行プログラム120の実行が開始される前に、エントリポイントテキスト121および対応表122以外のテキストまたはデータをプロセス空間130にマッピングしない(図6参照)。
Before the execution of the
In addition, the
The
エントリポイントテキスト121および対応表122以外のテキストまたはデータは、実行プログラム120の実行が開始されてアクセス命令が発生したときに、メモリアクセス例外によってプロセス空間130にマッピングされ、物理メモリにロードされる(図7参照)。
Text or data other than the
図8は、実施の形態1における計算機システム100の機能構成図である。
実施の形態1における計算機システム100の機能構成について、図8に基づいて説明する。
FIG. 8 is a functional configuration diagram of the
A functional configuration of the
計算機システム100(プログラム実行装置の一例)は、プログラム実行部141と、コンパイル部142と、リンク部143(プログラム生成部の一例)と、OS部144(開始前マッピング部、実行中マッピングの一例)と、シグナルハンドラ部145と、デバイスドライバ部146と、プログラム記憶部149とを備える。
プログラム実行部141は、実行プログラム120を実行する。
コンパイル部142は、コンパイラ113を実行することによって、プログラムソース115と、スタティックライブラリソース116と、共有ライブラリソース117とをコンパイルする。
リンク部143は、リンカ114を実行することによって、コンパイルされたプログラムソース115(オブジェクトプログラム)と、コンパイルされたスタティックライブラリソース116(スタティックライブラリ)と、コンパイルされた共有ライブラリソース117(共有ライブラリ)とを結合して実行プログラム120を生成する。
OS部144は、OS111を実行する。例えば、OS部144は、OS111のプログラムローダー112および仮想記憶機能(ページング機構を含む)を実行する。
シグナルハンドラ部145は、実行プログラム120のmain()関数に定義されるシグナルハンドラを実行する。
デバイスドライバ部146は、ディスクコントローラ104を制御するためのデバイスドライバを実行する。
プログラム記憶部149は、ハードディスク105を用いて、プログラムソース115、スタティックライブラリソース116、共有ライブラリソース117または実行プログラム120などを記憶する。
The computer system 100 (an example of a program execution device) includes a
The
The compiling
By executing the
The
The
The
The
図9は、実施の形態1におけるプログラム実行処理を示すフローチャートである。
実施の形態1におけるプログラム実行処理について、図9に基づいて説明する。
FIG. 9 is a flowchart showing a program execution process in the first embodiment.
The program execution process in Embodiment 1 is demonstrated based on FIG.
ここで、コンパイル部142およびリンク部143によって、実行プログラム120(図3参照)および対応表122(図4参照)が生成されているものとする。
Here, it is assumed that the execution program 120 (see FIG. 3) and the correspondence table 122 (see FIG. 4) are generated by the compiling
S110において、OS部144は、実行プログラム120を実行するためのプロセス空間130(図5参照)を生成する。
S110の後、処理はS120に進む。
In S110, the
After S110, the process proceeds to S120.
S120において、OS部144は、以下のようにエントリポイントテキスト121および対応表122をロードする。
In S120, the
OS部144は、実行プログラム120の.textセクションに格納されたエントリポイントテキスト121を、プロセス空間130のテキスト領域131にある「main text」の仮想ページにマッピングする。
OS部144は、実行プログラム120の.textセクションに格納されたエントリポイントテキスト121を、プロセス空間130のテキスト領域131にある「main text」の仮想ページにマッピングする。
OS部144は、物理メモリ(DRAM103)の物理ページを「main text」の仮想ページに割り付ける(図6参照)。
そして、OS部144は、プログラム記憶部149(ハードディスク105)からエントリポイントテキスト121を読み出し、読み出したエントリポイントテキスト121を物理ページに書き込む。つまり、OS部144は、エントリポイントテキスト121を物理ページにロードする。
The
The
The
Then, the
また、OS部144は、スタック領域132を指定するためのスタックポインタに「main text」の直後の仮想アドレスを設定する(図6の(1)参照)。
Further, the
さらに、OS部144は、実行するプログラムコードを指定するためのエントリポインタに、エントリポイントテキスト121に含まれる書き換えロジックの仮想アドレスを設定する。書き換えロジックが実行された後、main()関数が実行される。但し、OS部144がエントリポインタにmain()関数の仮想アドレスを設定し、main()関数から書き換えロジックが呼び出されても構わない。
Further, the
同様に、OS部144は、実行プログラム120の.dataセクションに格納された対応表122を、プロセス空間130のデータ領域135にある「main data」の仮想ページにマッピングする。
OS部144は、物理ページを「main data」の仮想ページに割り付ける(図6参照)。
そして、OS部144は、プログラム記憶部149から物理ページに対応表122をロードする。
また、OS部144は、ヒープ領域133を指定するためのヒープポインタに「main data」の直前の仮想アドレスを設定する(図6の(2)参照)。
S120の後、処理はS130に進む。
Similarly, the
The
Then, the
Further, the
After S120, the process proceeds to S130.
S130において、プログラム実行部141は、実行プログラム120の実行を開始する。つまり、プログラム実行部141は、エントリポインタに設定されている書き換えロジック(または、main()関数から呼び出された書き換えロジック)を実行する。
In S <b> 130, the
プログラム実行部141は、書き換えロジックを実行することによってスタック領域132の正しい仮想アドレスをスタックポインタに設定すると共に、ヒープ領域133の正しい仮想アドレスをヒープポインタに設定する。
つまり、プログラム実行部141は、スタックポインタに設定されている仮想アドレスをテキスト領域131の直後の仮想アドレスに更新し(図6の(3)参照)、ヒープポインタに設定されている仮想アドレスをbss領域134の直前の仮想アドレスに更新する(図6の(4)参照)。
これにより、既存のプログラムローダーに書き換えロジックの機能を追加しなくても、既存のプログラムローダーを計算機システム100のプログラムローダー112として使用することができる。
The
That is, the
Thus, the existing program loader can be used as the
プログラム実行部141は、書き換えロジックの実行後、書き換えロジックの次のプログラムコードを実行する。
S130の後、処理はS140に進む。
After executing the rewrite logic, the
After S130, the process proceeds to S140.
S140において、仮想ページがマッピングされていなプログラムデータ123またはプログラムテキスト124にアクセスするアクセス命令(call、jump、load、storeなど)が実行される場合、OS部144は、アクセスされる仮想アドレスをシグナルハンドラ部145に通知することによって、メモリアクセス違反を発生させる。
以下、S140でアクセスされるプログラムデータ123またはプログラムテキスト124を「アクセス違反データ」とし、アクセス違反データの仮想アドレスを「アクセス違反アドレス」とする。
メモリアクセス違反が発生した場合(YES)、処理はS150に進む。
メモリアクセス違反が発生しない場合(NO)、処理はS170に進む。
In S140, when an access instruction (call, jump, load, store, etc.) for accessing the
Hereinafter, the
If a memory access violation has occurred (YES), the process proceeds to S150.
If no memory access violation occurs (NO), the process proceeds to S170.
S150において、シグナルハンドラ部145は、main()関数に定義されているシグナルハンドラを実行することによって以下のような処理を行う。
In S150, the
シグナルハンドラ部145は、対応表122(図4参照)から、アクセス違反アドレスと同じ仮想アドレスに対応付けられた開始オフセットおよびページ数を取得する。
そして、シグナルハンドラ部145は、取得した開始オフセットおよびページ数によって特定されるハードディスク105内のページ(アクセス違反データ)を、アクセス違反アドレスによって特定される仮想ページにマッピングし、仮想ページに物理ページを割り付ける。
The
Then, the
例えば、アクセス違反アドレスが「0xc0077000」である場合、シグナルハンドラ部145は、対応表122から開始オフセット「114」およびページ数「56」を取得する。
そして、シグナルハンドラ部145は、ハードディスク105の「114」番目のページから「169」番目のページまでの「56」個のページを仮想ページにマッピングし、仮想ページに物理ページを割り付ける。
For example, when the access violation address is “0xc0077000”, the
The
以下、S150で取得された開始オフセットを「対象開始オフセット」とし、S150で取得されたページ数を「対象ページ数」とする。
S150の後、処理はS160に進む。
Hereinafter, the start offset acquired in S150 is referred to as “target start offset”, and the number of pages acquired in S150 is referred to as “target page number”.
After S150, the process proceeds to S160.
S160において、OS部144は、シグナルハンドラ部145から対象開始オフセットおよび対象ページ数を取得する。
OS部144は、OS111のページング機能を用いて、ハードディスク105のセクタ(記憶領域)のうち対象開始オフセットおよび対象ページ数によって特定されるページに対応するセクタを特定する。
以下、特定したセクタを「対象セクタ」とし、特定したセクタを識別する識別子を「対象セクタ番号」とする。
In S160, the
The
Hereinafter, the specified sector is referred to as “target sector”, and the identifier for identifying the specified sector is referred to as “target sector number”.
OS部144は、アクセス違反アドレスと対象セクタ番号とをデバイスドライバ部146に通知する。
The
デバイスドライバ部146は、MMU102を用いてアクセス違反アドレスを物理アドレスに変換し、物理アドレスと対象セクタ番号とを含んだI/O命令をディスクコントローラ104に入力する。
The
ディスクコントローラ104は、I/O命令に従って、ハードディスク105の対象セクタに記憶されているアクセス違反データを、物理アドレスで識別される物理ページにロードする。
例えば、ディスクコントローラ104は、DMA(Direct Memory Access)機能を用いて、アクセス違反データのロードを行う。
S160の後、処理はS170に進む。
In accordance with the I / O instruction, the
For example, the
After S160, the process proceeds to S170.
S170において、プログラム実行部141は、実行プログラム120の実行を続ける。
S170の後、処理はS171に進む。
In S170, the
After S170, the process proceeds to S171.
S171において、実行プログラム120の実行が終了した場合(YES)、プログラム実行処理は終了する。
また、実行プログラム120の実行が終了しない場合(NO)、処理はS140に戻る。
In S171, when the execution of the
If execution of the
以上のように、実施の形態1における計算機システム100は、プログラムの実行において必要なページのみを使用し、冗長なコピーを発生させない。結果として、巨大なアプリケーションになればなるほど、従来例に比較して高速に起動し、且つ、無駄なメモリ消費を抑えることができる。
As described above, the
実施の形態1において、計算機システム100が備えるハードディスク105に実行プログラム120を記憶しておく形態について説明した。
但し、実行プログラム120(または実行プログラム120の一部)はネットワーク107に接続された他の記憶装置に記憶しておいても構わない。この場合、計算機システム100はネットワーク107を介して他の記憶装置から実行プログラム120(または実行プログラム120の一部)を取得する。
In the first embodiment, the form in which the
However, the execution program 120 (or a part of the execution program 120) may be stored in another storage device connected to the
図10は、従来におけるプログラム実行時のページ割り付け方法の概要を示す図である。
従来のプログラムの実行開始時におけるページ割り付け方法の概要について、図10に基づいて説明する。
FIG. 10 is a diagram showing an outline of a conventional page allocation method during program execution.
An overview of a page allocation method at the start of execution of a conventional program will be described with reference to FIG.
従来、プログラムが実行される場合、プログラムの実行が開始される前に、プロセス空間および実行コンテキストが確保される。
また、プロセス空間のうちプログラムのテキスト用の領域「main text」およびスタティックライブラリのテキスト用の領域「Libc text」に物理ページが割り付けられ、プログラムのテキストおよびスタティックライブラリのテキストがロードされる。
また、プログラムのデータ用の領域「main data」、スタティックライブラリのデータ用の領域「Libc data」および共有ライブラリのデータ用の領域「hoge data」に物理ページが割り付けられ、プログラム、スタティックライブラリおよび共有ライブラリのデータがロードされる。
さらに、プログラムのプロセス空間とは別の仮想空間に設けられる共有ライブラリのテキスト用の領域「hoge text」に物理ページが割り付けられ、共有ライブラリのテキストがロードされる。
つまり、従来は、プログラムの実行が開始される前に、全てのプログラム、スタティックライブラリおよび共有ライブラリが物理メモリにロードされる。
Conventionally, when a program is executed, a process space and an execution context are secured before the execution of the program is started.
Also, physical pages are allocated to the program text area “main text” and the static library text area “Libc text” in the process space, and the program text and the static library text are loaded.
Further, physical pages are allocated to the program data area “main data”, the static library data area “Libc data”, and the shared library data area “hoge data”, and the program, static library, and shared library Data is loaded.
Furthermore, a physical page is allocated to the text area “hoge text” of the shared library provided in a virtual space different from the process space of the program, and the text of the shared library is loaded.
In other words, conventionally, all programs, static libraries, and shared libraries are loaded into physical memory before program execution is started.
なお、スタック領域はテキスト領域「main text」「Libc text」の直後に設けられ、bss領域はデータ領域「main data」「Libc data」「hoge data」の直前に設けられ、ヒープ領域はbss領域の直前に設けられる。
また、プログラムは、エントリポインタで指定されるmain()関数から順に実行される。
The stack area is provided immediately after the text areas “main text” and “Libc text”, the bss area is provided immediately before the data areas “main data”, “Libc data”, and “hoge data”, and the heap area is the bss area. It is provided immediately before.
The program is executed in order from the main () function specified by the entry pointer.
プログラムの実行が開始された後、物理メモリが不足した場合、共有ライブラリがハードディスクに退避される。
また、ハードディスクに退避された共有ライブラリが使用される場合、共有ライブラリをロードするためのロード関数が実行され、共有ライブラリがハードディスクから物理メモリにロードされる。
After running the program, if the physical memory is insufficient, the shared library is saved to the hard disk.
When the shared library saved on the hard disk is used, a load function for loading the shared library is executed, and the shared library is loaded from the hard disk to the physical memory.
次に、ハードディスクから物理メモリにデータ(例えば、共有ライブラリ)をロードするファイルシステムについて説明する。
ファイルシステムは、ハードディスクの1セクタに相当する512バイトのバッファメモリをOSの機能で管理し、このOSのバッファメモリを用いてハードディスクから物理メモリに共有ライブラリをロードする。
つまり、ファイルシステムは、共有ライブラリをロードするためにread()またはwrite()などのOSのシステムコールが呼び出されると、ハードディスクのセクタ単位で共有ライブラリをバッファメモリにコピーすると共に、共有ライブラリをバッファメモリから物理メモリにコピーする。
Next, a file system for loading data (for example, a shared library) from the hard disk into the physical memory will be described.
The file system manages a 512-byte buffer memory corresponding to one sector of the hard disk by the function of the OS, and loads the shared library from the hard disk to the physical memory using the buffer memory of the OS.
That is, when an OS system call such as read () or write () is called to load the shared library, the file system copies the shared library to the buffer memory in units of sectors on the hard disk and buffers the shared library. Copy from memory to physical memory.
但し、近年のファイルシステムは、OSのバッファメモリを使用する代わりに、物理メモリの1ページに相当するLibc用のデータバッファを使用する。Libcとは、C言語で用意された標準ライブラリである。
例えば、ファイルシステムは、共有ライブラリをロードするためのロード関数が実行されると、ハードディスク内のファイルうち共有ライブラリを含んだファイルをopen()関数でオープンし、共有ライブラリをread()関数でハードディスクから読み出し、読み出した共有ライブラリをLibc用のデータバッファにコピーする。
さらに、ファイルシステムは、共有ライブラリをLibc用のデータバッファからヒープ領域またはテキスト領域「hoge text」に割り付けられた物理メモリにコピーする。
つまり、ファイルシステムは、共有ライブラリを物理メモリにロードするために、物理メモリのページ毎に、1回のディスクI/O(ハードディスクからの読み出し)および2回のデータコピー(ハードディスクからデータバッファへのコピー、データバッファから物理メモリへのコピー)を行う。
However, recent file systems use a Libc data buffer corresponding to one page of physical memory instead of using the OS buffer memory. Libc is a standard library prepared in C language.
For example, when a load function for loading a shared library is executed, the file system opens a file including the shared library among files on the hard disk with the open () function, and opens the shared library with the read () function. The shared library that has been read is copied to the data buffer for Libc.
Further, the file system copies the shared library from the data buffer for Libc to the physical memory allocated to the heap area or the text area “hoge text”.
That is, the file system loads one disk I / O (read from the hard disk) and two data copies (from the hard disk to the data buffer) for each page of the physical memory in order to load the shared library into the physical memory. Copy, copy from data buffer to physical memory).
実施の形態1において、例えば、以下のようなプログラム生成方法およびプログラム実行方法について説明した。括弧内に、対応する構成の符号または名称を記す。
プログラム生成部(143)が、プログラム(120)の実行が開始される前に仮想空間にマッピングするプログラムコードとしてメイン関数(main()関数)を含む一部のプログラムコード(121)を含み、前記プログラムの実行が開始される前に仮想空間にマッピングするデータとして前記一部のプログラムコードを除いた残りのプログラムコードが記憶される補助記憶装置(105)内の記憶領域を特定するための記憶領域情報(122)を含み、前記プログラムの実行が開始される前に仮想空間にマッピングしないデータとして前記残りのプログラムコード(124)を含むファイルを前記プログラムとして生成する。
In the first embodiment, for example, the following program generation method and program execution method have been described. The code or name of the corresponding configuration is shown in parentheses.
The program generation unit (143) includes a part of program code (121) including a main function (main () function) as a program code to be mapped to the virtual space before the execution of the program (120) is started, A storage area for specifying a storage area in the auxiliary storage device (105) in which the remaining program codes excluding the part of the program codes are stored as data to be mapped in the virtual space before the execution of the program is started A file including the information (122) and including the remaining program code (124) as data not mapped in the virtual space before the execution of the program is started is generated as the program.
開始前マッピング部(144)が、実行プログラムの実行が開始される前に、前記実行プログラムのプログラムコードのうちメイン関数を含む一部のプログラムコードと、前記実行プログラムのプログラムコードのうち前記一部のプログラムコードを除いた残りのプログラムコードが記憶される補助記憶装置内の記憶領域を特定するための記憶領域情報と、を仮想空間にマッピングする。
プログラム実行部(141)が、前記実行プログラムを実行する。
実行中マッピング部(144)が、前記プログラム実行部が前記開始前マッピング部によって仮想空間にマッピングされていない前記残りのプログラムコードに含まれるプログラムコードを実行コードとして実行するときに、前記開始前マッピング部によって仮想空間にマッピングされた前記記憶領域情報を用いて前記実行コードを仮想空間にマッピングする。
Before the
A program execution unit (141) executes the execution program.
When the executing mapping unit (144) executes, as the execution code, the program code included in the remaining program code that is not mapped in the virtual space by the pre-start mapping unit, the pre-start mapping The execution code is mapped to the virtual space using the storage area information mapped to the virtual space by the unit.
実施の形態1においてフローチャートなどに含まれている矢印は主としてデータや信号の入出力を示す。フローチャートなどに基づいて説明する処理はハードウェアを用いて実行される。
実施の形態1において「〜部」として説明するものは「〜回路」「〜装置」「〜ユニット」「〜ステップ」または「〜処理」に置き換えてもよい。すなわち、「〜部」として説明するものは、ファームウェア、ソフトウェア、ハードウェアまたはこれらの組み合わせのいずれで実装されても構わない。
In the first embodiment, the arrows included in the flowchart mainly indicate input / output of data and signals. The processing described based on the flowchart and the like is executed using hardware.
What is described as “˜unit” in the first embodiment may be replaced with “˜circuit”, “˜device”, “˜unit”, “˜step”, or “˜processing”. That is, what is described as “to part” may be implemented by any of firmware, software, hardware, or a combination thereof.
以降の実施の形態では、実施の形態1における計算機システム100について説明を補足する。
In the following embodiments, the description of the
実施の形態2.
実施の形態1で説明したように、計算機システム100は、オペレーティングシステムの仮想記憶機能をそのまま使用することによって、プログラムを実行するためのワーキングセット(メモリ領域)を管理することができる。
なお、計算機システム100は、仮想記憶装置として利用するバックストアの所在を制限しない。例えば、計算機システム100は、インターネットなどのネットワークに接続するサーバーを仮想記憶装置として用いても構わない。つまり、計算機システム100は、実行プログラム120をハードディスク105の代わりにサーバーから物理メモリにロードしても構わない。
As described in the first embodiment, the
The
実施の形態2において、例えば、以下のような計算機システム100について説明した。
計算機システム100は、ライブラリテキストおよびデータのページデータを実行プログラムファイルのレプリカとしてネットワーク上に配置し、当該ページデータをネットワーク経由で取得する。
In the second embodiment, for example, the following
The
実施の形態3.
実施の形態1で説明したように、計算機システム100は、オペレーティングシステムの仕様を問わないため、既存のオペレーティングシステムを使用することができる。
つまり、計算機システム100のリンカ114は、既存のCPU101、MMU102およびOS111によって実現される仮想記憶機構の実装に則って実装することが可能である。
例えば、計算機システム100は、インテル社またはAMD社のCPU101、マイクロソフト社またはHP社のOS111、HP社のPA−RISCインバーティッドテーブルアーキテクチャ、IBM社のサーバーなどを適用することが可能である。
As described in the first embodiment, the
That is, the
For example, the
実施の形態3において、例えば、以下のような計算機システム100について説明した。
計算機システム100は、実行プログラムを実行することによってスタックポインタとヒープポインタとを変更し、ライブラリのテキスト配置領域とデータ配置領域を確保する。これにより、計算機システム100は、既存システムのプログラムのローダー機能の変更を必要としない。
In the third embodiment, for example, the following
The
実施の形態4.
実施の形態1では、計算機システム100が実行プログラム120を一つのプロセス空間で実行される場合について説明した。
但し、計算機システム100は、実行プログラム120を複数のプロセス空間で実行することもできる。例えば、計算機システム100は、ウェブブラウザの実行プログラム120を複数のプロセス空間で実行することによって、ウェブブラウザとして機能するウィンドウを複数表示することもできる。
In the first embodiment, the case where the
However, the
図11は、実施の形態4におけるプロセス空間を示す図である。
計算機システム100は、実行プログラム120の実行を開始するときに第一のプロセス空間を生成し、生成した第一のプロセス空間を用いて実行プログラム120を実行する。
さらに、計算機システム100は、第一のプロセス空間を用いて実行プログラム120を実行しているときに第二のプロセスを生成し、生成した第二のプロセス空間を用いて第一のプロセス空間とは別に実行プログラム120を実行する。
なお、第一のプロセス空間と第二のプロセス空間とで共有することができる領域「hoge text」は、第一のプロセス空間と第二のプロセス空間とは別の仮想領域に設けてもよい。
FIG. 11 is a diagram showing a process space in the fourth embodiment.
The
Furthermore, the
The area “hoge text” that can be shared by the first process space and the second process space may be provided in a virtual area different from the first process space and the second process space.
実施の形態4において、例えば、以下のような計算機システム100について説明した。
計算機システム100は、実行プログラムを2つ以上実行するとき、当該テキストが割り当てられている物理メモリのページを共有する。
In the fourth embodiment, for example, the following
When the
実施の形態5.
共有ライブラリを利用する利点の一つとして、次のような事項が挙げられる。共有ライブラリが何らかの理由で更新されても共有ライブラリのAPI(Application Program Interface)に変更がない場合、更新された共有ライブラリを利用するアプリケーションプログラムをリコンパイルする必要が無い。
実施の形態1で説明した計算機システム100においても、APIの変更を除いた共有ライブラリの更新に伴ってアプリケーションプログラム(実行プログラム120)をリコンパイルする必要は無い。但し、計算機システム100は、更新後の共有ライブラリを利用するため、新たにリンカ114を実行することによって新たにアプリケーションプログラムを生成する必要がある。
Embodiment 5 FIG.
One of the advantages of using a shared library is as follows. Even if the shared library is updated for some reason, if there is no change in the API (Application Program Interface) of the shared library, there is no need to recompile an application program that uses the updated shared library.
In the
実施の形態5において、例えば、以下のような計算機システム100について説明した。
計算機システム100は、共有ライブラリに変更があっても当該ライブラリのインクリメンタルな変更だけを行い、実行プログラムのリコンパイルを必要としない。
In the fifth embodiment, for example, the following
Even if there is a change in the shared library, the
実施の形態6.
実施の形態1で説明した計算機システム100は、アプリケーションプログラム(実行プログラム120)を仮想空間に貼り付け、その実行に必要なページのみを有効化することによって、アプリケーションプログラムの起動時間の短縮およびメモリ消費の最適化を図るものである。
計算機システム100は既存のシステムに手を加えずに上記の効果を奏することができるが、既存のシステムに手を加えて計算機システム100を構築しても構わない。
Embodiment 6 FIG.
The
The
実施の形態7.
計算機システム100は、実行プログラム120の実行時にメモリアクセス違反が発生した仮想アドレスを記憶し、記憶した仮想アドレスで識別される仮想領域に設定されるテキストまたはデータを.textセクションまたは.dataセクションに格納するように実行プログラム120を再構成してもよい。また、計算機システム100は、記憶した仮想アドレスに設定されるテキストまたはデータをアドレスの記憶番にソートしてもよい。
これにより、計算機システム100は、実行プログラム120の実行を開始する前に、実行プログラム120を実行中に使用する可能性が高いテキストまたはデータを物理メモリにロードすることができる。つまり、計算機システム100は、実行プログラム120の実行中に発生するメモリアクセス違反を抑制することができる。
Embodiment 7 FIG.
The
As a result, the
実施の形態7において、例えば、以下のような計算機システム100について説明した。
計算機システム100は、テキスト及びデータのメモリアクセス違反が発生したアドレスを取得し、そのアドレスに該当するシンボル単位でテキスト及びデータをソートし、プログラムを再リンクする。
In the seventh embodiment, for example, the following
The
実施の形態8.
計算機システム100は、マイクロソフト社が提供するリンカを使用し、マイクロソフト社のPE実行ファイル形式を踏襲してアプリケーションプログラム(実行プログラム120)を生成してもよい。
計算機システム100は、マイクロソフト社のオペレーティングシステム「Windows(登録商標)」上で動作するすべてのアプリケーションプログラムに対して適用することが可能である。
例えば、「Windows(登録商標)」上で動作するアプリケーションプログラムを開発する開発者は、マイクロソフト社の「Visual Studio(登録商標)」などの開発環境を用いて従来通りにプログラムの作成および試験を行い、製品としてしかるべき品質のアプリケーションプログラムを開発すればよい。そして、開発者は、マイクロソフト社が提供するリンカを使用し、PE実行ファイル形式のアプリケーションプログラムを作成し、作成したアプリケーションプログラムを製品として出荷する。
Embodiment 8 FIG.
The
The
For example, a developer who develops an application program that runs on "Windows (registered trademark)" creates and tests a program as usual using a development environment such as "Visual Studio (registered trademark)" of Microsoft Corporation. An application program of an appropriate quality as a product may be developed. Then, the developer creates a PE execution file format application program using a linker provided by Microsoft, and ships the created application program as a product.
実施の形態8において、例えば、以下のような計算機システム100について説明した。
計算機システム100は、実行プログラム形式を解釈可能なローダーを有する。
In the eighth embodiment, for example, the following
The
実施の形態9.
実施の形態1とは異なる実行プログラム120の形態について説明する。
実施の形態1と異なる事項について主に説明し、説明を省略する事項については実施の形態1と同様である。
Embodiment 9 FIG.
The form of the
Items different from the first embodiment will be mainly described, and items omitted will be the same as those in the first embodiment.
図12は、実施の形態9における第一の実行プログラム120Aおよび第二の実行プログラム120Bを示す図である。
図12に示すように、リンク部143は、エントリポイントテキスト121と対応表122とから成る第一の実行プログラム120Aと、プログラムテキスト124とプログラムデータ123とから成る第二の実行プログラム120Bとを生成する。
エントリポイントテキスト121のmain()関数は、プロセス空間130をコピーするためのシステムコール(fork)と、コピーされたプロセス空間130にプログラムテキスト124およびプログラムデータ123をマッピングするマッピングロジックとを含んでいる。
FIG. 12 is a diagram showing the first execution program 120A and the second execution program 120B in the ninth embodiment.
As shown in FIG. 12, the
The main () function of the
図13は、実施の形態9における第一のプロセス空間130Aと第二のプロセス空間130Bとを示す図である。
図13において、OS部144は、第一の実行プログラム120A(図12参照)を実行するための第一のプロセス空間130Aを生成する。
OS部144は、第一の実行プログラム120Aのエントリポイントテキスト121を「main text」の仮想ページにマッピングし、対応表122を「main data」にマッピングする。
OS部144は、「main text」の仮想ページおよび「main data」の仮想ページに物理ページを割り付け、割り付けた物理ページにエントリポイントテキスト121および対応表122をロードする。
FIG. 13 is a diagram showing a first process space 130A and a second process space 130B in the ninth embodiment.
In FIG. 13, the
The
The
プログラム実行部141は、第一のプロセス空間130Aのエントリポイントテキスト121に含まれるmain()関数を実行する。
これにより、第一のプロセス空間130Aをコピーして第二のプロセス空間130Bが生成され、対応表122を用いて第二のプロセス空間130Bにプログラムテキスト124とプログラムデータ123とがマッピングされる。
The
Thereby, the first process space 130A is copied to generate the second process space 130B, and the
その後、プログラム実行部141は、第二のプロセス空間130Bにマッピングされた第二の実行プログラム120Bを実行する。
Thereafter, the
実施の形態9において、エントリポイントテキスト121と対応表122とから成る最小の実行プログラムと、プログラムテキスト124とプログラムデータ123とから成る通常の実行プログラムとを生成することを説明した。
また、最小の実行プログラムのプロセス空間をコピーすることによって、通常のプログラムを実行するためのプロセス空間を生成することを説明した。
In the ninth embodiment, it has been described that the minimum execution program composed of the
Further, it has been described that the process space for executing a normal program is generated by copying the process space of the smallest execution program.
各実施の形態において、例えば、以下の事項を説明した。
従来のオペレーティングシステム機能により、共有ライブラリのテキストのメモリ上へのロード、利用プロセスへのデータコピーなどのサービスを回避し、スタティックライブラリを含め、全てのライブラリを当該実行プログラムの仮想アドレス空間の中に配置し、アドレスを解決して一つの実行プログラムとする。
In each embodiment, for example, the following matters have been described.
Conventional operating system functions avoid services such as loading shared library text into memory and copying data to the process of use, and all libraries, including static libraries, are in the virtual address space of the executable program. Arrange and resolve the address to make one execution program.
リンカプログラムはmain()関数に先立って、全てのテキストが格納されるテキスト位置にスタックポインタを初期化する論理とライブラリ部分のデータを追加し、BSS格納に必要な位置にヒープポインタを更新する論理を追加する。 Prior to the main () function, the linker program adds logic for initializing the stack pointer at the text position where all text is stored and data for the library part, and logic for updating the heap pointer at the position required for BSS storage. Add
main()関数で記述されるプログラムは最小限である。
リンカプログラムは実行プログラムの.textセクションに当該プログラムのテキストを格納し、.dataセクションに当該プログラムのデータと、ライブラリプログラムのテキスト、データおよびBSSの対応表とを格納する。
また、対応表にポイントされるライブラリのテキストとデータは.commentセクションに格納する。
The program described by the main () function is minimal.
A linker program is an executable program. Store the text of the program in the text section; In the data section, the data of the program and the correspondence table of the text, data and BSS of the library program are stored.
The text and data of the library pointed to the correspondence table is. Store in the comment section.
システムプログラムのローダーは.textセクションと.dataセクションとを確保したプロセス空間にロードする。
システムが当該プロセスに実行コンテキストを与えると、実行プログラムはスタックポインタおよびヒープポインタの更新論理により、ライブラリテキスト、データおよびBSSの格納領域を確保する。
The system program loader is. text section and. The data section is loaded into the secured process space.
When the system gives an execution context to the process, the execution program secures storage areas for library text, data, and BSS by the update logic of the stack pointer and heap pointer.
プログラムの実行により、テキスト参照、あるいはデータ参照・書き込みでメモリアクセス違反の例外が発生する。 By executing the program, a memory access violation exception occurs in text reference or data reference / write.
実行プログラムにはメモリアクセス違反の例外処理ハンドラが定義されている。
ハンドラは、メモリアクセス違反が発生したアドレスをもって対応表を参照し、.commentセクションにあるテキストあるいはデータを、当該アドレスを含むページにマップする。そして、システムのページング機構がファイルシステムを介してハードディスクコントローラにDMA I/O命令を発行する事により、実行プログラムファイルの当該ページ部分の内容がハードディスクの当該セクタから当該ページにDMAでデータ書き込みされる。
An exception handler for memory access violation is defined in the execution program.
The handler refers to the correspondence table with the address where the memory access violation occurred. The text or data in the comment section is mapped to the page containing the address. Then, when the system paging mechanism issues a DMA I / O instruction to the hard disk controller via the file system, the contents of the page portion of the execution program file are written into the page from the sector of the hard disk by DMA. .
実行プログラムは、スタックポインタおよびヒープポインタを更新するタイミングで実行プログラムのライブラリテキストとデータの全域とをプロセス空間にマップしておいても良い。 The execution program may map the library text of the execution program and the entire data in the process space at the timing of updating the stack pointer and the heap pointer.
前記実行プログラムのレプリカはネットワーク上に置かれていても良い。 The replica of the execution program may be placed on the network.
巨大なアプリケーションの共有ライブラリはシステムの上で当該プログラムでのみ使用される物が多い。
しかしながら、同一のシステム上で複数の同一アプリケーションが複数利用されることがある。
この状況を鑑みて、実行プログラムは自身の同時複数実行がどれほどなされるか統計情報を取る。
統計情報から2以上同時に実行されることが多いと判断したときは、実行プログラムはライブラリ用テキストのページメモリを共有メモリとして確保する。
これにより、2つ目以降の実行プログラムはライブラリテキストのメモリ空間を共用することができる。
Many shared libraries for huge applications are used only by the program on the system.
However, a plurality of the same applications may be used on the same system.
In view of this situation, the execution program takes statistical information on how many simultaneous executions of itself are performed.
When it is determined from the statistical information that two or more are often executed simultaneously, the execution program reserves the page memory of the library text as a shared memory.
Thus, the second and subsequent execution programs can share the library text memory space.
ライブラリ用の共有メモリ領域を使用する実行方式は実行プログラムのプロセス数に関わらず常に適用する運用も可能である。 The execution method using the shared memory area for the library can always be applied regardless of the number of processes of the execution program.
リンカプログラムにより既存の共有ライブラリを実行プログラムに再構成する。
しかし、使用する共有ライブラリに変更が発生した場合は、リンカプログラムの再実行を行う。
The linker program reconfigures the existing shared library into an execution program.
However, if a change occurs in the shared library to be used, the linker program is re-executed.
各実施の形態は、既存システムの変更なしに奏効することを特徴とする。
しかし、CPUおよびDRAMの高性能化および大容量化によるプログラミングパラダイムの変化を否定するものではない。システムプログラム、特に実行時にプロセス空間の確保と実行プログラムのマッピングとを行うローダーを実装することも許容する。
Each embodiment is characterized in that it is effective without changing the existing system.
However, this does not deny the change in programming paradigm due to higher performance and larger capacity of CPUs and DRAMs. It is also acceptable to implement a system program, particularly a loader that secures process space and maps the execution program during execution.
計算機システム100はプログラム実行によってメモリアクセス違反を発生させたアドレスを記憶し、そのアドレスが含まれるシンボルと当該シンボルにより修飾されるテキスト及びデータをメモリアクセス違反の発生順に再リンクする。これにより、更に効率の高いページメモリ使用を可能にする。
The
各実施の形態により、巨大なアプリケーションの起動が非常に高速になる。
また、アプリケーションが自らメモリ使用を管理できるので、メモリ使用の制約が厳しい組み込みシステムにおけるアプリケーションにおいても、ワーキングセット管理をアプリケーション機能として実装することが可能である。
According to each embodiment, the start-up of a huge application becomes very fast.
Further, since the application can manage the memory use by itself, the working set management can be implemented as an application function even in an application in an embedded system in which restrictions on the memory use are severe.
各実施の形態において、例えば、以下のようなプログラム生成方法およびプログラム実行方法について説明した。
実行形式のプログラムを生成するリンカと実行形式のプログラムをメモリ上にロードするローダーとから構成され、プログラムがライブラリテキスト、データまたはBSSを参照する際に発生するメモリアクセス例外によって、プログラムアドレス空間の当該部分のページメモリの確保および当該データのロードを行う。
リンカは、実行プログラム生成時に必要とするスタティックライブラリおよび共有ライブラリを一つのプログラムアドレス空間に配置し、共有ライブラリを含めてアドレス解決のみを行い、実行プログラムに格納されているロードアドレスと当該ライブラリのテキストおよびデータとを特定する手段である対応表をデータとして生成し、実行形式のプログラムを生成する。
In each embodiment, for example, the following program generation method and program execution method have been described.
A linker that generates an executable program and a loader that loads the executable program into memory. The memory address exception that occurs when the program references library text, data, or BSS causes the program address space A part of page memory is secured and the data is loaded.
The linker places the static library and shared library required when generating the execution program in one program address space, performs address resolution only including the shared library, and stores the load address stored in the execution program and the text of the library. A correspondence table, which is a means for specifying the data, is generated as data, and an executable program is generated.
ライブラリテキストおよびデータのページデータを実行プログラムファイルのレプリカとしてネットワーク上に配置し、当該ページデータをネットワーク経由で取得する。 The library text and the page data of the data are arranged on the network as a replica of the execution program file, and the page data is acquired via the network.
実行プログラム自身がスタックポインタおよびヒープ領域ポインタを変更することによって、ライブラリのテキスト配置領域およびデータ配置領域を確保する。
これにより、既存システムのプログラムのローダー機能を変更する必要がない。
The execution program itself changes the stack pointer and heap area pointer to secure the text arrangement area and data arrangement area of the library.
Thereby, it is not necessary to change the loader function of the program of the existing system.
同一のシステム上にて、実行プログラムが2以上実行されるときは、当該テキストが割り当てられている物理メモリページを共有する。 When two or more execution programs are executed on the same system, the physical memory page to which the text is assigned is shared.
ロードアドレスとテキストおよびデータとの対応表と、その内容を更新する手段とを有する。
共有ライブラリ部分に変更があっても当該ライブラリのインクリメンタルな変更のみで、実行プログラムの他のプログラムのリコンパイルは必要としない。
It has a correspondence table of load addresses, texts and data, and means for updating the contents.
Even if there is a change in the shared library portion, it is only an incremental change of the library, and no recompilation of other programs in the execution program is required.
システムに実行プログラム形式を解釈可能なローダーを有する。 The system has a loader that can interpret the executable program format.
実行プログラムは、プログラムの実行によってテキスト及びデータのメモリアクセス違反を発生させたアドレス情報を取得し、そのアドレスに該当するシンボル単位でテキスト及びデータをソートし、テキスト及びデータを再リンクする。 The execution program acquires the address information that caused the memory access violation of the text and data by executing the program, sorts the text and data in symbol units corresponding to the address, and relinks the text and data.
100 計算機システム、101 CPU、102 MMU 103 DRAM、104 ディスクコントローラ、105 ハードディスク、106 ネットワークコントローラ、107 ネットワーク、108 バス、111 OS、112 プログラムローダー、113 コンパイラ、114 リンカ、115 プログラムソース、116 スタティックライブラリソース、117 共有ライブラリソース、120 実行プログラム、121 エントリポイントテキスト、122 対応表、123 プログラムデータ、124 プログラムテキスト、130 プロセス空間、131 テキスト領域、132 スタック領域、133 ヒープ領域、134 bss領域、135 データ領域、141 プログラム実行部、142 コンパイル部、143 リンク部、144 OS部、145 シグナルハンドラ部、146 デバイスドライバ部、149 プログラム記憶部。
100 computer system, 101 CPU, 102
Claims (16)
ことを特徴とするプログラム生成方法。 Data including a part of program code including a main function as a program code to be mapped to the virtual space before the program execution is started, and mapped to the virtual space before the execution of the program is started Including storage area information for specifying a storage area in the auxiliary storage device in which the remaining program codes excluding the part of the program codes are stored, and mapped to the virtual space before the execution of the program is started A program generation method comprising: generating a file including the remaining program code as unprocessed data as the program.
プログラム実行部が、前記実行プログラムを実行し、
実行中マッピング部が、前記プログラム実行部が前記開始前マッピング部によって仮想空間にマッピングされていない前記残りのプログラムコードに含まれるプログラムコードを実行コードとして実行するときに、前記開始前マッピング部によって仮想空間にマッピングされた前記記憶領域情報を用いて前記実行コードを仮想空間にマッピングする
ことを特徴とするプログラム実行方法。 Before the start mapping unit starts executing the execution program, a part of the program code of the execution program including a main function and a part of the program code of the execution program Mapping the storage area information for specifying the storage area in the auxiliary storage device in which the remaining program codes except for are stored in the virtual space,
The program execution unit executes the execution program,
When the executing mapping unit executes, as the execution code, the program code included in the remaining program code that is not mapped to the virtual space by the pre-start mapping unit, the pre-start mapping unit performs virtual A program execution method, wherein the execution code is mapped to a virtual space using the storage area information mapped to a space.
前記開始前マッピング部は、前記プログラム生成部によって生成された前記実行プログラムの実行が開始される前に、前記実行プログラムに前記テキストセクションデータとして含まれる前記一部のプログラムコードを仮想空間の前記テキスト領域にマッピングする
ことを特徴とする請求項2記載のプログラム実行方法。 A program generation unit generates, as the execution program, a program including the part of the program code as text section data to be set in a text area for setting a program code among areas constituting a virtual space for executing the program And
The pre-start mapping unit converts the partial program code included in the execution program as the text section data into the text in the virtual space before the execution of the execution program generated by the program generation unit is started. 3. The program execution method according to claim 2, wherein the program is mapped to an area.
前記ポインタ書き換え関数が、前記テキスト領域の隣に位置する第一の領域を指定するための第一のポインタに、前記残りのプログラムコードを前記テキスト領域に加えた場合の前記第一の領域を指定するアドレスを設定する関数である
ことを特徴とする請求項3記載のプログラム実行方法。 The part of the program code includes the main function and a pointer rewriting function,
The pointer rewriting function designates the first area when the remaining program code is added to the text area as a first pointer for designating a first area located next to the text area. 4. The program execution method according to claim 3, wherein the function is a function for setting an address to be executed.
前記開始前マッピング部は、前記プログラム生成部によって生成された前記実行プログラムの実行が開始される前に、前記実行プログラムに前記データセクションデータとして含まれる前記記憶領域情報を仮想空間の前記データ領域にマッピングする
ことを特徴とする請求項4記載のプログラム実行方法。 The program generation unit generates, as the execution program, a program including the storage area information as data section data to be set in a data area for setting data defined in the program among the areas constituting the virtual space,
The pre-start mapping unit stores the storage area information included in the execution program as the data section data in the data area of the virtual space before the execution of the execution program generated by the program generation unit is started. 5. The program execution method according to claim 4, wherein mapping is performed.
ことを特徴とする請求項5記載のプログラム実行方法。 The pointer rewriting function adds data defined in the execution program to the data area to a second pointer for designating the second area other than the text area, the data area, and the first area. 6. The program execution method according to claim 5, wherein the program is a function for setting an address for designating the second area.
ことを特徴とする請求項4から請求項6いずれかに記載のプログラム実行方法。 The program execution method according to claim 4, wherein the program execution unit executes the main function after executing the pointer rewriting function.
ことを特徴とする請求項2から請求項8いずれかに記載のプログラム実行方法。 When the execution program is executed by using the first virtual space and the execution program is executed by using the second virtual space by the program execution unit, the executing mapping unit At least one program included in the remaining program code in a third virtual space shared by the execution program executed using the space and the execution program executed using the second virtual space 9. The program execution method according to claim 2, wherein the code is mapped.
ことを特徴とする請求項3から請求項7いずれかに記載のプログラム実行方法。 The said program generation part includes the said execution code mapped by the said executing mapping part in the said one part program code, and produces | generates the said execution program newly, The any one of Claim 3-7 characterized by the above-mentioned. The program execution method described in 1.
を備えることを特徴とするプログラム生成装置。 A part of program code including a main function as program code to be mapped to the virtual space before the execution of the program is started, and the part of the code as data to be mapped to the virtual space before the execution of the program is started Including storage area information for specifying a storage area in the auxiliary storage device in which the remaining program code excluding the program code is stored, and the remaining as data not mapped in the virtual space before the execution of the program is started A program generation apparatus comprising: a program generation unit that generates a file including the program code as the program.
前記実行プログラムを実行するプログラム実行部と、
前記プログラム実行部が前記開始前マッピング部によって仮想空間にマッピングされていない前記残りのプログラムコードに含まれるプログラムコードを実行コードとして実行するときに、前記開始前マッピング部によって仮想空間にマッピングされた前記記憶領域情報を用いて前記実行コードを仮想空間にマッピングする実行中マッピング部と
を備えることを特徴とするプログラム実行装置。 Before execution of the execution program is started, a part of the program code of the execution program including a main function and a remaining program excluding the part of the program code of the execution program A storage area information for specifying a storage area in the auxiliary storage device in which the code is stored; and a pre-start mapping unit that maps the virtual space;
A program execution unit for executing the execution program;
When the program execution unit executes the program code included in the remaining program code that is not mapped to the virtual space by the pre-start mapping unit as the execution code, the pre-start mapping unit is mapped to the virtual space A program execution apparatus comprising: an executing mapping unit that maps the execution code to a virtual space using storage area information.
ことを特徴とするプログラム生成方法。 An entry point text that is a program code including a main function for copying the virtual space and mapping the program code of the second program to the virtual space, and an auxiliary for storing the program code of the second program A program generation method comprising: generating a first program including storage area information for specifying a storage area in a storage device.
プログラム実行部が、前記第一のプログラムの前記メイン関数を実行することにより、前記第一のプログラム用の第一の仮想空間をコピーして第二の仮想空間を生成し、
前記プログラム実行部が、前記記憶領域情報を用いて前記第二のプログラムのプログラムコードを前記第二の仮想空間にマッピングし、
前記プログラム実行部が、前記第二の仮想空間を用いて前記第二のプログラムのプログラムコードを実行する
ことを特徴とするプログラム実行方法。 Entry point text that is a program code that includes a main function for the pre-start mapping unit to copy the virtual space and map the program code of the second program to the virtual space before the execution of the second program is started And mapping the first program to the virtual space, the storage area information for specifying the storage area in the auxiliary storage device in which the program code of the second program is stored,
By executing the main function of the first program, the program execution unit creates a second virtual space by copying the first virtual space for the first program,
The program execution unit maps the program code of the second program to the second virtual space using the storage area information,
The program execution method, wherein the program execution unit executes the program code of the second program using the second virtual space.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2013027249A JP6103972B2 (en) | 2013-02-15 | 2013-02-15 | Program generation method, program execution method, program execution device, and program execution program |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2013027249A JP6103972B2 (en) | 2013-02-15 | 2013-02-15 | Program generation method, program execution method, program execution device, and program execution program |
Publications (2)
Publication Number | Publication Date |
---|---|
JP2014157434A true JP2014157434A (en) | 2014-08-28 |
JP6103972B2 JP6103972B2 (en) | 2017-03-29 |
Family
ID=51578284
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2013027249A Expired - Fee Related JP6103972B2 (en) | 2013-02-15 | 2013-02-15 | Program generation method, program execution method, program execution device, and program execution program |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP6103972B2 (en) |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPS63626A (en) * | 1986-06-19 | 1988-01-05 | Casio Comput Co Ltd | program management device |
JP2002222088A (en) * | 2001-01-25 | 2002-08-09 | Nec Corp | System and method for compilation, and program |
-
2013
- 2013-02-15 JP JP2013027249A patent/JP6103972B2/en not_active Expired - Fee Related
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPS63626A (en) * | 1986-06-19 | 1988-01-05 | Casio Comput Co Ltd | program management device |
JP2002222088A (en) * | 2001-01-25 | 2002-08-09 | Nec Corp | System and method for compilation, and program |
Also Published As
Publication number | Publication date |
---|---|
JP6103972B2 (en) | 2017-03-29 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11188638B2 (en) | Fine-grained memory address space layout randomization | |
US10157268B2 (en) | Return flow guard using control stack identified by processor register | |
JP5255348B2 (en) | Memory allocation for crash dump | |
US10311227B2 (en) | Obfuscation of an address space layout randomization mapping in a data processing system | |
US8281293B2 (en) | Copy-on-write optimization of immutable objects for objects oriented languages | |
US9213623B2 (en) | Memory allocation with identification of requesting loadable kernel module | |
US10496534B2 (en) | Manual memory management using lazy patching | |
US10296353B2 (en) | Protecting basic input/output (BIOS) code | |
JP2017045477A (en) | Virtual disk storage technology | |
KR101650424B1 (en) | Operation transfer from an origin virtual machine to a destination virtual machine | |
Tang et al. | Exploring control flow guard in windows 10 | |
JP2013520744A (en) | Method and apparatus for generating minimum boot image | |
JP5778296B2 (en) | Virtual computer system, virtualization mechanism, and data management method | |
US10228993B2 (en) | Data dump for a memory in a data processing system | |
JP2008269474A (en) | Information processor and access control method | |
JP2022545012A (en) | Data storage using flash order of memory aperture | |
CN114327777B (en) | Method and device for determining global page directory, electronic equipment and storage medium | |
US9298472B2 (en) | High-speed restart method, information processing device, and program | |
US10496433B2 (en) | Modification of context saving functions | |
CN102597972A (en) | Virtual computer system, area management method, and program | |
US6782446B2 (en) | Method to prevent corruption of page tables during flash EEPROM programming | |
JP7025104B2 (en) | Information processing equipment, methods and programs | |
JP6103972B2 (en) | Program generation method, program execution method, program execution device, and program execution program | |
US9110793B2 (en) | Inner process | |
JP6691294B2 (en) | Information processing apparatus, dynamic link program, and program restart method |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20151217 |
|
A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20161025 |
|
A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20161115 |
|
A521 | Request for written amendment filed |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20161214 |
|
TRDD | Decision of grant or rejection written | ||
A01 | Written decision to grant a patent or to grant a registration (utility model) |
Free format text: JAPANESE INTERMEDIATE CODE: A01 Effective date: 20170131 |
|
A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20170228 |
|
R150 | Certificate of patent or registration of utility model |
Ref document number: 6103972 Country of ref document: JP Free format text: JAPANESE INTERMEDIATE CODE: R150 |
|
R250 | Receipt of annual fees |
Free format text: JAPANESE INTERMEDIATE CODE: R250 |
|
R250 | Receipt of annual fees |
Free format text: JAPANESE INTERMEDIATE CODE: R250 |
|
LAPS | Cancellation because of no payment of annual fees |