Threads endpoint

August 2, 2023

ID kernel_methods_threads

This endpoint is intended for managing threads.

Information about methods of the endpoint is provided in the table below.

Methods of the thread.Thread endpoint (kl.core.Thread interface)

Method

Method purpose and parameters

Potential danger of the method

Create

Purpose

Creates a thread.

Parameters

  • [out] tid – thread ID (TID).
  • [in] priority – value defining the thread priority.
  • [in] stackSize – size of the stack for the thread, or 0 for the default size.
  • [in] routine – pointer to the function that will be executed when creating the thread.
  • [in] context – pointer to the function that will be executed in the thread context.
  • [in] context2 – pointer to the parameters that will be passed to the function defined through the context parameter.
  • [in] flags – flags defining the parameters for creating the thread.
  • [out] rc – return code.

Allows the following:

  • Create a real-time thread that takes up all the CPU time from other threads, including from other processes (it is recommended to monitor thread creation parameters).
  • Create a multitude of threads (including with high priority) to reduce the CPU time available to the threads of other processes (it is recommended to monitor thread priority).
  • Exhaust the RAM.
  • Exhaust the kernel memory by creating a multitude of objects within it.

Suspend

Purpose

Blocks a thread.

Parameters

  • [in] tid – thread ID (TID).
  • [out] rc – return code.

Lets you lock a standard thread that has captured the synchronization entity expected by the real-time thread in whose context the interrupt is being handled. This could stop the handling of this interrupt by other processes.

Resume

Purpose

Resumes a thread.

Parameters

  • [in] tid – thread ID (TID).
  • [out] rc – return code.

N/A

Terminate

Purpose

Terminates a thread.

Parameters

  • [in] tid – thread ID (TID).
  • [in] zombie – fictitious parameter.
  • [in] code – thread exit code.
  • [out] rc – return code.

N/A

Exit

Purpose

Terminates the current thread.

Parameters

  • [in] zombie – fictitious parameter.
  • [in] code – thread exit code.
  • [out] rc – return code.

N/A

Wait

Purpose

Locks the current thread until the defined thread is terminated.

Parameters

  • [in] tid – thread ID (TID).
  • [in] msec – thread termination timeout (in milliseconds).
  • [out] code – thread exit code.
  • [out] rc – return code.

N/A

SetPriority

Purpose

Defines the priority of a thread.

Parameters

  • [in] tid – thread ID (TID).
  • [in] priority – value defining the thread priority.
  • [out] rc – return code.

Allows the priority of a thread to be elevated to reduce the CPU time available to all other threads, including from other processes.

It is recommended to monitor thread priority.

GetTcb

Purpose

Allows access to the local memory of the current thread (TLS of the current thread).

Parameters

  • [out] va – pointer to the local memory of the current thread.
  • [out] rc – return code.

N/A

SetTls

Purpose

Defines the base address of the local memory of the current thread (TLS of the current thread).

Parameters

  • [in] va – pointer to the local memory of the current thread.
  • [out] rc – return code.

N/A

Sleep

Purpose

Locks the current thread for the specified duration.

Parameters

  • [in] mdelay – thread lockout duration (in milliseconds).
  • [out] rc – return code.

N/A

GetInfo

Purpose

Lets you get information about a thread.

Parameters

  • [in] tid – thread ID (TID).
  • [out] info – structure containing information about the thread.
  • [out] rc – return code.

N/A

DetachIrq

Purpose

Detaches the current thread from the interrupt handled in its context.

Parameters

  • [out] rc – return code.

N/A

GetAffinity

Purpose

Lets you get a thread affinity mask.

Parameters

  • [in] tid – thread ID (TID).
  • [out] mask – thread affinity mask.
  • [out] rc – return code.

N/A

SetAffinity

Purpose

Defines a thread affinity mask.

Parameters

  • [in] tid – thread ID (TID).
  • [in] mask – thread affinity mask.
  • [out] rc – return code.

N/A

SetSchedPolicy

Purpose

Defines the thread scheduler class.

Parameters

  • [in] tid – thread ID (TID).
  • [in] policy – value defining the thread scheduler class.
  • [in] priority – value defining the thread priority.
  • [in] param – union containing parameters of a thread scheduler class.
  • [out] rc – return code.

Allows the following:

  • Convert a thread into a real-time thread that takes up all the CPU time from all other threads, including from other processes (it is recommended to monitor the thread scheduler class).
  • Elevate the priority of a thread to reduce the CPU time available to all other threads, including from other processes (it is recommended to monitor thread priority).

GetSchedPolicy

Purpose

Lets you get information about the thread scheduler class.

Parameters

  • [in] tid – thread ID (TID).
  • [out] policy – value indicating the thread scheduler class.
  • [out] priority – value indicating the thread priority.
  • [out] param – union containing parameters of a thread scheduler class.
  • [out] rc – return code.

N/A

Did you find this article helpful?
What can we do better?
Thank you for your feedback! You're helping us improve.
Thank you for your feedback! You're helping us improve.