distortos  v0.4.0
object-oriented C++ RTOS for microcontrollers

Signals-related synchronization API of distortos. More...

Collaboration diagram for Signals:

Classes

class  distortos::SignalAction
 SignalAction class contains information needed to handle signal that was caught. More...
 
class  distortos::SignalInformation
 SignalInformation class contains information about queued signal. More...
 
class  distortos::SignalSet
 SignalSet class is used as a set of signals. More...
 

Functions

int distortos::DynamicThread::generateSignal (uint8_t signalNumber) override
 Generates signal for thread. More...
 
SignalSet distortos::DynamicThread::getPendingSignalSet () const override
 Gets set of currently pending signals. More...
 
int distortos::DynamicThread::queueSignal (uint8_t signalNumber, sigval value) override
 Queues signal for thread. More...
 
int distortos::ThisThread::Signals::generateSignal (uint8_t signalNumber)
 Generates signal for current thread. More...
 
SignalSet distortos::ThisThread::Signals::getPendingSignalSet ()
 Gets set of currently pending signals for current thread. More...
 
std::pair< int, SignalActiondistortos::ThisThread::Signals::getSignalAction (uint8_t signalNumber)
 Gets SignalAction associated with given signal number. More...
 
SignalSet distortos::ThisThread::Signals::getSignalMask ()
 Gets signal mask for current thread. More...
 
int distortos::ThisThread::Signals::queueSignal (uint8_t signalNumber, sigval value)
 Queues signal for current thread. More...
 
std::pair< int, SignalActiondistortos::ThisThread::Signals::setSignalAction (uint8_t signalNumber, const SignalAction &signalAction)
 Sets association for given signal number. More...
 
int distortos::ThisThread::Signals::setSignalMask (SignalSet signalMask)
 Sets signal mask for current thread. More...
 
std::pair< int, SignalInformationdistortos::ThisThread::Signals::tryWait (const SignalSet &signalSet)
 Tries to accept pending signals. More...
 
std::pair< int, SignalInformationdistortos::ThisThread::Signals::tryWaitFor (const SignalSet &signalSet, TickClock::duration duration)
 Tries to wait for signals for given duration of time. More...
 
template<typename Rep , typename Period >
std::pair< int, SignalInformationdistortos::ThisThread::Signals::tryWaitFor (const SignalSet &signalSet, const std::chrono::duration< Rep, Period > duration)
 Tries to wait for signals for given duration of time. More...
 
std::pair< int, SignalInformationdistortos::ThisThread::Signals::tryWaitUntil (const SignalSet &signalSet, TickClock::time_point timePoint)
 Tries to wait for signals until given time point. More...
 
template<typename Duration >
std::pair< int, SignalInformationdistortos::ThisThread::Signals::tryWaitUntil (const SignalSet &signalSet, const std::chrono::time_point< TickClock, Duration > timePoint)
 Tries to wait for signals until given time point. More...
 
std::pair< int, SignalInformationdistortos::ThisThread::Signals::wait (const SignalSet &signalSet)
 Waits for signals. More...
 
virtual int distortos::Thread::generateSignal (uint8_t signalNumber)=0
 Generates signal for thread. More...
 
virtual SignalSet distortos::Thread::getPendingSignalSet () const =0
 Gets set of currently pending signals. More...
 
virtual int distortos::Thread::queueSignal (uint8_t signalNumber, sigval value)=0
 Queues signal for thread. More...
 
int distortos::ThreadCommon::generateSignal (uint8_t signalNumber) override
 Generates signal for thread. More...
 
SignalSet distortos::ThreadCommon::getPendingSignalSet () const override
 Gets set of currently pending signals. More...
 
int distortos::ThreadCommon::queueSignal (uint8_t signalNumber, sigval value) override
 Queues signal for thread. More...
 

Detailed Description

Signals-related synchronization API of distortos.

Function Documentation

◆ generateSignal() [1/4]

int distortos::ThisThread::Signals::generateSignal ( uint8_t  signalNumber)

Generates signal for current thread.

Similar to raise() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/raise.html

Adds the signalNumber to set of pending signals of current thread.

Warning
This function must not be called from interrupt context!
Parameters
[in]signalNumberis the signal that will be generated, [0; 31]
Returns
0 on success, error code otherwise:
Here is the call graph for this function:
Here is the caller graph for this function:

◆ generateSignal() [2/4]

int distortos::ThreadCommon::generateSignal ( uint8_t  signalNumber)
overridevirtual

Generates signal for thread.

Similar to pthread_kill() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_kill.html

Adds the signalNumber to set of pending signals. If this thread is currently waiting for this signal, it will be unblocked.

Parameters
[in]signalNumberis the signal that will be generated, [0; 31]
Returns
0 on success, error code otherwise:

Implements distortos::Thread.

Here is the call graph for this function:

◆ generateSignal() [3/4]

virtual int distortos::Thread::generateSignal ( uint8_t  signalNumber)
pure virtual

Generates signal for thread.

Similar to pthread_kill() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_kill.html

Adds the signalNumber to set of pending signals. If this thread is currently waiting for this signal, it will be unblocked.

Parameters
[in]signalNumberis the signal that will be generated, [0; 31]
Returns
0 on success, error code otherwise:
  • EINVAL - signalNumber value is invalid;
  • ENOTSUP - reception of signals is disabled for this thread;

Implemented in distortos::DynamicThread, and distortos::ThreadCommon.

Here is the caller graph for this function:

◆ generateSignal() [4/4]

int distortos::DynamicThread::generateSignal ( uint8_t  signalNumber)
overridevirtual

Generates signal for thread.

Similar to pthread_kill() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_kill.html

Adds the signalNumber to set of pending signals. If this thread is currently waiting for this signal, it will be unblocked.

Parameters
[in]signalNumberis the signal that will be generated, [0; 31]
Returns
0 on success, error code otherwise:

Implements distortos::Thread.

◆ getPendingSignalSet() [1/4]

SignalSet distortos::ThisThread::Signals::getPendingSignalSet ( )

Gets set of currently pending signals for current thread.

Similar to sigpending() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/sigpending.html

This function shall return the set of signals that are blocked from delivery and are pending on the current thread.

Warning
This function must not be called from interrupt context!
Returns
set of currently pending signals for current thread
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getPendingSignalSet() [2/4]

SignalSet distortos::ThreadCommon::getPendingSignalSet ( ) const
overridevirtual

Gets set of currently pending signals.

Similar to sigpending() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/sigpending.html

This function shall return the set of signals that are blocked from delivery and are pending on the thread.

Returns
set of currently pending signals

Implements distortos::Thread.

Here is the call graph for this function:

◆ getPendingSignalSet() [3/4]

virtual SignalSet distortos::Thread::getPendingSignalSet ( ) const
pure virtual

Gets set of currently pending signals.

Similar to sigpending() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/sigpending.html

This function shall return the set of signals that are blocked from delivery and are pending on the thread.

Returns
set of currently pending signals

Implemented in distortos::DynamicThread, and distortos::ThreadCommon.

Here is the caller graph for this function:

◆ getPendingSignalSet() [4/4]

SignalSet distortos::DynamicThread::getPendingSignalSet ( ) const
overridevirtual

Gets set of currently pending signals.

Similar to sigpending() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/sigpending.html

This function shall return the set of signals that are blocked from delivery and are pending on the thread.

Returns
set of currently pending signals

Implements distortos::Thread.

◆ getSignalAction()

std::pair< int, SignalAction > distortos::ThisThread::Signals::getSignalAction ( uint8_t  signalNumber)

Gets SignalAction associated with given signal number.

Similar to sigaction() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/sigaction.html

Warning
This function must not be called from interrupt context!
Parameters
[in]signalNumberis the signal for which the association is requested, [0; 31]
Returns
pair with return code (0 on success, error code otherwise) and SignalAction that is associated with signalNumber, default-constructed object if no association was found; error codes:
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getSignalMask()

SignalSet distortos::ThisThread::Signals::getSignalMask ( )

Gets signal mask for current thread.

Similar to pthread_sigmask() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_sigmask.html#

Warning
This function must not be called from interrupt context!
Returns
SignalSet with signal mask for current thread
Here is the call graph for this function:
Here is the caller graph for this function:

◆ queueSignal() [1/4]

int distortos::ThisThread::Signals::queueSignal ( uint8_t  signalNumber,
sigval  value 
)

Queues signal for current thread.

Similar to sigqueue() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/sigqueue.html

Adds the signalNumber and signal value (sigval union) to queue of SignalInformation objects.

Warning
This function must not be called from interrupt context!
Parameters
[in]signalNumberis the signal that will be queued, [0; 31]
[in]valueis the signal value
Returns
0 on success, error code otherwise:
Here is the call graph for this function:
Here is the caller graph for this function:

◆ queueSignal() [2/4]

int distortos::ThreadCommon::queueSignal ( uint8_t  signalNumber,
sigval  value 
)
overridevirtual

Queues signal for thread.

Similar to sigqueue() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/sigqueue.html

Adds the signalNumber and signal value (sigval union) to queue of SignalInformation objects. If this thread is currently waiting for this signal, it will be unblocked.

Parameters
[in]signalNumberis the signal that will be queued, [0; 31]
[in]valueis the signal value
Returns
0 on success, error code otherwise:

Implements distortos::Thread.

Here is the call graph for this function:

◆ queueSignal() [3/4]

virtual int distortos::Thread::queueSignal ( uint8_t  signalNumber,
sigval  value 
)
pure virtual

Queues signal for thread.

Similar to sigqueue() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/sigqueue.html

Adds the signalNumber and signal value (sigval union) to queue of SignalInformation objects. If this thread is currently waiting for this signal, it will be unblocked.

Parameters
[in]signalNumberis the signal that will be queued, [0; 31]
[in]valueis the signal value
Returns
0 on success, error code otherwise:
  • EAGAIN - no resources are available to queue the signal, maximal number of signals is already queued in associated queue of SignalInformation objects;
  • EINVAL - signalNumber value is invalid;
  • ENOTSUP - reception or queuing of signals are disabled for this thread;

Implemented in distortos::DynamicThread, and distortos::ThreadCommon.

Here is the caller graph for this function:

◆ queueSignal() [4/4]

int distortos::DynamicThread::queueSignal ( uint8_t  signalNumber,
sigval  value 
)
overridevirtual

Queues signal for thread.

Similar to sigqueue() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/sigqueue.html

Adds the signalNumber and signal value (sigval union) to queue of SignalInformation objects. If this thread is currently waiting for this signal, it will be unblocked.

Parameters
[in]signalNumberis the signal that will be queued, [0; 31]
[in]valueis the signal value
Returns
0 on success, error code otherwise:

Implements distortos::Thread.

◆ setSignalAction()

std::pair< int, SignalAction > distortos::ThisThread::Signals::setSignalAction ( uint8_t  signalNumber,
const SignalAction signalAction 
)

Sets association for given signal number.

Similar to sigaction() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/sigaction.html

Warning
This function must not be called from interrupt context!
Parameters
[in]signalNumberis the signal for which the association will be set, [0; 31]
[in]signalActionis a reference to SignalAction that will be associated with given signal number, object in internal storage is copy-constructed
Returns
pair with return code (0 on success, error code otherwise) and SignalAction that was associated with signalNumber, default-constructed object if no association was found; error codes:
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setSignalMask()

int distortos::ThisThread::Signals::setSignalMask ( SignalSet  signalMask)

Sets signal mask for current thread.

Similar to pthread_sigmask() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_sigmask.html#

Warning
This function must not be called from interrupt context!
Parameters
[in]signalMaskis the SignalSet with new signal mask for current thread
Returns
0 on success, error code otherwise:
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tryWait()

std::pair< int, SignalInformation > distortos::ThisThread::Signals::tryWait ( const SignalSet signalSet)

Tries to accept pending signals.

Similar to sigtimedwait() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/sigtimedwait.html

This function shall select the lowest pending signal from provided set, atomically clear it from current thread's set of pending signals and return that signal number. If no signal in provided set is pending at the time of the call, then this function shall return immediately with an error.

Warning
This function must not be called from interrupt context!
Parameters
[in]signalSetis a reference to set of signals that may be accepted
Returns
pair with return code (0 on success, error code otherwise) and SignalInformation object for accepted signal; error codes:
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tryWaitFor() [1/2]

std::pair< int, SignalInformation > distortos::ThisThread::Signals::tryWaitFor ( const SignalSet signalSet,
TickClock::duration  duration 
)

Tries to wait for signals for given duration of time.

Similar to sigtimedwait() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/sigtimedwait.html

This function shall select the lowest pending signal from provided set, atomically clear it from current thread's set of pending signals and return that signal number. If no signal in provided set is pending at the time of the call, the thread shall be suspended until one or more becomes pending or until given duration of time expires.

Warning
This function must not be called from interrupt context!
Parameters
[in]signalSetis a reference to set of signals that will be waited for
[in]durationis the duration after which the wait for signals will be terminated
Returns
pair with return code (0 on success, error code otherwise) and SignalInformation object for accepted signal; error codes:
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tryWaitFor() [2/2]

template<typename Rep , typename Period >
std::pair<int, SignalInformation> distortos::ThisThread::Signals::tryWaitFor ( const SignalSet signalSet,
const std::chrono::duration< Rep, Period >  duration 
)

Tries to wait for signals for given duration of time.

Template variant of tryWaitFor(const SignalSet&, TickClock::duration).

Warning
This function must not be called from interrupt context!
Template Parameters
Repis type of tick counter
Periodis std::ratio type representing the tick period of the clock, seconds
Parameters
[in]signalSetis a reference to set of signals that will be waited for
[in]durationis the duration after which the wait for signals will be terminated
Returns
pair with return code (0 on success, error code otherwise) and SignalInformation object for accepted signal; error codes:
Here is the call graph for this function:

◆ tryWaitUntil() [1/2]

std::pair< int, SignalInformation > distortos::ThisThread::Signals::tryWaitUntil ( const SignalSet signalSet,
TickClock::time_point  timePoint 
)

Tries to wait for signals until given time point.

Similar to sigtimedwait() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/sigtimedwait.html

This function shall select the lowest pending signal from provided set, atomically clear it from current thread's set of pending signals and return that signal number. If no signal in provided set is pending at the time of the call, the thread shall be suspended until one or more becomes pending or until given time point is reached

Warning
This function must not be called from interrupt context!
Parameters
[in]signalSetis a reference to set of signals that will be waited for
[in]timePointis the time point at which the wait for signals will be terminated
Returns
pair with return code (0 on success, error code otherwise) and SignalInformation object for accepted signal; error codes:
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tryWaitUntil() [2/2]

template<typename Duration >
std::pair<int, SignalInformation> distortos::ThisThread::Signals::tryWaitUntil ( const SignalSet signalSet,
const std::chrono::time_point< TickClock, Duration >  timePoint 
)

Tries to wait for signals until given time point.

Template variant of tryWaitUntil(const SignalSet&, TickClock::time_point).

Warning
This function must not be called from interrupt context!
Template Parameters
Durationis a std::chrono::duration type used to measure duration
Parameters
[in]signalSetis a reference to set of signals that will be waited for
[in]timePointis the time point at which the wait for signals will be terminated
Returns
pair with return code (0 on success, error code otherwise) and SignalInformation object for accepted signal; error codes:
Here is the call graph for this function:

◆ wait()

std::pair< int, SignalInformation > distortos::ThisThread::Signals::wait ( const SignalSet signalSet)

Waits for signals.

Similar to sigwait() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/sigwait.html

This function shall select the lowest pending signal from provided set, atomically clear it from current thread's set of pending signals and return that signal number. If no signal in provided set is pending at the time of the call, the thread shall be suspended until one or more becomes pending.

Warning
This function must not be called from interrupt context!
Parameters
[in]signalSetis a reference to set of signals that will be waited for
Returns
pair with return code (0 on success, error code otherwise) and SignalInformation object for accepted signal; error codes:
Here is the call graph for this function:
Here is the caller graph for this function: