Friday, 7 August 2009

Processes or Threads?

I've been busy describing DBWn and LGWR as "background processes", but in fact they might not be processes at all. If you are running Oracle on Windows, for example, then they are technically 'threads' within the main process, not independent processes in their own right. On Unix and Linux, however, they are genuinely independent processes and can be listed just like you can list the existence of any operating system process:

[oracle@tkit ~]$ ps -ef | grep ora
oracle 6688 1 0 06:32 ? 00:00:00 ora_pmon_mydb
oracle 6690 1 0 06:32 ? 00:00:00 ora_psp0_
mydb
oracle 6692 1 0 06:32 ? 00:00:00 ora_mman_mydb
oracle 6694 1 0 06:32 ? 00:00:02 ora_dbw0_mydb
oracle 6696 1 0 06:32 ? 00:00:01 ora_lgwr_mydb
oracle 6698 1 0 06:32 ? 00:00:01 ora_ckpt_mydb
oracle 6700 1 0 06:32 ? 00:00:02 ora_smon_mydb
oracle 6702 1 0 06:32 ? 00:00:00 ora_reco_mydb
oracle 6704 1 0 06:32 ? 00:00:01 ora_cjq0_mydb
oracle 6706 1 0 06:32 ? 00:00:03 ora_mmon_mydb
oracle 6708 1 0 06:32 ? 00:00:00 ora_mmnl_mydb
oracle 6710 1 0 06:32 ? 00:00:00 ora_d000_mydb
oracle 6712 1 0 06:32 ? 00:00:00 ora_s000_mydb
oracle 6716 1 0 06:32 ? 00:00:00 ora_qmnc_mydb
oracle 6719 1 0 06:32 ? 00:00:00 ora_q000_mydb
oracle 6721 1 0 06:32 ? 00:00:00 ora_q001_mydb

The middle bit of the names in the right-hand column show you the process abbreviations I've been using -and you can see PMON, DBW0, LGWR and so on listed together with a bunch of those 'other' processes (like S000) I mentioned briefly in passing.

There is no equivalent on Windows to the 'ps' command, however -and even downloadable tools like CurrProcess Explorer won't show you items with identifiable names such as I've been using here. The best you can see is the existence of a single process, called oracle.exe, and that's about it. You can see the process names even on Windows, though, if you query the instance itself by selecting from V$PROCESS:

SQL> select program from v$process;

PROGRAM
-----------------------------------
PSEUDO
ORACLE.EXE (PMON)
ORACLE.EXE (PSP0)
ORACLE.EXE (MMAN)
ORACLE.EXE (DBW0)
ORACLE.EXE (LGWR)
ORACLE.EXE (CKPT)
ORACLE.EXE (SMON)

...but that's as good as it ever gets on Windows.

This difference between Unix and Windows is down to the underlying architecture of the operating system and has no impact on the fundamental capabilities and functions of the Oracle database itself, but it means that, technically, we should talk about "background threads" when discussing Oracle-on-Windows ...but no-one in their right mind ever does so! Everyone still calls them 'background processes', even on Windows. It might not be technically precise but everyone will know what you mean.

No comments: