#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <time.h>
#include <map>
#include <sched.h>
#include <unistd.h>
using namespace std;
int thread_func(void*) {
for (int i = 0; i < 10; i++) {
printf("this is kernel thread\n");
sleep(1);
}
return 0;
}
char buf[4096];
int main() {
clone(thread_func, buf + 4096, CLONE_VM | CLONE_VFORK, 0);
return 0;
}
buf的大小必须是页大小的整数倍,否则会创建错误