@@ -206,6 +206,20 @@ void *rt_signal_check(void* context)
206206}
207207#endif /* RT_USING_SMP */
208208
209+ /**
210+ * @brief This function will install a processing function to a specific
211+ * signal and return the old processing function of this signal.
212+ *
213+ * @note This function needs to be used in conjunction with the
214+ * rt_signal_unmask() function to make the signal effective.
215+ *
216+ * @see rt_signal_unmask()
217+ *
218+ * @param signo is a specific signal value (range: 0 ~ RT_SIG_MAX).
219+ *
220+ * @return Return the old processing function of this signal. ONLY When the
221+ * return value is SIG_ERR, the operation is failed.
222+ */
209223rt_sighandler_t rt_signal_install (int signo , rt_sighandler_t handler )
210224{
211225 rt_base_t level ;
@@ -233,6 +247,17 @@ rt_sighandler_t rt_signal_install(int signo, rt_sighandler_t handler)
233247 return old ;
234248}
235249
250+ /**
251+ * @brief This function will block the specified signal.
252+ *
253+ * @note This function will block the specified signal, even if the
254+ * rt_thread_kill() function is called to send this signal to
255+ * the current thread, it will no longer take effect.
256+ *
257+ * @see rt_thread_kill()
258+ *
259+ * @param signo is a specific signal value (range: 0 ~ RT_SIG_MAX).
260+ */
236261void rt_signal_mask (int signo )
237262{
238263 rt_base_t level ;
@@ -245,6 +270,17 @@ void rt_signal_mask(int signo)
245270 rt_hw_interrupt_enable (level );
246271}
247272
273+ /**
274+ * @brief This function will unblock the specified signal.
275+ *
276+ * @note This function will unblock the specified signal. After calling
277+ * the rt_thread_kill() function to send this signal to the current
278+ * thread, it will take effect.
279+ *
280+ * @see rt_thread_kill()
281+ *
282+ * @param signo is a specific signal value (range: 0 ~ RT_SIG_MAX).
283+ */
248284void rt_signal_unmask (int signo )
249285{
250286 rt_base_t level ;
@@ -266,6 +302,20 @@ void rt_signal_unmask(int signo)
266302 }
267303}
268304
305+ /**
306+ * @brief This function will wait for the arrival of the set signal. If it does not wait for this signal, the thread will be
307+ * suspended until it waits for this signal or the waiting time exceeds the specified timeout: timeout.
308+ *
309+ * @param set is the set of signal values to be waited for. Use the function
310+ * sigaddset() to add the signal.
311+ *
312+ * @param si is a pointer to the received signal info. If you don't care about this value, you can use RT_NULL to set.
313+ *
314+ * @param timeout is a timeout period (unit: an OS tick).
315+ *
316+ * @return Return the operation status. When the return value is RT_EOK, the operation is successful.
317+ * If the return value is any other values, it means that the signal wait failed.
318+ */
269319int rt_signal_wait (const rt_sigset_t * set , rt_siginfo_t * si , rt_int32_t timeout )
270320{
271321 int ret = RT_EOK ;
@@ -497,6 +547,16 @@ void rt_thread_free_sig(rt_thread_t tid)
497547 }
498548}
499549
550+ /**
551+ * @brief This function can be used to send any signal to any thread.
552+ *
553+ * @param tid is a pointer to the thread that receives the signal.
554+ *
555+ * @param sig is a specific signal value (range: 0 ~ RT_SIG_MAX).
556+ *
557+ * @return Return the operation status. When the return value is RT_EOK, the operation is successful.
558+ * If the return value is any other values, it means that the signal send failed.
559+ */
500560int rt_thread_kill (rt_thread_t tid , int sig )
501561{
502562 siginfo_t si ;
0 commit comments