Hello,
My resource manager starts a thread to manage IRQ events only after it receives some type of message from clients.
First the RM starts
241691 1 ./devc_dataaq 30o RECEIVE 1
241691 2 ./devc_dataaq 30o RECEIVE 1
241691 3 ./devc_dataaq 30o RECEIVE 1
To start the thread :
pthread_attr_init (&attr);
pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_DETACHED);
pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED);
pthread_attr_setschedpolicy( &attr, SCHED_FIFO);
attr.param.sched_priority = 60;
pthread_create(&th_interr, &attr, th_irq, &msg);
Then, if the RM gets new messages and need to re-start the thread, I do:
if (th_interr != 0) ThreadDestroy(th_interr, 60, NULL);
The RM works fine for the first thread,
241691 1 ./devc_dataaq 30o RECEIVE 1
241691 2 ./devc_dataaq 30o RECEIVE 1
241691 3 ./devc_dataaq 50o RECEIVE 1
241691 4 ./devc_dataaq 60f INTR
the other process running have the same priority as the RM and the new thread have the requested priority, you can see a thread with priority 50, I dont know where this came from (thread pool - write requests?), and when I need to destroy the running thread and start a new thread, the priority is all mixed up (as show by pidin) :
241691 1 ./devc_dataaq 60o RECEIVE 1
241691 2 ./devc_dataaq 30o RECEIVE 1
241691 3 ./devc_dataaq 50o RECEIVE 1
241691 4 ./devc_dataaq 60o RECEIVE 1
241691 5 ./devc_dataaq 60f INTR
One more thing, Now I get 5 threads instead of only 4. I think I’m having problems with the ThreadDestroy…
Note - Thread pool :
memset(&pool_attr, 0, sizeof pool_attr);
pool_attr.handle = dpp;
pool_attr.context_alloc = resmgr_context_alloc;
pool_attr.block_func = resmgr_block;
pool_attr.handler_func = resmgr_handler;
pool_attr.context_free = resmgr_context_free;
pool_attr.lo_water = 2;
pool_attr.hi_water = 4;
pool_attr.increment = 1;
pool_attr.maximum = 50;
So…