Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Multi-threaded windows service on a multi-processor server

10 views
Skip to first unread message

Ben

unread,
Jan 29, 2004, 10:27:38 AM1/29/04
to
Hi,

I am developing a multi-threaded windows service in C#. It is intended
to run on a multi-processor server. Single Application domain. To the
best of my knowledge there is a direct mapping between logical CLR
(Systsem.Threading.Thread) threads and physical OS
(System.Diagnostics.ProcessThread) threads. Does it mean that threads
in the windows service will be scheduled by OS to run on all
processors? Does direct mapping between logical and physical threads
in .NET intrinsically means support for a multi-processor platform?

Microsoft patterns and practices Team has recently published a draft
of its "Improving .NET Application Performance and Scalability" book
for a public review http://www.theserverside.net/booksinreview/pag.aspx
In Chapter 13th "Improving Remoting Performance" it says:

"There are two implementations of the CLR and its garbage collection
mechanism: One is designed for single CPU computers. This is MSCORWKS,
known as the Workstation garbage collector (GC). The other is designed
to handle multiple CPU computers. This is MSCORSVR, known as the
Server GC. ASP.NET uses the server GC on multi-processor servers. The
Server GC is optimized to maximize throughput and scalability".

"Windows Service. You can create a Windows service to host your remote
objects. Doing so does not allow you to load the Server GC, and you
are limited to the Workstation GC".

Does it imply that a multi-threaded windows service is restricted to a
single cpu on a multi-processor machine?

Thank you for your help,
Ben

Raghu

unread,
Jan 29, 2004, 2:34:51 PM1/29/04
to
Check out "Using mscorsvr.dll" thread on performance news group.

"Ben" <bme...@yahoo.com> wrote in message
news:f839a90f.04012...@posting.google.com...

Brian Grunkemeyer

unread,
Jan 30, 2004, 5:34:12 PM1/30/04
to
In V1 and V1.1, each logical thread corresponded with exactly one physical
thread in the OS. We also provide a Threadpool used for async IO
operations, async delegate invokations, and to process any requests that go
through QueueUserWorkItem. The choice of GC doesn't limit the number of
threads in an application to one processor or anything like that. It may
affect your scalability and performance though.

Note that in version 2, in some hosted enviroments like SQL Server,
multiple logical threads may be multi-tasked on the same physical thread,
using fibers. We might possibly add multiple finalizer threads in a future
version as well. Rest assured that we don't limit all your threads to one
processor (unless you set the thread's affinity), and don't make many
assumptions in your code about exactly which OS thread is running your
code. You can safely use Thread's AllocateDataSlot and
AllocateNamedDataSlot if you need a managed equivalent to thread-local
storage.

If you have any questions about the GC implementation, please read chapter
19 in Jeffrey Richter's "Applied Microsoft .NET Framework Programming".
Understanding when to use finalizers & the dispose pattern and being able
to use a managed memory profiler on your code will almost certainly give
you a better return for your time than trying to figure out whether to use
the server or workstation GC.

Brian Grunkemeyer
.NET Framework Base Class Library team

0 new messages