shell/ticks.c (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
#include "cedos.h"
#include "stdio.h"
#include <stdint.h>
#include "stdlib.h"
#include "string.h"
#include "cedos.h"
void main(char *args) {
if (strlen(args) == 0) {
int ticks = sc_time_get_ticks();
printf("%i\n", ticks);
} else {
int interval = atoi(args);
if (interval <= 0) {
printf("Invalid interval value.\n");
return;
}
int pid = get_pid();
int superticks = 0;
while (1) {
int ticks = sc_time_get_ticks();
if (ticks / interval != superticks) {
printf("[%i] %i ticks\n", pid, ticks);
superticks = ticks / interval;
}
yield();
}
}
}