Hello QNX community,
I am working with some legacy code. This code is basically a driver (which
is single threaded) for some polled hardware. Here is a vital snippet where
the timer that is used to “drive” the hardware is set up:
#define RS_CTL_POLLING_INTERVAL 1 // in milliseconds
#define RS_CTL_TIMEOUT_INTERVAL 1000 // in milliseconds
// Set up a channel in order to receive QNX messages and pulses
int coid;
coid = ConnectAttach(0,0,attach->chid,_NTO_SIDE_CHANNEL,0);
// Set up the sigevent struct for the ctl timer and create this timer
sigevent event;
event.sigev_notify = SIGEV_PULSE;
event.sigev_priority = 24;
event.sigev_coid = coid;
event.sigev_code = PULSE_CTL_TIMER;
timer_create(CLOCK_REALTIME, &event, &CtlTimer);
// Set up the ctl timer as a repeating interval timer!
CtlTimerSpecPoll.it_value.tv_sec = RS_CTL_POLLING_INTERVAL/1000;
CtlTimerSpecPoll.it_value.tv_nsec = (RS_CTL_POLLING_INTERVAL % 1000) *
1000000;
CtlTimerSpecPoll.it_interval.tv_sec = RS_CTL_POLLING_INTERVAL/1000;
CtlTimerSpecPoll.it_interval.tv_nsec = (RS_POLLING_INTERVAL %1000) *
1000000;
// Set up the ctl timer as a one shot timer!
CtlTimerSpecTimeout.it_value.tv_sec =
RS_CTL_TIMEOUT_INTERVAL /1000;
CtlTimerSpecTimeout.it_value.tv_nsec =
(RS_CTL_TIMEOUT_INTERVAL % 1000) * 1000000;
CtlTimerSpecTimeout.it_interval.tv_sec = 0;
CtlTimerSpecTimeout.it_interval.tv_nsec = 0;
CtlTimerPollCount = RS_CTL_TIMEOUT_INTERVAL/RS_CTL_POLLING_INTERVAL;
CtlTimerCountdown = -1;
// Arm the ctl timer as a repeating interval timer
timer_settime(CtlTimer, 0, &CtlTimerSpecPoll, NULL);
As one can see an interval timer is set up to fire every millisecond and
send a pulse at priority 24(!!).The timer-associated pulse is delivered to
the driver itself and the driver is using the SCHED_RR scheduling policy. We
have several other cooperating processes other than the driver and they are
all running at priority 10.
I would like to know others’ thoughts about this execution environment in
terms of thread starvation, responseness of other threads in other processes
including QNX-supplied processes, etc. E.g. I have been told that ionet runs
at priority 21.
Regards, Bill Halchin