Changes to attempt to silence bcc64x
[ACE_TAO.git] / TAO / docs / leader_follower.html
blobf722cf12fd394feacaaf20c6f70c4d7c4ec0699e
1 <html>
2 <!-- -->
3 <head>
4 <title>Implementation of leader follower model for global resources</title>
5 </head>
7 <BODY text = "#000000"
8 link="#0000ff"
9 vlink="#cc0000"
10 bgcolor="#ffffff">
12 <body>
13 <HR>
14 <h1>Leader follower model for global resources</h1>
15 <HR>
16 <h2>Context</h2>
17 Global resources in TAO mean one ORB and using the reactive strategy
18 one Reactor. TAO uses the ACE Select Reactor for this purpose.
19 One main problem with multithreading and only one Reactor is that
20 only one thread can wait in handle_events at a time.
21 Handle_events is called, when a thread expects input, meaning
22 it is blocking to wait for it.
24 <h2>Idea</h2>
25 One solution to this problem is to use a leader-follower model,
26 which partitions the set of threads wanting to wait for input
27 into one leader and followers. Every thread is eligible to become
28 a leader. A thread wanting to wait while nobody else is waiting
29 becomes the leader. If the leader gets its input, which is in
30 this case its response, it will select a new leader out of the
31 set of followers. The followers wait on a condition variable they
32 own and register it with the ORB core. The ORB core is thereby
33 responsible for making this access thread-save by providing
34 a lock for the list of followers with some flags, like
35 leader_available.
37 <h2>Implementation</h2>
38 The above mentioned condition variables are owned by the
39 connection handlers, because responses are expected per connection,
40 not necessarily, thinking about other resource models, per thread.
41 <p>
42 The involved classes are TAO_ORB_Core, TAO_Client_Connection_Handler
43 and TAO_ORB. In the TAO_ORB_Core class the list of followers, a lock,
44 a leader reference counter and a leader thread ID were added.
45 The handle_input and send_request methods on the TAO_Client_Connection_Handler
46 contain 95% of the code used for implementing the leader-follower
47 model. Care has to be taken, that the connection handlers are
48 suspended and resumed, properly. A special concern is that
49 no deadlocking occurs.
51 <HR>
52 For more details and questions,
53 <p>
55 <address><a href="mailto:mk1@cs.wustl.edu">Michael Kircher</a></address>
56 <p>
57 <address><a href="mailto:irfan1@cs.wustl.edu">Irfan Pyarali</a></address>
58 </body>
59 </html>