Benchmarks Documentation Examples Repository Blog Contact

Signals

Threads can send signals asynchronously to each other. Kernel provides mechanism to register signal handler, which gets executed whenever thread receives a signal. There are two kinds of signals:

  • catchable - kernel supports sending of 32 distinct catchable signals. Kernel doesn’t interpret any of them in any way. If such signal is sent to the thread then thread is simply notified of its arrival.
  • non-catchable - these signals are mostly system-defined and thread is not able to catch nor react to them. These include stopping and resuming thread, killing it and signalling memory protection violation error. catchable - kernel supports sending of 32 distinct catchable signals. Kernel doesn’t interpret any of them in any way. If such signal is sent to the thread then thread is simply notified of its arrival.non-catchable - these signals are mostly system-defined and thread is not able to catch nor react to them. These include stopping and resuming thread, killing it and signalling memory protection violation error.

If thread doesn’t register any signal handler, then signal arrival is effectively a no-op for given thread. In any case, arrival of signal will wake thread up, if it is stopped.

Function-like Macros

SIGALRM

SIGKILL

SIGSTOP

SIGCONT

SIGSEGV

int signal(int signo, void(*sighandler)(uint32_t))

  • signo number of signal
  • sighandler address of function which handles the signal

Returns 0. Mostly.

int kill(int thread, uint32_t signal)

Send a signal to the thread.

thread recipient thread id

signal signal number 0. Mostly.

  • thread recipient thread id
  • signal signal number

Returns 0. Mostly.

64kB of protected memory ought to be enough for everyone.