05.11.2015 Views

Apress.Expert.Oracle.Database.Architecture.9i.and.10g.Programming.Techniques.and.Solutions.Sep.2005

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

158<br />

CHAPTER 5 ■ ORACLE PROCESSES<br />

■Note There are many variants of the fork() <strong>and</strong> exec() calls, such as vfork(), execve(), <strong>and</strong> so on.<br />

The call used by <strong>Oracle</strong> may vary by operating system <strong>and</strong> implementation, but the net effect is the same.<br />

fork() creates a new process that is a clone of the parent process, <strong>and</strong> on UNIX this is the only way to create<br />

a new process. exec() loads a new program image over the existing program image in memory, thus<br />

starting a new program. So, SQL*Plus can “fork” (copy itself) <strong>and</strong> then “exec” the <strong>Oracle</strong> binary, overlaying<br />

the copy of itself with this new program.<br />

We can see this parent/child process creation clearly on UNIX when we run the client <strong>and</strong><br />

server on the same machine:<br />

ops$tkyte@ORA10G> select a.spid dedicated_server,<br />

2 b.process clientpid<br />

3 from v$process a, v$session b<br />

4 where a.addr = b.paddr<br />

5 <strong>and</strong> b.sid = (select sid from v$mystat where rownum=1)<br />

6 /<br />

DEDICATED_SE CLIENTPID<br />

------------ ------------<br />

5114 5112<br />

ops$tkyte@ORA10G> !/bin/ps -p 5114 5112<br />

PID TTY STAT TIME COMMAND<br />

5112 pts/1 R 0:00 sqlplus<br />

5114 ? S 0:00 oracleora10g (DESCRIPTION=(LOCAL=YES)..(PROTOCOL=beq)))<br />

Here, I used a query to discover the process ID (PID) associated with my dedicated server<br />

(the SPID from V$PROCESS is the operating system PID of the process that was being used during<br />

the execution of that query).<br />

Shared Server Connections<br />

Let’s now take a look at the shared server process in more detail. This type of connection<br />

m<strong>and</strong>ates the use of <strong>Oracle</strong> Net even if the client <strong>and</strong> server are on the same machine—you<br />

cannot use shared server without using the <strong>Oracle</strong> TNS listener. As described earlier, the client<br />

application will connect to the <strong>Oracle</strong> TNS listener <strong>and</strong> will be redirected or h<strong>and</strong>ed off to a<br />

dispatcher. The dispatcher acts as the conduit between the client application <strong>and</strong> the shared<br />

server process. Figure 5-2 is a diagram of the architecture of a shared server connection to the<br />

database.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!