What is the difference between process and thread | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

What is the difference between process and thread

please explain the difference between process and thread in terms of sql server.
Here’s an excerpt from Ken Henderson’s Guru’s Guide to SQL Server Internals
quote:
An instance of a running application is known as a process. Actually, that#%92s a
misnomer. Processes don#%92t actually run—threads do. Every process has at
least one thread (the main thread) but can have many. Each thread represents
an independent execution mechanism. Any code that runs within an
application runs via a thread.
Each process is allotted its own virtual memory address space. All threads
within the process share this virtual memory space. Multiple threads that
modify the same resource must synchronize access to the resource in order
to prevent erratic behavior and possible access violations. A process that correctly
serializes access to resources shared by multiple threads is said to be
thread-safe.
Each thread in a process gets its own set of volatile registers. A volatile
register is the software equivalent of a CPU register. In order to allow a
thread to maintain a context that is independent of other threads, each
thread gets its own set of volatile (software) registers that are used to save
and restore hardware registers. These volatile registers are copied to/from
the CPU registers every time the thread is scheduled/unscheduled to run by
Windows. The process by which this happens is known as a context switch.
Processes can be initiated by many different types of applications. Console
apps, graphical user interface (GUI) apps, Windows services, out-ofprocess
COM servers, and so on are examples of EXEs that can be executed
to instantiate a process. SQL Server can run as both a console app and a
Windows service.


Frank Kalis
Microsoft SQL Server MVP
http://www.insidesql.de
Ich unterstütze PASS Deutschland e.V. http://www.sqlpass.de)

I am a bit confused.Can you please explain this concept with a live example.I will really appreciate your help
Moreover how will I determine which thread is working now
What are you really after? —
Frank Kalis
Microsoft SQL Server MVP
http://www.insidesql.de
Ich unterstütze PASS Deutschland e.V. http://www.sqlpass.de)

Are you expecting information that Profiler gives?
Madhivanan Failing to plan is Planning to fail
I mean to say that I can get the process information from sysprocesses table with spid.
How can I know which thread of a particular spid is working now and how many threads a process have.

When you use SP_WHO you will see column
‘ecid’
The execution context ID of a given thread associated with a specific SPID.
ECID = {0, 1, 2, 3, …n}, where 0 always represents the main or parent thread, and {1, 2, 3, …n} represent the sub-threads.
Satya SKJ
Moderator
http://www.SQL-Server-Performance.Com/forum
This posting is provided “AS IS” with no rights for the sake of knowledge sharing.
<img src=’/community/emoticons/emotion-1.gif’ alt=’:)‘ />
]]>