From 86caa918a800a120dd7325c7bece4f7f5015dca3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ciro=20Santilli=20=E5=85=AD=E5=9B=9B=E4=BA=8B=E4=BB=B6=20?= =?UTF-8?q?=E6=B3=95=E8=BD=AE=E5=8A=9F?= Date: Mon, 11 Nov 2019 00:00:00 +0000 Subject: [PATCH] readme: further interlink _NPROCESSORS_CONF and controlling the --cpus count --- README.adoc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/README.adoc b/README.adoc index dd0334a..3cfe35e 100644 --- a/README.adoc +++ b/README.adoc @@ -10650,13 +10650,24 @@ cat /proc/cpuinfo getconf _NPROCESSORS_CONF .... +Or from <>, we can use <> with link:userland/linux/sysconf.c[] or <>'s link:userland/cpp/thread_hardware_concurrency.cpp[]: + +.... +./run --cpus 2 --emulator gem5 --userland userland/linux/sysconf.c | grep _SC_NPROCESSORS_ONLN +./run --cpus 2 --emulator gem5 --userland userland/cpp/thread_hardware_concurrency.cpp +.... + ====== QEMU user mode multithreading -TODO why in <> QEMU always shows the number of cores of the host. E.g., both of the following output the same as `nproc` on the host: +<> QEMU v4.0.0 always shows the number of cores of the host, presumably because the thread switching uses host threads directly which would make that harder to implement. + +It does not seem possible to make the guest see a different number of cores than what the host has. Full system does have the `-smp` options, which controls this. + +E.g., all of of the following output the same as `nproc` on the host: .... nproc -./run --userland userland/cpp/thread_hardware_concurrency.cpp +./run --cpus 1 --userland userland/cpp/thread_hardware_concurrency.cpp ./run --cpus 2 --userland userland/cpp/thread_hardware_concurrency.cpp ....