Untitled
unknown
plain_text
2 years ago
864 B
5
Indexable
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/sysctl.h>
int main() {
int processes_waiting;
int processes_uninterruptible;
// Get the number of processes waiting for run time
if (sysctlbyname("kern.running", &processes_waiting, NULL, NULL, 0) == -1) {
perror("Error getting processes waiting for run time");
exit(EXIT_FAILURE);
}
// Get the number of processes in uninterruptible sleep
if (sysctlbyname("kern.uninterruptible", &processes_uninterruptible, NULL, NULL, 0) == -1) {
perror("Error getting processes in uninterruptible sleep");
exit(EXIT_FAILURE);
}
printf("Processes waiting for run time (r): %d\n", processes_waiting);
printf("Processes in uninterruptible sleep (b): %d\n", processes_uninterruptible);
return 0;
}
Editor is loading...
Leave a Comment