Oracle を起動すると、まずはじめに専用サーバが fork されます。 このサーバが shmget() で共有メモリを作成し、そのアクセス権を得るために、 shmat() を呼びます。 それ以降に fork されるバックグランドプロセスは、shmat() ですでにある共有メモリ のアクセス権を取得します。
Oracle をシャットダウンすると、各バックグランドプロセスは、 shmdt() で共有メモリのアクセス権を解放します。 最後に残ったプロセスは、その後 shmctl(,IPC_RMID,) で共有メモリを削除します。
| OS | 設定されている制限値 |
|---|---|
| solaris | /etc/system の shmsys:shminfo_shmmax |
| HP-UX | sam の shmmax |
| AIX | |
| Linux | /proc/sys/kernel/shmmax |
また oracle の製品によっても制限されます。
| oracle 製品 | 制限値 |
|---|---|
| 32bit 版 | 2G |
| 64bit 版 | 64G |
AIX では以下の制限があります。
| AIX のバージョン | 制限値 |
|---|---|
| 4.3.1 以前 | 256M |
| 4.3.1 から 5.1 まで | 2G |
| 5.1 以降の 64bit 版 | 64G |
| int id = shmget(key_t key,int size,int shmflg); | ||
| id | 共有メモリ識別子 | |
| key | 共有メモリのキーの型 | #define IPC_PRIVATE (key_t)0 /* private key */ |
| size | 共有メモリのサイズ | |
| shmflg | フラグ | #define IPC_ALLOC 0100000 /* entry currently allocated */ |
| #define IPC_CREAT 0001000 /* create entry if key doesn't exist */ | ||
| #define IPC_EXCL 0002000 /* fail if key exists */ | ||
| #define IPC_NOWAIT 0004000 /* error if request must wait */ | ||
| void *addr = shmat(int id,void *shmaddr,int shmflg); | ||
| addr | 共有メモリのアドレス | |
| id | 共有メモリ識別子 | |
| shmaddr | 共有メモリのアドレス | 0 の場合システムがアドレスを決める |
| shmflg | フラグ | #define SHM_RDONLY 010000 /* attach read-only (else read-write) */ |
| #define SHM_RND 020000 /* round attach address to SHMLBA */ | ||
| #define SHM_SHARE_MMU 040000 /* ISM を使う。ISM は swapout されない。*/ | ||
| int shmdt(void *shmaddr); | |
| shmaddr | 解放する共有メモリのアドレス |
| int shmctl(int id,int command,shmid_ds *buf); | ||
| id | 共有メモリ識別子 | |
| command | 共有メモリ削除 | #define IPC_RMID 10 /* remove identifier */ |
| オプション設定 | #define IPC_SET 11 /* set options */ | |
| オプション取得 | #define IPC_STAT 12 /* get options */ | |
| buf | 共有メモリのためのデータ構造体 | shmid_ds |
| 略語 | 内 容 |
|---|---|
| IPC | Inter-Process Communication |
| ISM | Intimate Shared Memory |
| MMU | Memory Management Unit |
| SGA | System Global Area |