Finally, we can also find out about the interrupts that are associated with a process.
We use the DCMD_PROC_IRQS command, and expect to get back zero or more data structures, as we did in the DCMD_PROC_PAGEDATA, DCMD_PROC_MAPINFO, and DCMD_PROC_TIMERS examples above. The structure procfs_irq is the same as the debug_irq_t, which is defined as follows:
typedef struct _debug_irq {
pid_t pid;
pthread_t tid;
const struct sigevent *(*handler)(void *area, int id);
void *area;
unsigned flags;
unsigned level;
unsigned mask_count;
int id;
unsigned vector;
struct sigevent event;
} debug_irq_t;
To fetch the data, we use code similar to what we used with the timers and memory segments:
#define MAX_IRQS 512
static void
dump_procfs_irq (int fd, int pid)
{
procfs_irq irqs [MAX_IRQS];
int nirqs;
int i;
int sts;
// fetch information about the IRQs for this pid
sts = devctl (fd, DCMD_PROC_IRQS, irqs, sizeof (irqs), &nirqs);
if (sts != EOK) {
fprintf (stderr, "%s: IRQS proc %d, error %d (%s)\n",
progname, pid, sts, strerror (sts));
exit (EXIT_FAILURE);
}
if (nirqs > MAX_IRQS) {
fprintf (stderr, "%s: proc %d > %d IRQs (%d) !!! ***\n",
progname, pid, MAX_IRQS, nirqs);
exit (EXIT_FAILURE);
}
printf ("Info from DCMD_PROC_IRQS\n");
for (i = 0; i < nirqs; i++) {
// print information here
}
printf ("\n");
}
Since our pipe command doesn't use interrupts either, I've once again selected devb-eide:
Info from DCMD_PROC_IRQS
Buffer 0
pid 8200
tid 2
handler 0x00000000
area 0xEFEA5FF0
flags 0x0000000C
latency 0
mask_count 0
id 3
vector 14
event (sigev_notify type 4)
SIGEV_PULSE (sigev_coid 0x40000002,
sigev_value.sival_int 0,
sigev_priority 21, sigev_code 2)
Buffer 1
pid 8200
tid 3
handler 0x00000000
area 0xEFEEFDA0
flags 0x0000000C
latency 0
mask_count 0
id 4
vector 15
event (sigev_notify type 4)
SIGEV_PULSE (sigev_coid 0x40000005,
sigev_value.sival_int 0,
sigev_priority 21, sigev_code 2)
The members of the debug_irq_t shown above are as follows: