Boost logo

Boost Users :

Subject: [Boost-users] Monitoring thread liveness using multiple threads with a single asio io_service
From: Krajnak, Mike (GE Healthcare) (michael.krajnak_at_[hidden])
Date: 2011-04-11 14:33:47


We have a server implemented with boost::asio that uses a vector of
threads with a single io_service as in the asio http server 3 sample
program.

 

We want to check on the liveness of threads by having each thread
periodically call back to a thread manager so that we can confirm it is
still running.

 

To do that we have an inner loop that uses run_one() so we can call our
heartbeat function after each action is completed (pseudo code):

 

    do

  {

      num_ops = io_svc.run_one(ec)

      heartbeat_to_thread_manager();

  }

  while (num_ops > 0);

 

However, asio makes no garantees on how work is dispatched to threads.
In our testing work seems to go prefentially to one thread for several
iterations before going to another thread with no pattern that we can
find.

 

Is there some way we can change this solution so that we can be
reasonably sure each thread will be called at least once in a some
period of time or some other mechanism for monitoring thread liveness?

 

Thanks,

 

Mike

 

 

 

 



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net