* DCE, multithreading & pthread_self()
@ 1993-08-25 15:27 cbsmith
1993-08-25 17:30 ` Rich Salz
0 siblings, 1 reply; 2+ messages in thread
From: cbsmith @ 1993-08-25 15:27 UTC (permalink / raw)
Hello there. I'm playing around with stub code generated by the IDL
compiler. (I know.... DON'T TOUCH!! :-)
I am using a very simple RPC model (two remote procedures: one adds two
number and one multiply's two numbers). As the server can have multiple
calls running at the same time, I figured the best way to differentiate
each of the calls to the server was to have the stub code call
pthread_self(). However, I have discovered that even when I make a lot
of RPC calls (say 40) at approximately the same time (I did it the easy
way: started up 20 clients in the background on one machine) I'm
unlikely to have more than a few different return values for
pthread_self().
I've hypothesized that the server does not generate a new thread ID for
each RPC call it receives, but rather has a number of worker threads
running all the time which receive RPC calls and execute them. Any calls
beyond the limit imposed by DCE (presumably matching the number of
worker threads) are placed in a queue.
Is this correct, and if so, how would one go about creating unique ID's
for each RPC call that is received. From the programmers point of view
at least, each of these calls seem to be threads in the server process.
The programmer doesn't really deal with worker threads and such.
I haven't actually implemented my own explicit multithreading in my
server code, but if I *did* (I am planning to) it would make the whole
process even more confusing. (Is a new thread going to be handled by a
worker thread [old thread ID], or is it going to generate an entirely new
thread in the server [new thread ID]?)
Anyway, help on this manner would be appreciated.
--Chris
P.S.: I'm using DCE 1.0 on AIX
--
Christopher Smith
cbsmith@boomer.uwaterloo.ca
cbsmith@undergrad.math.uwaterloo.ca
DC 3527
(519) 885-1211x3581
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: DCE, multithreading & pthread_self()
1993-08-25 15:27 DCE, multithreading & pthread_self() cbsmith
@ 1993-08-25 17:30 ` Rich Salz
0 siblings, 0 replies; 2+ messages in thread
From: Rich Salz @ 1993-08-25 17:30 UTC (permalink / raw)
In <CBSMITH.93Aug25112729@ccnga.watserv2.uwaterloo.ca> cbsmith@ccnga.watserv2.uwaterloo.ca writes:
>I've hypothesized that the server does not generate a new thread ID for
>each RPC call it receives, but rather has a number of worker threads
>running all the time which receive RPC calls and execute them. Any calls
>beyond the limit imposed by DCE (presumably matching the number of
>worker threads) are placed in a queue.
This is 100% correct.
I'm not sure why you want unique ID's for each RPC call, but there are
a couple of things you can do. You first need to think about how you
are going to associate the ID with each RPC. You could attach it to
the thread, or you could keep it in some (global) per-operation state
table. To do the former, call pthread_keycreate before you call
rpc_server_listen, and then call pthread_getspecific and pthread_setspecific
to get and set your unique ID.
As for what to use for unique ID's there are two choices. A simple
increasing counter (protected by a mutex which must be initialized; easiest
to do before rpc_server_listen), or DCE uuid's.
>server code, but if I *did* (I am planning to) it would make the whole
>process even more confusing. (Is a new thread going to be handled by a
>worker thread [old thread ID], or is it going to generate an entirely new
>thread in the server [new thread ID]?)
I don't see how it is more confusing. If you need an application-specific
unique identifier, then you should use an application-specific kind of
thing. You really don't (want to) care whether threads are recycled or
not.
Hope this helps.
/r$
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1993-08-25 17:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1993-08-25 15:27 DCE, multithreading & pthread_self() cbsmith
1993-08-25 17:30 ` Rich Salz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox