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

Home -> Community -> Usenet -> c.d.o.misc -> Re: About OCI thread safety

Re: About OCI thread safety

From: Amogh <amogh.r_at_nospam.com>
Date: Wed, 26 Apr 2006 16:52:34 +0530
Message-ID: <p%I3g.19$Fk3.125@news.oracle.com>


Herode wrote:
> Gentlemen,
> this is the official page about thtead safety :
> http://oraclesvca2.oracle.com/docs/cd/B10501_01/appdev.920/a96584/oci09adv.htm#456379
>
> I don't understant how it works.
>
> Oracle says :
> "Then the application must tell the OCI layer that the application is
> running in multithreaded mode, by specifying OCI_THREADED for the mode
> parameter of the opening call to OCIEnvCreate()."
>
> And some lines below :
> "If an application running in OCI_THREADED mode maintains one or more
> environment handles, each of which has multiple connections, it also
> has the following options:
> [...]
> Pass a value of OCI_DEFAULT to OCIEnvCreate(). In this case, the OCI
> library automatically gets a mutex on every OCI call on the same
> environment handle."
>
> Then, if OCI_DEFAULT is passed ton OCIEnvCreate(), how can the OCI
> layer know that the application ruens in multithreaded mode ?????
>
> Moreover, the doc says :
> "Advantages of OCI Thread Safety
> [....]
> Users who do not write multithreaded programs do not pay a performance
> penalty for using thread-safe OCI calls."
> And a few lines below :
> "If an application is single-threaded, whether or not the platform is
> thread-safe, the application should pass a value of OCI_DEFAULT to
> OCIInitialize() or OCIEnvCreate(). Single-threaded applications which
> run in OCI_THREADED mode may incur performance hits."
>
> So what ??????
>
> regards,
> C.
>

 > Pass a value of OCI_DEFAULT to OCIEnvCreate(). In this case, the OCI
 > library automatically gets a mutex on every OCI call on the same
 > environment handle."

I think it should be OCI_THREADED and not OCI_DEFAULT. OCI_THREADED mode would automatically acquire and manage mutexing.

 > Users who do not write multithreaded programs do not pay a performance  > penalty for using thread-safe OCI calls."

Yes! It simply means that the threading feature will not affect somebody whos writing a non-threaded application, taken that the environment is created in the OCI_DEFAULT mode.

 > And a few lines below :
 > "If an application is single-threaded, whether or not the platform is
 > thread-safe, the application should pass a value of OCI_DEFAULT to
 > OCIInitialize() or OCIEnvCreate(). Single-threaded applications which
 > run in OCI_THREADED mode may incur performance hits."
 >
 > So what ??????

Yes! The application would incur a performance hit because it's single threaded and still uses OCI_THREADED as the mode. Think of all the unnecessary mutexing.

Rgds.
Amogh Received on Wed Apr 26 2006 - 06:22:34 CDT

Original text of this message

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