Re: How to implement synchronous rpc between 2 processes on the same machine.
- From: "lali.cpp" <lali.cpp@xxxxxxxxx>
- Date: Mon, 22 Sep 2008 00:09:22 -0700 (PDT)
On Sep 22, 8:20 am, "Chris M. Thomasson" <n...@xxxxxxxxxxxx> wrote:
"lali.cpp" <lali....@xxxxxxxxx> wrote in message
news:478d5717-1233-42eb-b6a9-a5be184d414a@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi
I hope i have not posted at the wrong place. Kindly read the full post
before lamenting as off topic:
Basically i need functionality similar to that provided by Solaris
DOORS( it is a properietry and quite efficient IPC by SUN)
To explain it:
I have process p1 and process p2 on the same computer and i can call a
function foo( ) in process p2 from p1 i.e rpc( on the same host) using
the function door_call( which takes arguments and writes and
This function door_call is synchronous. Moreover the DOOR library
makes sure that the function f( ) is executed in a concurrent manner
i.e it internally maintains a pool of threads i.e the server( process
p2 is a concurrent server )
So thats all about my requirement. I cannot use DOORS because i am now
porting the project to Linux.
So here is my design the i want you to kindly kindly review and give
me lots of details, caveats, shortcomings, suggestions etc as i am not
very well good in multithreaded programming and would like to have
your guidance rather that implement something that takes a lot of
locks and generates a lot of threads but is essentially serialized
code and add to it the problem of deadlocks and races. I need
efficiency and scalability in design and so require you geeks out
there to just review this design and provide your much needed inputs.
[...]
Read here for some tips on how to implement dynamically created shared
memory:
http://groups.google.com/group/comp.programming.threads/browse_frm/th...
One caveat... How are you going to handle a scenario in which a process gets
terminated while it holds a mutex? How much you do know about robust mutexs?
The link above deals with some of that. I have created impls of something
that is basically analogous to Solaris Doors. Perhaps I can help you. Its
not easy in any sense of the term indeed. However, its doable. You need to
think about how your going to handle the "robustness" factor first.
Multi-process shared memory impls need to think about misbehaving process..
Before I go on and on, do you have any thoughts on this aspect?
Well i have read a little about boost::thread library and we have a
non-blocking timed mutex in there. So instead of having a blocking
mutex we could use the boost::timedmutex.
In my particular case, let me elaborate the kind of functionality i
need. Process p1 wants to call a function say my_door(arguments). This
function will be executed in process 2 and results will be written to
the buffer sent by process 1 in the arguments to my_door.
I am not saying i need shared memory, all i am saying is what would be
the *best* way to do( doesn't matter using shared memory, message
queues or any other ipc mechanism). But the most important thing is
that multiple threads from p1 can call my_door( ) function and all the
requests are executed *concurrently* on the server side. Second
requirement is my_door( ) call is synchronous i.e blocking i.e just
like door_call in solaris. ( Of course the application makes sure that
the function being executed is thread safe )
Here is something i have thought and i need your suggestions :
We can have 2 queues say q1 and q2 in the shared memory and both the
processes have a dedicated thread each listening at these queues i.e
process p1 has a thread checking to see if p2 has written something on
q1 and p2 has a thread listening to q2 to check if p1 wrote something
in q2.
These respective threads can then distribute the remaining work to
worker threads in the respective threads.
this is just a vague idea but how would i make the door_call
synchronous ? the thread in p1 would just write the arguments in q2
and return ?
And i also need some suggestions whether the above design would be
fine or not ? Or does it suck just like my earlier design in the last
post( don't read it anyway )
Thanks & Regards
lali.cpp
.
- Follow-Ups:
- References:
- How to implement synchronous rpc between 2 processes on the same machine.
- From: lali.cpp
- Re: How to implement synchronous rpc between 2 processes on the same machine.
- From: Chris M. Thomasson
- How to implement synchronous rpc between 2 processes on the same machine.
- Prev by Date: Re: How to implement synchronous rpc between 2 processes on the same machine.
- Next by Date: Re: How to implement synchronous rpc between 2 processes on the same machine.
- Previous by thread: Re: How to implement synchronous rpc between 2 processes on the same machine.
- Next by thread: Re: How to implement synchronous rpc between 2 processes on the same machine.
- Index(es):
Relevant Pages
|