diff --git a/index.html b/index.html index ac10dec..a64bab1 100644 --- a/index.html +++ b/index.html @@ -1082,8 +1082,8 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b @@ -1231,10 +1232,11 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b -
  • 20.1.2. GCC C extensions +
  • 20.1.2. C multithreading
  • +
  • 20.1.3. GCC C extensions
  • @@ -1267,6 +1269,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
  • 20.5. C debugging
  • 20.6. Userland content bibliography
  • @@ -3700,7 +3703,7 @@ echo "$(./getvar --arch aarch64 --emulator gem5 image)"
    -

    see also: Section 18.17, “gem5 ARM platforms”.

    +

    see also: Section 18.18, “gem5 ARM platforms”.

    This generates yet new separate images with new magic constants:

    @@ -7629,7 +7632,7 @@ time \

    10.6.4. gem5 syscall emulation mode syscall tracing

    -

    Since gem5 has to implement syscalls itself in syscall emulation mode, it can of course clearly see which syscalls are bing made, and we can log them for debug purposes with gem5 tracing, e.g.:

    +

    Since gem5 has to implement syscalls itself in syscall emulation mode, it can of course clearly see which syscalls are being made, and we can log them for debug purposes with gem5 tracing, e.g.:

    @@ -17628,7 +17631,7 @@ getconf _NPROCESSORS_CONF
    -
    18.2.2.1.1. Number of cores in QEMU user mode
    +
    18.2.2.1.1. QEMU user mode multithreading

    TODO why in User mode simulation QEMU always shows the number of cores of the host. E.g., both of the following output the same as nproc on the host:

    @@ -17659,9 +17662,9 @@ ps Haux | grep qemu | wc
    -
    18.2.2.1.2. Number of cores in gem5 user mode
    +
    18.2.2.1.2. gem5 syscall emulation multithreading
    -

    gem5 user mode multi core has been particularly flaky compared to QEMU’s.

    +

    gem5 user mode multithreading has been particularly flaky compared to QEMU’s.

    You have the limitation that you must have at least one core per guest thread, otherwise pthread_create fails. For example:

    @@ -19837,20 +19840,26 @@ clock=500

    Note that the command and it’s corresponding results don’t need to show consecutively on stdout because tests are run in parallel. You just have to match them based on the class name CircleBufTest to the file circlebuf.test.cpp.

    +
    +
    +

    18.14. gem5 regression tests

    -

    Running the larger regression tests is exposed with:

    +

    https://stackoverflow.com/questions/52279971/how-to-run-the-gem5-unit-tests

    +
    +
    +

    Running the larger 2019 regression tests is exposed for example with:

    -
    ./build-gem5 --regression-test quick/fs
    +
    ./gem5-regression --arch aarch64 -- --length quick
    -

    but TODO: those require magic blobs on M5_PATH that we don’t currently automate.

    +

    TODO skip the build by default with --skip-build since we already manage it with ./build-gem5. But we can’t do this because it is the build step that downloads the test binaries. We need to find a way to either download the binaries without building, or to pass the exact same scons build options through test/main.py.

    -

    18.14. gem5 simulate() limit reached

    +

    18.15. gem5 simulate() limit reached

    This error happens when the following instruction limits are reached:

    @@ -19979,18 +19988,18 @@ Exiting @ tick 18446744073709551615 because simulate() limit reached
    -

    18.15. gem5 build options

    +

    18.16. gem5 build options

    In order to use different build options, you might also want to use gem5 build variants to keep the build outputs separate from one another.

    -

    18.15.2. gem5 clang build

    +

    18.16.2. gem5 clang build

    TODO test properly, benchmark vs GCC.

    @@ -20003,7 +20012,7 @@ Exiting @ tick 18446744073709551615 because simulate() limit reached
    -

    18.15.3. gem5 sanitation build

    +

    18.16.3. gem5 sanitation build

    If there gem5 appears to have a C++ undefined behaviour bug, which is often very difficult to track down, you can try to build it with the following extra SCons options:

    @@ -20065,7 +20074,7 @@ Indirect leak of 1346 byte(s) in 2 object(s) allocated from:
    -

    18.15.4. gem5 Ruby build

    +

    18.16.4. gem5 Ruby build

    Ruby is a system that includes the SLICC domain specific language to describe memory systems: http://gem5.org/Ruby

    @@ -20119,7 +20128,7 @@ Indirect leak of 1346 byte(s) in 2 object(s) allocated from:
    -

    18.15.5. gem5 Python 3 build

    +

    18.16.5. gem5 Python 3 build

    Python 3 support was mostly added in 2019 Q3 at arounda347a1a68b8a6e370334be3a1d2d66675891e0f1 but remained buggy for some time afterwards.

    @@ -20137,7 +20146,7 @@ Indirect leak of 1346 byte(s) in 2 object(s) allocated from:
    -

    18.16. gem5 CPU types

    +

    18.17. gem5 CPU types

    gem5 has a few in tree CPU models for different purposes. In fs.py and se.py, those are selectable with the --cpu-type option. Here is an overview of the most interesting ones:

    @@ -20157,7 +20166,7 @@ Indirect leak of 1346 byte(s) in 2 object(s) allocated from:
  • -

    MinorCPU: in-order core. Its 4 stage pipeline is described at the "MinorCPU" section of gem5 ARM RSK.

    +

    MinorCPU: in-order core. The weird name "Minor" stands for "M (TODO what is M) IN ONder". Its 4 stage pipeline is described at the "MinorCPU" section of gem5 ARM RSK. As of 2019, in-order cores are mostly present in low power / cost contexts, for example little cores of ARM bigLITTLE.

    -

    18.16.1. gem5 ARM RSK

    +

    18.17.1. gem5 ARM RSK

    @@ -20182,7 +20191,7 @@ Indirect leak of 1346 byte(s) in 2 object(s) allocated from:
    -

    18.17. gem5 ARM platforms

    +

    18.18. gem5 ARM platforms

    The gem5 platform is selectable with the --machine option, which is named after the analogous QEMU -machine option, and which sets the --machine-type.

    @@ -20210,9 +20219,9 @@ Indirect leak of 1346 byte(s) in 2 object(s) allocated from:
    -

    18.18. gem5 internals

    +

    18.19. gem5 internals

    -

    18.18.1. gem5 Python C++ interaction

    +

    18.19.1. gem5 Python C++ interaction

    The interaction uses the Python C extension interface https://docs.python.org/2/extending/extending.html interface through the pybind11 helper library: https://github.com/pybind/pybind11

    @@ -21028,7 +21037,7 @@ git -C "$(./getvar qemu_source_dir)" checkout - @@ -21044,7 +21053,10 @@ git -C "$(./getvar qemu_source_dir)" checkout -

    userland/c/malloc.c: malloc hello world: allocate two ints and use them.

    -

    LInux 5.1 / glibc 2.29 implements it with the mmap system call.

    +

    Linux 5.1 / glibc 2.29 implements it with the mmap system call.

    +
    +
    +

    malloc leads to the infinite joys of Memory leaks.

    20.1.1.1. malloc implementation
    @@ -21181,9 +21193,32 @@ echo 1 > /proc/sys/vm/overcommit_memory
    -

    20.1.2. GCC C extensions

    +

    20.1.2. C multithreading

    +
    +

    Added in C11!

    +
    +
    + +
    +
    +

    Bibliography:

    +
    + +
    +
    +

    20.1.3. GCC C extensions

    -
    20.1.2.1. C empty struct
    +
    20.1.3.1. C empty struct
    @@ -21195,7 +21230,7 @@ echo 1 > /proc/sys/vm/overcommit_memory
    -
    20.1.2.2. OpenMP
    +
    20.1.3.2. OpenMP

    GCC implements the OpenMP threading implementation: https://stackoverflow.com/questions/3949901/pthreads-vs-openmp

    @@ -21245,16 +21280,6 @@ echo 1 > /proc/sys/vm/overcommit_memory
  • userland/cpp/if_constexpr.cpp: C++17 if constexpr

    -
    - -
  • @@ -21275,6 +21300,12 @@ echo 1 > /proc/sys/vm/overcommit_memory
  • userland/cpp/thread_hardware_concurrency.cpp std::thread::hardware_concurrency

  • +
  • +

    userland/cpp/thread_get_id.cpp std::thread::get_id

    +
  • +
  • +

    userland/cpp/thread_return_value.cpp: how to return a value from a thread

    +
  • @@ -21457,6 +21488,9 @@ echo 1 > /proc/sys/vm/overcommit_memory
    @@ -27815,6 +27866,9 @@ cntv_cval_el0 0xB439642

    and new IRQ number section appears every second, when a clock interrupt is raised!

    +

    TODO make work on gem5. Fails with gem5 simulate() limit reached at the first WFI done in main, which means that the interrupt is never raised.

    +
    +

    Once an interrupt is raised, the interrupt itself sets up a new interrupt to happen in one second in the future after cntv_cval_el0 is reached by the counter.

    @@ -30057,7 +30111,7 @@ git -C "$(./getvar buildroot_source_dir)" checkout -
    -
    ./run --eval-after './sample_package.out'
    +
    ./run --eval-after '/sample_package.out'