diff --git a/README.adoc b/README.adoc index 0e9cae0..20dffdd 100644 --- a/README.adoc +++ b/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]. diff --git a/userland/linux/sched_getcpu.c b/userland/linux/sched_getcpu.c index 294a1b3..0d5cd1b 100644 --- a/userland/linux/sched_getcpu.c +++ b/userland/linux/sched_getcpu.c @@ -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; }