Skip to main content

IAR Embedded Workbench for RISC-V 3.40

Enabling multithread support

In this section:
To configure multithread support for use with threaded applications:
  1. To enable multithread support:

    Danger

    On the command line, use the linker option ‑‑threaded_lib.

    If C++ is used, the compiler option ‑‑guard_calls should be used as well to make sure that function-static variables with dynamic initializers are not initialized simultaneously by several threads.

    Caution

    In the IDE, choose Project>Options>General Options>Library Configuration>Enable thread support in the library. This will invoke the linker option ‑‑threaded_lib and if C++ is used, the IDE will automatically use the compiler option ‑‑guard_calls to make sure that function-static variables with dynamic initializers are not initialized simultaneously by several threads.

  2. To complement the built-in multithread support in the runtime library, you must also:

    • Implement code for the library’s system locks interface.

    • If file streams are used, implement code for the library’s file stream locks interface.

    • Implement code that handles thread creation, thread destruction, and TLS access methods for the library.

    You can find the required declaration of functions in the DLib_Threads.h file. There you will also find more information.

  3. Build your project.

    Note

    If you are using a third-party RTOS, check their guidelines for how to enable multithread support with IAR tools.