Hi George,
It is quite complicated to find a problem just speaking about it. I don’t remember any well known issue, which might cause this. I think it would be more effective if you can post some example clearly showing the behaviour you described, or, at least, output of pidin during the program work as a starter.
At first, take a look at the example below. I hope it resembles description of your task. I chose RTC as a source of interrupts. You can play with priority and rate. It works fine on any rate on P200 with priority 22. Nothing preempts the IRQ thread.
I don’t think the OS version is an issue here. Now I run this test on 6.2, but I dont remember any problems running similar task on 6.1 a while ago.
I am, also, pretty sure the procnto priority has nothing to do with this problem. As Chris mentioned before the procnto is client priority driven. High thread priority can only be an indication that some other process running on this high priority called procnto service. Most of the time all procnto’s threads are RECEIVE blocked.
Sincerely,
Serge
#include <unistd.h>
#include <stdlib.h>
#include <stdint.h>
#include <pthread.h>
#include <sys/slog.h>
#include <sys/slogcodes.h>
#include <sys/syspage.h>
#include <sys/siginfo.h>
#include <sys/neutrino.h>
#include <x86/inout.h>
#define RTC_CMD_ADDR 0x70 /* RTC internal register offset goes here /
#define RTC_DAT_ADDR 0x71 / RTC internal register R/W access here */
#define RTC_REG_A 0x0A /* RTC register offset for accessing Reg. A /
#define RTC_REG_B 0x0B / RTC register offset for accessing Reg. B /
#define RTC_REG_C 0x0C / RTC register offset for accessing Reg. C /
#define RTC_REG_D 0x0D / RTC register offset for accessing Reg. D */
#define RTC_IRQ 8
#define SLOG_CODE (_SLOGC_NEXT_QNX+1)
static uint64_t ih, it;
static int rate = 6; /* 0.000977 s */
const struct sigevent *interrupt_handler( void *data, int id )
{
struct sigevent *event = (struct sigevent *) data;
/*
- Mask interrupt until interrupt thread
- proceeds this event.
*/
InterruptMask( RTC_IRQ, id );
ih++;
/*
- Arm RTC
*/
out8( RTC_CMD_ADDR, RTC_REG_C );
in8( RTC_DAT_ADDR );
return event;
}
void * interrupt_thread( void *data )
{
uint64_t c1, c2, cps;
int id;
ThreadCtl( _NTO_TCTL_IO, 0 );
/*
- Enable RTC periodic IRQ
*/
out8( RTC_CMD_ADDR, RTC_REG_C );
in8( RTC_DAT_ADDR );
InterruptDisable();
out8( RTC_CMD_ADDR, RTC_REG_B ); /* select RTC register B /
out8( RTC_DAT_ADDR, 0x42 ); / set Periodic Interrupt Enable bit */
out8( RTC_CMD_ADDR, RTC_REG_A ); /* select RTC register A /
out8( RTC_DAT_ADDR, 0x20 | rate ); / set rate, oscillator enabled */
InterruptEnable();
id = InterruptAttach( RTC_IRQ,
interrupt_handler,
data,
sizeof( struct sigevent ),
_NTO_INTR_FLAGS_TRK_MSK );
cps = SYSPAGE_ENTRY( qtime )->cycles_per_sec;
c1 = ClockCycles();
for( ;; ) {
InterruptWait( 0, NULL );
c2 = ClockCycles();
it++;
slogf( _SLOG_SETCODE( SLOG_CODE, 0 ), _SLOG_DEBUG1, “IRQ: %f %lld %lld”, ( c2 - c1 ) / (double) cps, ih, it );
c1 = c2;
InterruptUnmask( RTC_IRQ, id );
}
}
int main( int argc, char **argv )
{
pthread_t tid;
pthread_attr_t pattr;
struct sched_param parm;
struct sigevent event;
int c, prio = 10;
while( -1 != ( c = getopt( argc, argv, “p:r:” ))) {
switch( c ) {
case ‘p’:
prio = atoi( optarg );
break;
case ‘r’:
c = atoi( optarg );
if( c > 2 && c < 16 )
rate = c;
break;
}
}
SIGEV_INTR_INIT( &event );
pthread_attr_init( &pattr );
pthread_attr_setschedpolicy( &pattr, SCHED_RR );
parm.sched_priority = prio;
pthread_attr_setschedparam( &pattr, &parm );
pthread_attr_setinheritsched( &pattr, PTHREAD_EXPLICIT_SCHED );
pthread_create( &tid, &pattr, interrupt_thread, &event );
pthread_join( tid, NULL );
return 0;
}
I wonder if procnto raises it’s own priority to carry
out process creation
tasks.
I ran pidin from memory (dev/shmem) - the results are
the same (nice
suggestion though, thanks). The preemption does not
seem to be a strong
function of the “size” of the application launched.
Whether I run “pidin” or
launch “slinger” the same preemption occurs. Also, if
I do an execl() on an
existing process, the preemption occurs (when execl
is executed) just as if
a new process had been spawned.
I’m stumped.
-george