Quote:
Originally Posted by chrism01
When I was reading up on threads, they said not to mix signals and threads, not least because thrs are lightweight processes inside the one process env (as of 2.6 kernels).
Use thr globals vars, as per 2nd suggestion above.
|
Thanks for the quick response .
All my 5 thread will run in endless loop (like task).so witting 1 for starting and 0 during end cannot work.
i planing 3 ideas plz let me know the your comments
****************************************************************
1) Thread 6 will send ping request (can call send Alive message ) to all thread using Posix message queue , and then wait for the response (Non Blocking call to read the queue).As soon as each thread (1 to 5)got the request they will prepare a response message and send to task 6 queue (response message will contain the thread ID , in order identify which thread is responded ).thread 6 will read the q
if any one thread is not responding thread 6 will retry or take necessary action .
The above steps will do periodically by thread 6.
*****************************************************************
2) using signal , thread 6 will send signal to other threads , Each threads having the signal handler ,. As soon as the handler is invoked threads (1-5) will be send response signal to thread 6 thread 6 will collect response signal and verify who is not responded and take necessary action for that
****************************************************************
3) using a global Array
int sendAliveMsg[NO_OF_THREAD];//global array
Thread 6 will make all position in the array (sendAliveMsg) to 0.
if threads [1-5] found their location is 0 zero will make it 1
periodically thread 6 will read the array and check status is 1 .if status is 1 it will make to 0. if any thread is running properly it cannot reset the global array.
*******************************************************