This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
zhangyang-variable-monitor/testcase/helloworld.c

38 lines
719 B
C
Raw Normal View History

2023-11-16 14:07:26 +08:00
#include "../source/uapi/monitor_user.h"
2023-11-16 13:17:49 +08:00
#include <stdio.h>
#include <string.h>
2023-11-27 20:34:06 -05:00
#include <unistd.h>
2023-11-16 13:17:49 +08:00
#define NUM_VARS 2049
2023-11-27 20:34:06 -05:00
int main() {
int i = 0;
int temps[NUM_VARS] = {0};
watch_arg watch_args[NUM_VARS] = {0};
cancel_watch();
for (i = 0; i < NUM_VARS; i++) {
temps[i] = 100;
char name[20];
snprintf(name, sizeof(name), "temp%d", i);
// 拷贝字符串
strncpy(watch_args[i].name, name, (MAX_NAME_LEN + 1));
2023-11-27 21:01:02 -05:00
START_WATCH_INT(name, &temps[i], (110 + i));
2023-11-27 20:34:06 -05:00
}
2023-11-16 13:17:49 +08:00
2023-11-27 20:34:06 -05:00
while (temps[NUM_VARS - 1] < 205) {
for (i = 0; i < NUM_VARS; i++) {
temps[i]++;
2023-11-16 13:17:49 +08:00
}
2023-11-27 20:34:06 -05:00
printf("Value of variable %d: %d", i, temps[0]);
printf("\n");
sleep(1);
}
2023-11-16 13:17:49 +08:00
2023-11-27 20:34:06 -05:00
cancel_watch();
return 0;
2023-11-17 01:59:41 -05:00
}