mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-22 17:55:57 +01:00
sched_getcpu: input and sample outputs
This commit is contained in:
24
README.adoc
24
README.adoc
@@ -17305,6 +17305,30 @@ So when running a multicore program, we may see that each thread can be running
|
||||
|
||||
The cores in which the process runs can be fixed with `sched_setaffinity` as shown at: link:userland/linux/sched_getaffinity.c[].
|
||||
|
||||
So when I run it with `main` thread + 4 threads on a 4 core CPUs:
|
||||
|
||||
....
|
||||
./userland/linux/sched_getcpu.out 4
|
||||
....
|
||||
|
||||
I see random outputs like:
|
||||
|
||||
....
|
||||
7
|
||||
2
|
||||
1
|
||||
5
|
||||
....
|
||||
|
||||
and:
|
||||
|
||||
....
|
||||
5
|
||||
0
|
||||
2
|
||||
1
|
||||
....
|
||||
|
||||
=== Linux calling conventions
|
||||
|
||||
A summary of results is shown at: xref:table-linux-calling-conventions[xrefstyle=full].
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
void* main_thread(void *arg) {
|
||||
(void)arg;
|
||||
printf("sched_getcpu = %d\n", sched_getcpu());
|
||||
printf("%d\n", sched_getcpu());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user