DF-3590 / mouse_reader.c
/* DF-3590/exploratory: keep /dev/psm0 open with reader threads while the * host injects PS/2 mouse events via the QEMU monitor. Exercises psmintr() * (hard IRQ 12) -> psmsoftintr() direct call -> lockmgr() on sc->lock. */ #include <sys/ioctl.h> #include <sys/mouse.h> #include <fcntl.h> #include <pthread.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <time.h> static int fd; static void *reader(void *arg) { char buf[64]; long total = 0; for (;;) { ssize_t n = read(fd, buf, sizeof(buf)); if (n > 0) total += n; } return (NULL); } int main(int argc, char **argv) { int secs = argc > 1 ? atoi(argv[1]) : 60; pthread_t t1, t2; struct timespec ts; fd = open("/dev/psm0", O_RDWR); if (fd < 0) { perror("open"); return 1; } pthread_create(&t1, NULL, reader, NULL); pthread_create(&t2, NULL, reader, NULL); printf("readers running for %ds\n", secs); fflush(stdout); ts.tv_sec = secs; ts.tv_nsec = 0; nanosleep(&ts, NULL); printf("done\n"); return (0); } |