Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: latches or semaphores

Re: latches or semaphores

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: 13 Nov 2001 07:02:31 -0800
Message-ID: <9srcm70esu@drn.newsguy.com>


In article <2c78cfac.0111130613.6fdc613f_at_posting.google.com>, danisment_at_yahoo.com says...
>
>Hello,
>
>According to my tests, Oracle doesn't use semaphores on latch
>operations. It's also true in theory since semaphore operations are
>done in FIFO order, but latches not. Semaphores include atomic
>test-and-set instructions too. But, using just atomic test-and-set
>instructions for latches are enough instead of using expensive entire
>semaphore operations.
>
>what happens if hardwares don't support atomic test-and-set
>instructions ?
>

what hardware doesn't?

Oracle uses atomic instructions like 'test and set' for operating on latches. Since the instructions to set and free latches are atomic, the operating system itself guarantees that only one process gets it. Since it is only one instruction, it can be quite fast. Latches are held for short periods of time and provide a mechanism for clean up in case a holder dies abnormally while holding it. This cleaning up process would be performed by PMON.

>If Oracle doesn't use, how is the latch positing implemented ? Which
>IPC mechanism is used ? There are two options other than semaphores:
>
>- message queues
>- shared memory
>
>message queues are not solution, becasue they are ordered. I guess
>posting is done shared memory IPC mechanism.

but that in itself would need some serialization device -- we use latches to protect the shared data structures in the SGA (a shared memory segment)

>
>I would like to be sure about this case to confirm my knowledge. does
>Oracle use semaphore on latches ?
>

semaphores are too heavy weight for this...

>
>thanks in advance...

--
Thomas Kyte (tkyte@us.oracle.com)             http://asktom.oracle.com/ 
Expert one on one Oracle, programming techniques and solutions for Oracle.
http://www.amazon.com/exec/obidos/ASIN/1861004826/  
Opinions are mine and do not necessarily reflect those of Oracle Corp 
Received on Tue Nov 13 2001 - 09:02:31 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US