Solved

When/how many threads are created in DCOM

Posted on 1998-09-10
5
190 Views
Last Modified: 2013-12-03
Hi,

We know there are different threading model when we create a DCOM server, like single apartment thread, multiple apartment thread and free thread.
Can some body tell me exactly at which point the thread is created ? And how many thread will be created in case there are many clients(say 100 clients) try to talk to a DCOM server ?


Thanks,


Mike


0
Comment
Question by:mikechen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 13

Accepted Solution

by:
Mirkwood earned 200 total points
ID: 1414355
When you are an out-of-process DCOM server (EXE), you dominate the threads. That is, when you don't create any new threads. Nobody will.
When you are in-process DCOM server (DLL), you are requested to follow at least the caller threading model. So if the caller is Apartment threading, you need to be apartment, mental or free threading. Single threading will give an error on CoInitialize. The other way around when you are apartment threading then the host may only be apartment or single threading. In this case a connection by a mental or free-threading host is not allowed.

Threads are only created by the main process.  No threads are created spontaniously. So if 100 clients each have 1 thread an call a dll then you have 100 processes with each 1 thread so your dll is called from 100 different threads. If you have an exe server, all calls will be serialed and you will only be called from within one thread, your thread.

The problem begins when using a tool like MFC or VB. In VB it can be specified that every window has it own thread with a maximum of a certain number that can be specified. In MFC, you can create your own thread. Classes can inhered from CWinThread and create a new thread. But all this is only important when you have an inprocess server. An outofprocess executable manages its own threads.
0
 

Author Comment

by:mikechen
ID: 1414356
Hi, Mirkwood,

Thank you for your response.

Let's stick with out-proc server(.exe or service). From what I understand, when a DCOM client calls a method exposed by the server, the server itself will create a thread) to handle this request(or a thread from thread pool will do that). My question is when, how may threads are created in the server to handle these request when you have a lot of clients ?
And do we have any control on that ?

Thanks,

Mike

0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1414357
Oh, you mean how many threads are created by the RPCss.
I've read that in Professional DCOM by Richard Grimes (page 182)

--
The threads created on the server's behalf have been created by DCOM out of a pool of threads that it maintains.In this situations, the server uses up to 6 threads (10 clients). There's no way for the system administrator to change this. However DCOM has been built with flexibility and scalibility in mind: if the server is heavily used, DCOM with dynamically create more threads to handle the requests and make the clients more responsive.
--

A utility like Pview can show you how many threads are created to handle the calls.
0
 

Author Comment

by:mikechen
ID: 1414358
Hi, Mirkwood,

Is there any difference between STA and MTA regarding to how may threads are created ?

If the server is using STA, when there are many clients try to call the same method, exactly what happens ?

Thanks,


Mike


0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1414359
Hmm, I've not really tested the difference. My quess would be that it does not make any difference since the RPC manager just manages the connections and the number of connections is equal given a certain number of users.
BTW: you can always mail Richard himself at rtg@grimes.demon.co.uk or visit his website http://www.grimes.demon.co.uk/
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question