NAME
mthr_suspend - suspend a thread's execution

mthr_resume - resume a thread's execution

SYNOPSIS
#include <mthread.h>

int mthr_suspend(mthread_p tp, int wait);

void mthr_resume(mthread_p tp);

DESCRIPTION
mthr_suspend() suspends the thread specified by tp.

If tp is equal to the calling thread's handle, the calling thread is suspended and another thread will be scheduled.

If tp specifies another thread and this thread isn't currently running, it is suspended and the call returns. If the thread is running on another processor the behaviour of mthr_suspend() depends on the value of wait. If wait is null, the requested thread will be marked for suspension. When it triggers a new scheduling decision for its processor it will be suspended. If wait has a value that's not null, the calling thread will be blocked until the suspension has actually occured.

Calls to mthr_suspend() accumulate, i.e. each call to mthr_suspend() needs a corresponding call to mthr_resume() to resume the thread and vice versa. If mthr_resume() has been called before mthr_suspend(), no suspension will happen but mthr_suspend() will return.

mthr_resume will resume a thread's execution if there have been less calls to mthr_suspend() than calls to mthr_resume(). Calls to mthr_resume() also accumulate.

RETURN VALUES
Upon successful completion, mthr_suspend returns with a value of 0. Otherwise, a value of -1 is returned and merrno is set to indicate the error.

ERRORS
mthr_suspend fails if the following is true:

SEE ALSO
mthreads(3), mthr_exit(3)