INtime SDK Help
DeleteRtThread
INtime SDK v6 > About INtime > INtime Kernel > Threads > DeleteRtThread

Deletes a thread referenced by the given handle.

BOOLEAN DeleteRtThread(
    RTHANDLE hThread    // handle for RT thread
);

Parameters

hThread
A handle for the thread you want to delete. To delete the calling thread, use the value NULL_RTHANDLE.

Remarks

If a thread deletes itself by calling this function and the containing process makes reference to any RSLs, the entry point of each RSL is called with a reason code of RSL_THREAD_DETACH in the context of the thread being deleted.

DeleteRtThread enables any thread currently within a region or waiting in a queue for a region to exit the region before being deleted. Deleting the thread counts toward both the object and thread limits for the containing process.

Any attempt to delete an interrupt thread results in an E_CONTEXT status code. Use ResetRtInterruptHandler instead.

Note: Normally, when a thread runs to completion, it executes the user code associated with RslMain() and RSL_THREAD_DETACH. Deleting another thread may result in that thread leaking resources. This is because the thread does not have a chance to execute its exit handlers. The leaked resources may be those allocated explicitly by the thread or by system code on behalf of the thread. A thread that deletes itself by calling DeleteRtThread does call RslMain().  If a thread returns from the initial thread function then it calls RslMain()  and deletes itself.

Return Values

TRUE
Success.
FALSE
Failure. To determine the status, call GetLastRtError.

Status

E_OK 0x0000
No exceptional conditions occurred.
E_CONTEXT 0x0005
hThread specifies an RT handle for an interrupt thread.
E_EXIST 0x0006
One of these conditions exist:
  • You used an invalid value for hThread.
  • hThread is an RT handle for a thread whose process is being deleted.
  • More than one thread tried to delete a thread in a region.
E_TYPE 0x8002
hThread requires an RT handle for a thread.

Requirements

Versions Defined in Include Link to
INtime 3.0 intime/rt/include/rtbase.h rt.h rt.lib
See Also