sched_getcpu: input and sample outputs

This commit is contained in:
Ciro Santilli 六四事件 法轮功
2020-04-17 05:00:04 +00:00
parent 1300b25e29
commit cc78fe7d81
2 changed files with 25 additions and 1 deletions

View File

@@ -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[]. 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 === Linux calling conventions
A summary of results is shown at: xref:table-linux-calling-conventions[xrefstyle=full]. A summary of results is shown at: xref:table-linux-calling-conventions[xrefstyle=full].

View File

@@ -12,7 +12,7 @@
void* main_thread(void *arg) { void* main_thread(void *arg) {
(void)arg; (void)arg;
printf("sched_getcpu = %d\n", sched_getcpu()); printf("%d\n", sched_getcpu());
return NULL; return NULL;
} }