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: Pro*C question concerning Unix fork() system call

Re: Pro*C question concerning Unix fork() system call

From: Lance S. Nehring <lnehrin_at_uswest.com>
Date: 1998/02/03
Message-ID: <34D78CF2.4F0B8F44@uswest.com>#1/1

Nuno Guerreiro wrote:

> I'm developing a Pro*C program in the HP-UX OS against an Oracle 7.3.3
> DBMS. The program consists of a daemon whose mission is to provide
> services received through an Oracle pipe (using the DBMS_PIPE
> package).
>
> For best performance, when the daemon receives a request, it should
> call the fork() system call and let the child process service the
> request, while the parent process keeps scanning the pipe for other
> requests.

It's arguable whether forking for each request will yield best performance, but it is a straight forward design to give concurrency. It would actually be faster, although more complex, to pre-fork a number of worker processes -or- if you're into threads, create a number of worker threads in your daemon process. It also depends on how many CPU's you've got and what version of HP-UX you're running. For threads, HP-UX doesn't support kernel space threads until HP-UX 10.30 or 11.x. Prior to this, i.e. HP-UX 10.20, all you've got is user space threads which cannot span CPU's.

>
>
> When the fork() call takes place, does the child process create a new
> database session or it simply uses the same as the parent process?

The database connection is forked as a child process when you perform the Oracle login. I don't think that another forked child from your daemon could use that database connection child. (I don't know that for certain....please let me know if you try it) More importantly, I'm not sure you would want to use the same database connection. Unless you use mutexes (or Oracle thread contexts) to protect the database connection, you'll end up with out of sequence SQL errors when multiple processes (or threads) use the same connection. I have seen this when trying to thread a program prior to Pro*C 2.2 (earlier versions didn't have thread or context support).

>
>
> Thanks in advance,
>
> Nuno Guerreiro
Received on Tue Feb 03 1998 - 00:00:00 CST

Original text of this message

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