-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheetah.c
More file actions
58 lines (40 loc) · 1.05 KB
/
cheetah.c
File metadata and controls
58 lines (40 loc) · 1.05 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <linux/sched.h>
#include <linux/kthread.h>
MODULE_LICENSE("MIT");
#define NUM_CHEETAH_THREADS 4
struct task_struct *k[NUM_CHEETAH_THREADS];
static void kthread_main(void)
{
u32 vmx_msr_low, vmx_msr_high;
rdmsr(MSR_IA32_UCODE_REV, vmx_msr_low, vmx_msr_high);
schedule();
}
static int kthread_func(void* arg)
{
printk(KERN_INFO "start kthread\n");
while (!kthread_should_stop()) {
kthread_main();
}
printk(KERN_INFO "stop kthread\n");
return 0;
}
static int __init cheetah_init(void)
{
int i;
for (i = 0; i < NUM_CHEETAH_THREADS; i++) {
k[i] = kthread_run(kthread_func, NULL, "cheetah kthread");
kthread_bind(k[i], i);
}
printk(KERN_INFO "cheetah loaded\n");
return 0;
}
static void __exit cheetah_exit(void)
{
int i;
for (i = 0; i < NUM_CHEETAH_THREADS; i++) {
kthread_stop(k[i]);
}
printk(KERN_INFO "cheetah unloaded\n");
}
module_init(cheetah_init);
module_exit(cheetah_exit);