thr_suspend

Suspends the execution of a specified thread and returns when the target thread is suspended.

Library:LibC
Classification:UNIX International
Service:Threads

Syntax

  #include <thread.h>
   
  int thr_suspend (
     thread_t   thr);
  

Parameters

thr

(IN) Specifies the ID of the thread to suspend.

Return Values

If successful, returns 0; otherwise, returns a nonzero error code:

Decimal

Constant

Description

15

EDEADLK

Target thread is the calling thread.

77

ESRCH

The specified thread ID is invalid.

78

ECANCELED

A subsequent continue occurred before the suspend completed.

Remarks

The thread that calls thr_suspend blocks until the suspension is granted, which might not be immediately. For example:

  • A thread can disable suspension, which stays in effect until the thread enables suspension.

  • If a thread has acquired a lock, LibC prohibits suspension until the lock is released.

Calling thr_suspend on a thread that is already suspended has no effect.

A suspended thread can be resumed by calling thr_continue.

IMPORTANT:A thread cannot suspend itself.

See Also