Kernel Multithreading Modes

The kernel multithreading mode controls the thread-safety of the kernel objects and defines which kernel operations will be paralleled.

The kernel multithreading mode is defined as the MbeMultithreadedMode enumeration in the tool_multithreading.h file.

The kernel can work in the following modes:

  • mtm_Off – the kernel multithreading is off. In this mode all operations are executed sequentially. The mechanism providing the kernel objects thread-safety is switched off.

  • mtm_Standard – in the standard multithreading mode the limited operations are paralleled, namely only operations that process independent data. The mechanism providing the kernel objects thread-safety is switched off.

  • mtm_SafeItems – the objects thread-safety mode. In this mode the mechanism of multithreaded caches is switched on, but still only limited operations are paralleled. This mode is used to support multithreaded operations in user applications.

  • mtm_Items – the objects multithreading mode. In this mode the full multithreading of the kernel operations is on. The kernel operations that process both independent and dependent data are paralleled. This mode also can be used to support multithreaded operations in user applications.

  • mtm_Max – the maximal kernel multithreading is on. Currently this mode is equal to the mtm_Items mode.

By default the kernel works in the mtm_Max mode.

The kernel provides interfaces for dynamic switching of the multithreading mode.

The interfaces for switching the kernel multithreading mode are declared in the mb_variables.h file.

The following static methods of the Math class can be used for switching the kernel multithreading mode:

  • bool Multithreaded() – checks if the mtm_Standard mode is used (whether multithreading is on).

  • void SetMultithreaded( bool b ) – if b == false, disables multithreading (sets the mode to mtm_Off). If b == true, enables limited multithreading (sets the mode to mtm_Standard).

  • MbeMultithreadedMode MultithreadedMode() – returns the current multithreading mode.

  • bool CheckMultithreadedMode( MbeMultithreadedMode mode ) – checks if the current mode implies the specified mode (is not lower than the specified mode).

  • void SetMultithreadedMode( MbeMultithreadedMode mode ) – sets the specified multithreading mode.