January 10, 2005 at 6:55 am
Hi
some body help me,i have Q and need A
what is Difference between Process and thread
can a threed kill the process that it belongs to
Can thread kill its sibling thread initated by some process
January 10, 2005 at 9:59 am
Boy you have a lot of questions today. A process is equivalent to a thread, but at a higher level in SQL Server. Each process uses one of the many worker threads that SQL Server has, so there are potentially more processes than threads.
If I understand it right, there is no affinity between a particular thread and a process. The process uses whatever thread becomes available.
Threads typically don't kill threads.
January 10, 2005 at 2:25 pm
A process is the encapsulation of a running program on a given platform. It provides the context in which thread(s) an carry out the work of an application. A process by design can be as few as a single thread or can contain multiple threads. So the executable for SQL Server "sqlservr.exe" when running is a process.
A thread on the other hand is where the actual program code is executed and is how a process carries out it's work. In lives within the context of the owning Process. The first thread created is the main or primary thread and always at least one is created. Also you should note that threads require fewer system resources than the process itself so it is better to write a multithreaded application to do all the work for the process than to run the same application multiple times to create multiple processes. The main thread is responsible for spawning additional child threads (called worker threads) in a multithreaded process. Each threads key role is to do the work and are assigned time division on the CPU, the more threads thou the higher the number of context siwtches there will be and the more chance for a racing condition can occurr which is all based on the hardware it is run on, so be carefull not to have too many threads on a system.
Now as for destroying the process that depends on the code itself. Pretty much any thread could be used to destory the process but it is usally done by the main thread where cleanup of the worker threads can best be handled.
Although it is not the best thing to do any thread from any process could be built to kill a thread in any process (this is sorta how using end process works in task manager). So yes it can be done but usually you stick to the same process and allow the main thread to handle signalling the worker threads so that they close themselves thru whatever code they have for that.
May 4, 2012 at 12:15 am
In sql server 2008 :
I agree if I run
Select * from sys.dm_exec_sessions;
and run
Kill 3;
It will kill SPID.
But I want to kill Session ID.
so How to kill it?
Thanks
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply