System Architecture 2-25
How User Processes Attach to Shared Memory
Step 2: Calculate Shared-Memory Key Value
Whena user process is ready to attach to shared memory,it calculates a value
that serves as the shared-memory key to identify toUNIX the first shared-
memory segment. To ensure that all user processes within a single OnLine
system attach to the same shared-memory segments, the key value must be
shared among all OnLine user processes. To ensure that the user processes
fromindependent OnLines do not become entangled, the key value must be
unique for each OnLine system.
Theshared-memory key value that each user process arrives at is defined by
the calculation:
(SERVERNUM * 65536) + shmkey
The database configuration parameterSERVERNUM uniquely identifies the
shared-memorysegments for each OnLine system. If more than one OnLine
databaseserver exists on a single host machine, the calculated key values are
separated by the difference between the two values ofSERVERNUM, multi-
plied by 65536.
Thevalue of shmkey is set internally and cannot be changed by the user. (The
shmkey value is 52564801 in hexadecimal representation or 1,381,386,241 in
decimal.)
Thevalue (SERVERNUM *65536) is the same as multiplying SERVERNUM by
hexadecimal 1000.
Steps 3 and 4: Request Shared-Memory Segment and Attach toSHMBASE
Theuser process transfers to UNIX the calculated shared-memory key value.
In return, theUNIX operating system passes back the shared-memory
segment identifier associated with the value of the shared-memory key.
Using this identifier, the user process requests that the operating system
attach this segment of shared memory to the user process space at the
address specified as the OnLine configuration parameterSHMBASE.