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; // fetch information about the IRQs for this pid if (devctl (fd, DCMD_PROC_IRQS, irqs, sizeof (irqs), &nirqs) != EOK) { fprintf (stderr, "%s: IRQS proc %d, errno %d (%s)\n", progname, pid, errno, strerror (errno)); 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 6 tid 2 handler 0x00000000 area 0xEFFF7168 flags 0x0000000E level 14 mask_count 0 id 2 vector 14 event (sigev_notify type 4) SIGEV_PULSE (sigev_coid 1073741826, sigev_value.sival_int 0, sigev_priority 21, sigev_code 2) Buffer 1 pid 6 tid 3 handler 0x00000000 area 0xEFFF71E0 flags 0x0000000E level 15 mask_count 0 id 3 vector 15 event (sigev_notify type 4) SIGEV_PULSE (sigev_coid 1073741829, sigev_value.sival_int 0, sigev_priority 21, sigev_code 2)
The members of the debug_irq_t shown above are as follows: