AllocSignal

Allocates signals.

Synopsis

int32 AllocSignal( uint32 sigMask )

Description

One of the ways tasks communicate is by sending signals to each other. Signals are 1-bit flags that indicate that a particular event has occurred.

Tasks that send and receive signals must agree on which signal bits to use and the meanings of the signals. Except for system signals, there are no conventions for the meanings of individual signal bits; it is up to software developers to define their meanings.

You allocate bits for new signals by calling AllocSignal(). To define one signal at a time - by far the most common case - call AllocSignal() with 0 as the argument:

theSignal = AllocSignal( 0 )

This allocates the next unused bit in the signal word. In the return value, the bit that was allocated is set. If the allocation fails (which happens if all the non-reserved bits in the signal word are already allocated), the procedure returns 0.

In rare cases, you may need to define more than one signal with a single call. You do this by creating a uint32 value and setting any bits you want to allocate for new signals, then calling AllocSignal() with this value as the argument. If all the signals are successfully allocated, the bits set in the return value are the same as the bits that were set in the argument.

Signals are implemented as follows:

The following system signals are currently defined:

SIGF_ABORT
Informs the task that the current operation has been aborted.
SIGF_IODONE
Informs the task that an asynchronous I/O request is complete.
SIGF_DEADTASK
Informs the task that one of its child tasks or threads has been deleted. Note: This signal does not specify which task was deleted. To find this out, the parent task must check to see which of its child tasks still exist.
SIGF_SEMAPHORE
Informs a task waiting to lock a semaphore that it can do so. Note: This signal is for system internal use only.

Arguments

signalMask
An uint32 value in which the bits to be allocated are set, or 0 to allocate the next available bit. You should use 0 whenever possible (see Notes).

Return Value

The procedure returns a int32 value with bits set for any bits that were allocated or 0 if not all of the requested bits could be allocated. It returns ILLEGALSIGNAL if the signalMask specified a reserved signal.

Implementation

SWI implemented in kernel folio V20.

Associated Files

task.h
ARM C Prototype

Notes

Use FreeSignal() to deallocate signals.

Future versions of Portfolio may define additional system signals. To help ensure that the signal bits you allocate in current applications do not conflict with future system signals, you should always use 0 as the value of the signalMask argument when allocating signals. If you must allocate specific signal bits (which is discouraged), use bits 17-31.

See Also

FreeSignal(), GetCurrentSignals(), SendSignal(), WaitSignal()