Discussion:
[omniORB] A multi-thread question
2007-12-21 15:55:21 UTC
Permalink
I'm a newcomer trying to use omniORB to build an application configured to support multi-thread feature. Here is a question I can not find answers to on internet:

omniORB server supports to upcall application codes through multi threads. If I have only one servant activated in the main thread, and I configured thread pool mode on the server side, does every invoked thread incarnate one more servant to serve the incoming requests? Or, only one servant serves all threads' incoming requests?

Thanks.

Thierry from Beijing, China
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20071221/d55c9a07/attachment.htm
Duncan Grisby
2007-12-21 17:47:36 UTC
Permalink
Post by 罗
omniORB server supports to upcall application codes through multi
threads. If I have only one servant activated in the main thread, and
I configured thread pool mode on the server side, does every invoked
thread incarnate one more servant to serve the incoming requests? Or,
only one servant serves all threads' incoming requests?
If you just activate one servant, then that single servant will be used
for all the incoming requests concurrently. That's true regardless of
whether you use thread pool mode or the default thread per connection
mode.

In CORBA, the system never automatically incarnates servants for you.
If that's what you want, you must explicitly create and configure a
servant manager.

Cheers,

Duncan.
--
-- Duncan Grisby --
-- ***@grisby.org --
-- http://www.grisby.org --
2007-12-22 07:41:22 UTC
Permalink
Dear Duncan, Thanks for your reply. As you said omniORB just use 'manually' and explicitly activated servants(one or more) to service all incoming concurrent requests. So, what isthe good to use thread pool? I mean, all concurrent requests must wait inqueue for the servants to be idle, which is just like all concurrentrequests waiting on the same connection or the same thread. Does every worker thread from thread pool include the servant activated?What if there are serveral different servants? Do I have to enalblemore POAs to deal with them? I don't know the thread model once the ORB gets running. The servant isa single thread? The main thread just listens on the endpoints and dispatchrequests to worker thread? What source files should I refer to? Thanks. Thierry from Beijin, China
ÔÚ2007-12-21£¬"Duncan Grisby" <***@grisby.org> ÐŽµÀ£º
On Friday 21 December, "=?gb2312?B?wt4=?=" wrote: > omniORB server supports to upcall application codes through multi > threads. If I have only one servant activated in the main thread, and > I configured thread pool mode on the server side, does every invoked > thread incarnate one more servant to serve the incoming requests? Or, > only one servant serves all threads' incoming requests? If you just activate one servant, then that single servant will be used for all the incoming requests concurrently. That's true regardless of whether you use thread pool mode or the default thread per connection mode. In CORBA, the system never automatically incarnates servants for you. If that's what you want, you must explicitly create and configure a servant manager. Cheers, Duncan. -- -- Duncan Grisby -- -- ***@grisby.org -- -- http://www.grisby.org --
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20071222/143ce38b/attachment.htm
Luo Yongheng
2008-01-03 21:20:42 UTC
Permalink
Hi,

Here is one question still regarding multi-thread mode:

I use multi-thread mode on server side. Assume that we have one servant
incarnated, does that mean all running threads/tasks enters the same
memory/code area of the servant in the main process? since all the
threads/tasks share the same memory image of the main process.

Futhre, if we incarnate one more servant whose implementation is the
same as the previous one, does that still mean all threads/tasks enters
the same memory area as previous one? Because functions of different
objects of the same class just shares the same memory area, and the only
difference is the implicit 'this' pointer passed as the parameter.

So can we conclude that incarnating more than one servants of the same
implementation class does not help improve the multi-thread efficiency?

Thanks.

Thierry from Beijing, China


----- Original Message -----
Post by Duncan Grisby
Post by 罗
omniORB server supports to upcall application codes through multi
threads. If I have only one servant activated in the main thread, and
I configured thread pool mode on the server side, does every invoked
thread incarnate one more servant to serve the incoming requests? Or,
only one servant serves all threads' incoming requests?
If you just activate one servant, then that single servant will be used
for all the incoming requests concurrently. That's true regardless of
whether you use thread pool mode or the default thread per connection
mode.
In CORBA, the system never automatically incarnates servants for you.
If that's what you want, you must explicitly create and configure a
servant manager.
Cheers,
Duncan.
--
-- Duncan Grisby --
-- http://www.grisby.org --
Duncan Grisby
2008-01-02 18:02:58 UTC
Permalink
Post by 罗
Dear Duncan, Thanks for your reply. As you said omniORB just use
'manually' and explicitly activated servants(one or more) to service
all incoming concurrent requests. So, what isthe good to use thread
pool? I mean, all concurrent requests must wait inqueue for the
servants to be idle, which is just like all concurrentrequests waiting
on the same connection or the same thread.
I think you have your terminology confused.

A servant is just a programming language object. Multiple threads can
call a single servant's methods at the same time. There is no queue
waiting for a servant to become free -- if two calls for a particular
object come in at the same time, methods on the servant are called
concurrently.

I suggest you read the free online book "CORBA explained simply" by
Ciaran McHale, which explains all the terminology well:

http://www.ciaranmchale.com/corba-explained-simply/

Cheers,

Duncan.
--
-- Duncan Grisby --
-- ***@grisby.org --
-- http://www.grisby.org --
Duncan Grisby
2008-01-10 21:16:04 UTC
Permalink
Post by Luo Yongheng
I use multi-thread mode on server side.
omniORB is always multi-threaded. You can't choose not to be
multi-threaded. You can only choose between different ways of allocating
threads, not to avoid using threads altogether.
Post by Luo Yongheng
Assume that we have one servant
incarnated, does that mean all running threads/tasks enters the same
memory/code area of the servant in the main process? since all the
threads/tasks share the same memory image of the main process.
Yes.
Post by Luo Yongheng
Futhre, if we incarnate one more servant whose implementation is the
same as the previous one, does that still mean all threads/tasks enters
the same memory area as previous one? Because functions of different
objects of the same class just shares the same memory area, and the only
difference is the implicit 'this' pointer passed as the parameter.
If you incarnate another servant, it will correspond to a different
CORBA object. If all the client calls are to the first CORBA object, all
the calls will be handled by the first servant, and the second servant
will be ignored.
Post by Luo Yongheng
So can we conclude that incarnating more than one servants of the same
implementation class does not help improve the multi-thread efficiency?
No. I think you are imagining some kind of link between servants and
threads. There isn't any relationship between them. CORBA objects can
map to servants in various ways, depending on the POA setup, but
threading never comes into it.

Duncan.
--
-- Duncan Grisby --
-- ***@grisby.org --
-- http://www.grisby.org --
Jonathan Biggar
2008-01-10 23:07:23 UTC
Permalink
Post by Duncan Grisby
Post by Luo Yongheng
Futhre, if we incarnate one more servant whose implementation is the
same as the previous one, does that still mean all threads/tasks enters
the same memory area as previous one? Because functions of different
objects of the same class just shares the same memory area, and the only
difference is the implicit 'this' pointer passed as the parameter.
If you incarnate another servant, it will correspond to a different
CORBA object. If all the client calls are to the first CORBA object, all
the calls will be handled by the first servant, and the second servant
will be ignored.
Post by Luo Yongheng
So can we conclude that incarnating more than one servants of the same
implementation class does not help improve the multi-thread efficiency?
No. I think you are imagining some kind of link between servants and
threads. There isn't any relationship between them. CORBA objects can
map to servants in various ways, depending on the POA setup, but
threading never comes into it.
Actually, if you find a need to code a CORBA server where each incoming
CORBA request thread for a given object needs its own servant, you can
install a ServantLocator in your POA to accomplish this. Each call to
ServantLocator::preinvoke creates a new servant, and each call to
ServantLocator::postinvoke destroys it.

This can be useful when all of your object state is stored externally,
like in a database, and you don't want to cache any state in the servant
class itself.
--
Jon Biggar
Levanta Inc
***@levanta.com
Continue reading on narkive:
Loading...