Understanding Shared Memory and Semaphores - Oracle FAQ
Understanding Shared Memory and Semaphores - Oracle FAQ
User login
Understanding Shared Memory and
Login: * Semaphores
Submitted by Nidhi Jain on M on, 2003-12-15 13:03
Password: * Operating Systems
by Nidhi Jain
Login Shared memory and semaphores are two important resources for an Oracle
[ Register ] [ Forgot instance on Unix. An instance cannot start if it is unable to allocate what it
password ] needs.
DEFINATIONS
Search Shared memory is exactly that - a memory region that can shared between
different processes. Oracle uses shared memory for implementing the SGA,
Go which needs to be visible to all database sessions.
[ Advanced ] [ Help ]
Semaphores can be thought of as flags (hence their name, semaphores). They
are either on or off. A process can turn on the flag or turn it off. If the flag is
already on, processes who try to turn on the flag will sleep until the flag is off.
Site navigation Upon awakening, the process will reattempt to turn the flag on, possibly
suceeding or possibly sleeping again. Such behaviour allows semaphores to be
About
used in implementing a post-wait driver - a system where processes can wait for
Blogs events (i.e. wait on turning on a semphore) and post events (i.e. turning of a
Feed aggregator semaphore). This mechanism is used by Oracle to maintain concurrency control
Books over the SGA, since it is writeable by all processes attached.
Directories
Events ALLOCATION IN SIMPLE TERMS
FAQ's
Shared memory required by the Oracle Instance : On instance startup, the first
Forums
things that the instance does is: -Read the "init.ora" -Start the background
Mailing Lists
processes -Allocate the shared memory and semphores required The size of the
Papers
SGA will be calculated from various "init.ora" parameters. This will be the
Scripts
amount of shared memory required. The SGA is broken into 4 sections - the
Tools
fixed portion, which is constant in size, the variable portion, which varies in size
USENET News depending on "init.ora" parameters, the redo block buffer, which has its size
Wiki controlled by log_buffers, and the db block buffer, which has its size controlled by
XML Feeds db_block_buffers. The size of the SGA is the sum of the sizes of the 4 portions.
There is unfortunately no simple ormula for determining the size of the variable
portion.
http://www.orafaq.com/node/8 1/7
6/7/2010 Understanding Shared Memory and Se…
Similar entries
Generally, the shared pool dominates all other parts of the variable portion, so as
a rule of thumb, one can estimate the size as the value of shared_pool_size.
Shared Server -- Part I
Shared Server -- Part III The number of semphores required is much simpler to determine.
What Unix commands Oracle will need exactly as many semaphores as the value of the processes
can one use when "init.ora" parameter.
administrating a
database? SHARED MEMORY ALLOCATION
Running Oracle on 10g
on Windows Server 1. One-segment
2003 x64 Editions:
Unlimited Scalability 2. Contigous multi-segment
and Performance
Oracle 10g New 3. Non-contigous multi-segment
Features: Advisory
Framework - ADDM When attempting to allocate and attach shared memory for the SGA, it will
attempt each one, in the above order, until one succeeds or raises an ORA error.
On other, non-fatal, errors, Oracle simply cleans up and tries again using the
next memory model. The entire SGA must fit into shared memory, so the total
amount of shared memory allocated under any model will be equal of the size of
the SGA(SGASIZE).
1. One-segment:- The one-segment model is the simplest and first model tried.
In this model, the SGA resides in only one shared memory segment. Oracle
attempts to allocate and attach one shared memory segement of size equal to
total size of the SGA. However, if the SGASIZE is larger than the configured
SHMMAX, this will obviously fail. In this case, the SGA will need to be placed in
multiple shared memory segments, and Oracle proceeds to the next memory
model for the SGA.
With multiple segments there are two possibilities. The segments can be
attached contiguously, so that it appears to be one large shared memory
segment, or non-contiguously, with gaps between the segments.
3. Non- contigous multi-segment : Once the number of segments and their sizes
is determined, Oracle then allocates and attaches the segments one at a time;
first the fixed and variable portion segment(s), then the redo block buffer
segment(s), then the db block buffer segment(s). They will be attached non-
contiguously,
At this point, we have either attached the entire SGA or returned an ORA error.
The total size of segments attached is exactly SGASIZE; no space is wasted.
Once Oracle has the shared memory attached, Oracle proceeds to allocating the
semaphores it requires.
max Sga that can be created by the one segment model is SHMMAX*SHMSEG
You can display the current kernel parameters by doing a "sysdef -i"
SEMAPHORE ALLOCATION
Since each oracle process* requires a semaphore, the number that is allocated is
equal to the value of the init.ora parameter PROCESSES. The total # of
semaphores required is the sum of all your instance's PROCESSES.
You can allocate all of your semaphores in one or more semaphore sets. If
SEMMSL=PROCESSES, then only one semaphore set is required.
If you have more than one instance and the values of PROCESSES are different,
you may want to make SEMMSL equal to the lowest PROCESSES so that you don't
allocate semaphores that will not be used. Otherwise, this could prevent you
from being able to allocate all of your requirements.
For example:
Instance PROD has PROCESSES=100
Instance DEV has PROCESSES=50
If SEMMSL = 50, 3 semaphore sets will be allocated, 2 for PROD and 1 for DEV.
To see what semaphores have been allocated, use the Unix command 'ipcs -b'.
For example:
Semaphores:
T ID KEY MODE OWNER GROUP NSEMS
s 0 0 --ra-r----- osupport dba 25
s 1 0 --ra-r----- osupport dba 25
s 18 0 --ra-r----- osupport dba 25
s 19 0 --ra-r----- osupport dba 25
s 4 0 --ra-r----- osupport dba 25
s 5 0 --ra-r----- osupport dba 25
$ svrmgrl
SVRMGR>connect internal
SVRMGR>oradebug ipc
This will show the shared memory segment and semaphore that each instance
has attached/in use.
The Seg Id shows 10250 for the shared memory which is attacehed to the
RUNNING instance. DO NOT REMOVE THAT ONE.
http://www.orafaq.com/node/8 4/7
6/7/2010 Understanding Shared Memory and Se…
The Semaphore identifiers shows 188434 for the semaphore which is attacehed
to the RUNNING instance. DO NOT REMOVE THAT ONE.
Once you have noted ALL of the identifiers for ALL of the instances which are up
and running, compare these id numbers to those in the "ipcs -b" listing.
The entry that does not have a running instance to match is the orphaned entry.
THAT ONE SHOULD BE REMOVED.
»
Lo g in to post comments
»
Lo g in to post comments
Question 1
question 2
If all of shared memory is used up does Oracle use
SWAP ?
Arun.
http://www.orafaq.com/node/8 5/7
6/7/2010 Understanding Shared Memory and Se…
»
Lo g in to post comments
Nidhi
»
Log in to post comments
For eg,
M etalink Doc ID: Note:187260.1 discussing about Kernel parameters for Solaris
mentions this
"
SEM M SL - Set to 10 plus the largest PROCESSES parameter of any Oracle database
on the system."
-Thiru Vadivelu
»
Lo g in to post comments
»
Lo g in to post comments
http://www.orafaq.com/node/8 6/7
6/7/2010 Understanding Shared Memory and Se…
What about copiright?
Submitted by Danb on Tue, 2008-05-13 00:35.
It's compilation from Oracle M etalink 15566.1
It is sad that author did not mention it in his "work"
»
Lo g in to post comments
I have mac hine with 4gb of and i set shared memory to 10gb.
Regards
Sachin
»
Lo g in to post comments
.:: Blogger Home :: Wiki Home :: Forum Home :: Privacy :: Contact ::.
http://www.orafaq.com/node/8 7/7