signal.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2017/10/5 Bernard the first version
  9. * 2018/09/17 Jesven fix: in _signal_deliver RT_THREAD_STAT_MASK to RT_THREAD_STAT_SIGNAL_MASK
  10. * 2018/11/22 Jesven in smp version rt_hw_context_switch_to add a param
  11. */
  12. #include <stdint.h>
  13. #include <string.h>
  14. #include <rthw.h>
  15. #include <rtthread.h>
  16. #ifdef RT_USING_SIGNALS
  17. #ifndef RT_SIG_INFO_MAX
  18. #ifdef ARCH_CPU_64BIT
  19. #define RT_SIG_INFO_MAX 64
  20. #else
  21. #define RT_SIG_INFO_MAX 32
  22. #endif /* ARCH_CPU_64BIT */
  23. #endif /* RT_SIG_INFO_MAX */
  24. #define DBG_TAG "SIGN"
  25. #define DBG_LVL DBG_WARNING
  26. #include <rtdbg.h>
  27. #ifdef RT_USING_MUSLLIBC
  28. #define sig_mask(sig_no) (1u << (sig_no - 1))
  29. #else
  30. #define sig_mask(sig_no) (1u << sig_no)
  31. #endif
  32. #define sig_valid(sig_no) (sig_no >= 0 && sig_no < RT_SIG_MAX)
  33. static struct rt_spinlock _thread_signal_lock = RT_SPINLOCK_INIT;
  34. struct siginfo_node
  35. {
  36. siginfo_t si;
  37. struct rt_slist_node list;
  38. };
  39. static struct rt_mempool *_siginfo_pool;
  40. static void _signal_deliver(rt_thread_t tid);
  41. void rt_thread_handle_sig(rt_bool_t clean_state);
  42. static void _signal_default_handler(int signo)
  43. {
  44. RT_UNUSED(signo);
  45. LOG_I("handled signo[%d] with default action.", signo);
  46. return ;
  47. }
  48. static void _signal_entry(void *parameter)
  49. {
  50. RT_UNUSED(parameter);
  51. rt_thread_t tid = rt_thread_self();
  52. /* handle signal */
  53. rt_thread_handle_sig(RT_FALSE);
  54. #ifdef RT_USING_SMP
  55. #else
  56. /* return to thread */
  57. tid->sp = tid->sig_ret;
  58. tid->sig_ret = RT_NULL;
  59. #endif /* RT_USING_SMP */
  60. LOG_D("switch back to: 0x%08x\n", tid->sp);
  61. RT_SCHED_CTX(tid).stat &= ~RT_THREAD_STAT_SIGNAL;
  62. #ifdef RT_USING_SMP
  63. rt_hw_context_switch_to((rt_uintptr_t)&parameter, tid);
  64. #else
  65. rt_hw_context_switch_to((rt_uintptr_t)&(tid->sp));
  66. #endif /* RT_USING_SMP */
  67. }
  68. /*
  69. * To deliver a signal to thread, there are cases:
  70. * 1. When thread is suspended, function resumes thread and
  71. * set signal stat;
  72. * 2. When thread is ready:
  73. * - If function delivers a signal to self thread, just handle
  74. * it.
  75. * - If function delivers a signal to another ready thread, OS
  76. * should build a slice context to handle it.
  77. */
  78. static void _signal_deliver(rt_thread_t tid)
  79. {
  80. rt_base_t level;
  81. level = rt_spin_lock_irqsave(&_thread_signal_lock);
  82. /* thread is not interested in pended signals */
  83. if (!(tid->sig_pending & tid->sig_mask))
  84. {
  85. rt_spin_unlock_irqrestore(&_thread_signal_lock, level);
  86. return;
  87. }
  88. if ((RT_SCHED_CTX(tid).stat & RT_THREAD_SUSPEND_MASK) == RT_THREAD_SUSPEND_MASK)
  89. {
  90. /* resume thread to handle signal */
  91. #ifdef RT_USING_SMART
  92. rt_thread_wakeup(tid);
  93. #else
  94. rt_thread_resume(tid);
  95. #endif
  96. /* add signal state */
  97. RT_SCHED_CTX(tid).stat |= (RT_THREAD_STAT_SIGNAL | RT_THREAD_STAT_SIGNAL_PENDING);
  98. rt_spin_unlock_irqrestore(&_thread_signal_lock, level);
  99. /* re-schedule */
  100. rt_schedule();
  101. }
  102. else
  103. {
  104. if (tid == rt_thread_self())
  105. {
  106. /* add signal state */
  107. RT_SCHED_CTX(tid).stat |= RT_THREAD_STAT_SIGNAL;
  108. rt_spin_unlock_irqrestore(&_thread_signal_lock, level);
  109. /* do signal action in self thread context */
  110. if (rt_interrupt_get_nest() == 0)
  111. {
  112. rt_thread_handle_sig(RT_TRUE);
  113. }
  114. }
  115. else if (!((RT_SCHED_CTX(tid).stat & RT_THREAD_STAT_SIGNAL_MASK) & RT_THREAD_STAT_SIGNAL))
  116. {
  117. /* add signal state */
  118. RT_SCHED_CTX(tid).stat |= (RT_THREAD_STAT_SIGNAL | RT_THREAD_STAT_SIGNAL_PENDING);
  119. #ifdef RT_USING_SMP
  120. {
  121. int cpu_id;
  122. cpu_id = RT_SCHED_CTX(tid).oncpu;
  123. if ((cpu_id != RT_CPU_DETACHED) && (cpu_id != rt_cpu_get_id()))
  124. {
  125. rt_uint32_t cpu_mask;
  126. cpu_mask = RT_CPU_MASK ^ (1 << cpu_id);
  127. rt_hw_ipi_send(RT_SCHEDULE_IPI, cpu_mask);
  128. }
  129. }
  130. #else
  131. /* point to the signal handle entry */
  132. RT_SCHED_CTX(tid).stat &= ~RT_THREAD_STAT_SIGNAL_PENDING;
  133. tid->sig_ret = tid->sp;
  134. tid->sp = rt_hw_stack_init((void *)_signal_entry, RT_NULL,
  135. (void *)((char *)tid->sig_ret - 32), RT_NULL);
  136. #endif /* RT_USING_SMP */
  137. rt_spin_unlock_irqrestore(&_thread_signal_lock, level);
  138. LOG_D("signal stack pointer @ 0x%08x", tid->sp);
  139. /* re-schedule */
  140. rt_schedule();
  141. }
  142. else
  143. {
  144. rt_spin_unlock_irqrestore(&_thread_signal_lock, level);
  145. }
  146. }
  147. }
  148. #ifdef RT_USING_SMP
  149. void *rt_signal_check(void* context)
  150. {
  151. rt_sched_lock_level_t level;
  152. int cpu_id;
  153. struct rt_cpu* pcpu;
  154. struct rt_thread *current_thread;
  155. level = rt_spin_lock_irqsave(&_thread_signal_lock);
  156. cpu_id = rt_cpu_get_id();
  157. pcpu = rt_cpu_index(cpu_id);
  158. current_thread = pcpu->current_thread;
  159. if (pcpu->irq_nest)
  160. {
  161. rt_spin_unlock_irqrestore(&_thread_signal_lock, level);
  162. return context;
  163. }
  164. if (current_thread->cpus_lock_nest == 1)
  165. {
  166. if (RT_SCHED_CTX(current_thread).stat & RT_THREAD_STAT_SIGNAL_PENDING)
  167. {
  168. void *sig_context;
  169. RT_SCHED_CTX(current_thread).stat &= ~RT_THREAD_STAT_SIGNAL_PENDING;
  170. rt_spin_unlock_irqrestore(&_thread_signal_lock, level);
  171. sig_context = rt_hw_stack_init((void *)_signal_entry, context,
  172. (void*)((char*)context - 32), RT_NULL);
  173. return sig_context;
  174. }
  175. }
  176. rt_spin_unlock_irqrestore(&_thread_signal_lock, level);
  177. return context;
  178. }
  179. #endif /* RT_USING_SMP */
  180. /**
  181. * @brief This function will install a processing function to a specific
  182. * signal and return the old processing function of this signal.
  183. *
  184. * @note This function needs to be used in conjunction with the
  185. * rt_signal_unmask() function to make the signal effective.
  186. *
  187. * @see rt_signal_unmask()
  188. *
  189. * @param signo is a specific signal value (range: 0 ~ RT_SIG_MAX).
  190. *
  191. * @param handler is sets the processing of signal value.
  192. *
  193. * @return Return the old processing function of this signal. ONLY When the
  194. * return value is SIG_ERR, the operation is failed.
  195. */
  196. rt_sighandler_t rt_signal_install(int signo, rt_sighandler_t handler)
  197. {
  198. rt_base_t level;
  199. rt_sighandler_t old = RT_NULL;
  200. rt_thread_t tid = rt_thread_self();
  201. if (!sig_valid(signo)) return SIG_ERR;
  202. level = rt_spin_lock_irqsave(&_thread_signal_lock);
  203. if (tid->sig_vectors == RT_NULL)
  204. {
  205. rt_spin_unlock_irqrestore(&_thread_signal_lock, level);
  206. rt_thread_alloc_sig(tid);
  207. level = rt_spin_lock_irqsave(&_thread_signal_lock);
  208. }
  209. if (tid->sig_vectors)
  210. {
  211. old = tid->sig_vectors[signo];
  212. if (handler == SIG_IGN) tid->sig_vectors[signo] = RT_NULL;
  213. else if (handler == SIG_DFL) tid->sig_vectors[signo] = _signal_default_handler;
  214. else tid->sig_vectors[signo] = handler;
  215. }
  216. rt_spin_unlock_irqrestore(&_thread_signal_lock, level);
  217. return old;
  218. }
  219. /**
  220. * @brief This function will block the specified signal.
  221. *
  222. * @note This function will block the specified signal, even if the
  223. * rt_thread_kill() function is called to send this signal to
  224. * the current thread, it will no longer take effect.
  225. *
  226. * @see rt_thread_kill()
  227. *
  228. * @param signo is a specific signal value (range: 0 ~ RT_SIG_MAX).
  229. */
  230. void rt_signal_mask(int signo)
  231. {
  232. rt_base_t level;
  233. rt_thread_t tid = rt_thread_self();
  234. level = rt_spin_lock_irqsave(&_thread_signal_lock);
  235. tid->sig_mask &= ~sig_mask(signo);
  236. rt_spin_unlock_irqrestore(&_thread_signal_lock, level);
  237. }
  238. /**
  239. * @brief This function will unblock the specified signal.
  240. *
  241. * @note This function will unblock the specified signal. After calling
  242. * the rt_thread_kill() function to send this signal to the current
  243. * thread, it will take effect.
  244. *
  245. * @see rt_thread_kill()
  246. *
  247. * @param signo is a specific signal value (range: 0 ~ RT_SIG_MAX).
  248. */
  249. void rt_signal_unmask(int signo)
  250. {
  251. rt_base_t level;
  252. rt_thread_t tid = rt_thread_self();
  253. level = rt_spin_lock_irqsave(&_thread_signal_lock);
  254. tid->sig_mask |= sig_mask(signo);
  255. /* let thread handle pended signals */
  256. if (tid->sig_mask & tid->sig_pending)
  257. {
  258. rt_spin_unlock_irqrestore(&_thread_signal_lock, level);
  259. _signal_deliver(tid);
  260. }
  261. else
  262. {
  263. rt_spin_unlock_irqrestore(&_thread_signal_lock, level);
  264. }
  265. }
  266. /**
  267. * @brief This function will wait for the arrival of the set signal. If it does not wait for this signal, the thread will be
  268. * suspended until it waits for this signal or the waiting time exceeds the specified timeout: timeout.
  269. *
  270. * @param set is the set of signal values to be waited for. Use the function
  271. * sigaddset() to add the signal.
  272. *
  273. * @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.
  274. *
  275. * @param timeout is a timeout period (unit: an OS tick).
  276. *
  277. * @return Return the operation status. When the return value is RT_EOK, the operation is successful.
  278. * If the return value is any other values, it means that the signal wait failed.
  279. */
  280. int rt_signal_wait(const rt_sigset_t *set, rt_siginfo_t *si, rt_int32_t timeout)
  281. {
  282. int ret = RT_EOK;
  283. rt_base_t level;
  284. rt_thread_t tid = rt_thread_self();
  285. struct siginfo_node *si_node = RT_NULL, *si_prev = RT_NULL;
  286. /* current context checking */
  287. RT_DEBUG_IN_THREAD_CONTEXT;
  288. /* parameters check */
  289. if (set == NULL || *set == 0 || si == NULL )
  290. {
  291. ret = -RT_EINVAL;
  292. goto __done_return;
  293. }
  294. /* clear siginfo to avoid unknown value */
  295. memset(si, 0x0, sizeof(rt_siginfo_t));
  296. level = rt_spin_lock_irqsave(&_thread_signal_lock);
  297. /* already pending */
  298. if (tid->sig_pending & *set) goto __done;
  299. if (timeout == 0)
  300. {
  301. ret = -RT_ETIMEOUT;
  302. goto __done_int;
  303. }
  304. /* suspend self thread */
  305. rt_thread_suspend_with_flag(tid, RT_UNINTERRUPTIBLE);
  306. /* set thread stat as waiting for signal */
  307. RT_SCHED_CTX(tid).stat |= RT_THREAD_STAT_SIGNAL_WAIT;
  308. /* start timeout timer */
  309. if (timeout != RT_WAITING_FOREVER)
  310. {
  311. rt_tick_t timeout_tick = timeout;
  312. /* reset the timeout of thread timer and start it */
  313. rt_timer_control(&(tid->thread_timer),
  314. RT_TIMER_CTRL_SET_TIME,
  315. &timeout_tick);
  316. rt_timer_start(&(tid->thread_timer));
  317. }
  318. rt_spin_unlock_irqrestore(&_thread_signal_lock, level);
  319. /* do thread scheduling */
  320. rt_schedule();
  321. level = rt_spin_lock_irqsave(&_thread_signal_lock);
  322. /* remove signal waiting flag */
  323. RT_SCHED_CTX(tid).stat &= ~RT_THREAD_STAT_SIGNAL_WAIT;
  324. /* check errno of thread */
  325. if (tid->error == -RT_ETIMEOUT)
  326. {
  327. tid->error = RT_EOK;
  328. rt_spin_unlock_irqrestore(&_thread_signal_lock, level);
  329. /* timer timeout */
  330. ret = -RT_ETIMEOUT;
  331. goto __done_return;
  332. }
  333. __done:
  334. /* to get the first matched pending signals */
  335. si_node = (struct siginfo_node *)tid->si_list;
  336. while (si_node)
  337. {
  338. int signo;
  339. signo = si_node->si.si_signo;
  340. if (sig_mask(signo) & *set)
  341. {
  342. *si = si_node->si;
  343. LOG_D("sigwait: %d sig raised!", signo);
  344. if (si_prev) si_prev->list.next = si_node->list.next;
  345. else
  346. {
  347. struct siginfo_node *node_next;
  348. if (si_node->list.next)
  349. {
  350. node_next = (void *)rt_slist_entry(si_node->list.next, struct siginfo_node, list);
  351. tid->si_list = node_next;
  352. }
  353. else
  354. {
  355. tid->si_list = RT_NULL;
  356. }
  357. }
  358. /* clear pending */
  359. tid->sig_pending &= ~sig_mask(signo);
  360. rt_mp_free(si_node);
  361. break;
  362. }
  363. si_prev = si_node;
  364. if (si_node->list.next)
  365. {
  366. si_node = (void *)rt_slist_entry(si_node->list.next, struct siginfo_node, list);
  367. }
  368. else
  369. {
  370. si_node = RT_NULL;
  371. }
  372. }
  373. __done_int:
  374. rt_spin_unlock_irqrestore(&_thread_signal_lock, level);
  375. __done_return:
  376. return ret;
  377. }
  378. void rt_thread_handle_sig(rt_bool_t clean_state)
  379. {
  380. rt_base_t level;
  381. rt_thread_t tid = rt_thread_self();
  382. struct siginfo_node *si_node;
  383. level = rt_spin_lock_irqsave(&_thread_signal_lock);
  384. if (tid->sig_pending & tid->sig_mask)
  385. {
  386. /* if thread is not waiting for signal */
  387. if (!(RT_SCHED_CTX(tid).stat & RT_THREAD_STAT_SIGNAL_WAIT))
  388. {
  389. while (tid->sig_pending & tid->sig_mask)
  390. {
  391. int signo, error;
  392. rt_sighandler_t handler;
  393. si_node = (struct siginfo_node *)tid->si_list;
  394. if (!si_node) break;
  395. /* remove this sig info node from list */
  396. if (si_node->list.next == RT_NULL)
  397. tid->si_list = RT_NULL;
  398. else
  399. tid->si_list = (void *)rt_slist_entry(si_node->list.next, struct siginfo_node, list);
  400. signo = si_node->si.si_signo;
  401. handler = tid->sig_vectors[signo];
  402. tid->sig_pending &= ~sig_mask(signo);
  403. rt_spin_unlock_irqrestore(&_thread_signal_lock, level);
  404. LOG_D("handle signal: %d, handler 0x%08x", signo, handler);
  405. if (handler) handler(signo);
  406. level = rt_spin_lock_irqsave(&_thread_signal_lock);
  407. error = -RT_EINTR;
  408. rt_mp_free(si_node); /* release this siginfo node */
  409. /* set errno in thread tcb */
  410. tid->error = error;
  411. }
  412. /* whether clean signal status */
  413. if (clean_state == RT_TRUE)
  414. {
  415. RT_SCHED_CTX(tid).stat &= ~RT_THREAD_STAT_SIGNAL;
  416. }
  417. else
  418. {
  419. rt_spin_unlock_irqrestore(&_thread_signal_lock, level);
  420. return;
  421. }
  422. }
  423. }
  424. rt_spin_unlock_irqrestore(&_thread_signal_lock, level);
  425. }
  426. void rt_thread_alloc_sig(rt_thread_t tid)
  427. {
  428. int index;
  429. rt_bool_t need_free = RT_FALSE;
  430. rt_base_t level;
  431. rt_sighandler_t *vectors;
  432. vectors = (rt_sighandler_t *)RT_KERNEL_MALLOC(sizeof(rt_sighandler_t) * RT_SIG_MAX);
  433. RT_ASSERT(vectors != RT_NULL);
  434. for (index = 0; index < RT_SIG_MAX; index ++)
  435. {
  436. vectors[index] = _signal_default_handler;
  437. }
  438. level = rt_spin_lock_irqsave(&_thread_signal_lock);
  439. if (tid->sig_vectors == RT_NULL)
  440. {
  441. tid->sig_vectors = vectors;
  442. }
  443. else
  444. {
  445. need_free = RT_TRUE;
  446. }
  447. rt_spin_unlock_irqrestore(&_thread_signal_lock, level);
  448. if (need_free)
  449. {
  450. rt_free(vectors);
  451. }
  452. }
  453. void rt_thread_free_sig(rt_thread_t tid)
  454. {
  455. rt_base_t level;
  456. struct siginfo_node *si_node;
  457. rt_sighandler_t *sig_vectors;
  458. level = rt_spin_lock_irqsave(&_thread_signal_lock);
  459. si_node = (struct siginfo_node *)tid->si_list;
  460. tid->si_list = RT_NULL;
  461. sig_vectors = tid->sig_vectors;
  462. tid->sig_vectors = RT_NULL;
  463. rt_spin_unlock_irqrestore(&_thread_signal_lock, level);
  464. if (si_node)
  465. {
  466. struct rt_slist_node *node;
  467. struct rt_slist_node *node_to_free;
  468. LOG_D("free signal info list");
  469. node = &(si_node->list);
  470. do
  471. {
  472. node_to_free = node;
  473. node = node->next;
  474. si_node = rt_slist_entry(node_to_free, struct siginfo_node, list);
  475. rt_mp_free(si_node);
  476. } while (node);
  477. }
  478. if (sig_vectors)
  479. {
  480. RT_KERNEL_FREE(sig_vectors);
  481. }
  482. }
  483. /**
  484. * @ingroup group_thread_management
  485. *
  486. * @brief This function can be used to send any signal to any thread.
  487. *
  488. * @param tid is a pointer to the thread that receives the signal.
  489. *
  490. * @param sig is a specific signal value (range: 0 ~ RT_SIG_MAX).
  491. *
  492. * @return Return the operation status. When the return value is RT_EOK, the operation is successful.
  493. * If the return value is any other values, it means that the signal send failed.
  494. */
  495. int rt_thread_kill(rt_thread_t tid, int sig)
  496. {
  497. siginfo_t si;
  498. rt_base_t level;
  499. struct siginfo_node *si_node;
  500. RT_ASSERT(tid != RT_NULL);
  501. if (!sig_valid(sig)) return -RT_EINVAL;
  502. LOG_I("send signal: %d", sig);
  503. si.si_signo = sig;
  504. si.si_code = SI_USER;
  505. si.si_value.sival_ptr = RT_NULL;
  506. level = rt_spin_lock_irqsave(&_thread_signal_lock);
  507. if (tid->sig_pending & sig_mask(sig))
  508. {
  509. /* whether already emits this signal? */
  510. struct rt_slist_node *node;
  511. struct siginfo_node *entry;
  512. si_node = (struct siginfo_node *)tid->si_list;
  513. if (si_node)
  514. node = (struct rt_slist_node *)&si_node->list;
  515. else
  516. node = RT_NULL;
  517. /* update sig info */
  518. for (; (node) != RT_NULL; node = node->next)
  519. {
  520. entry = rt_slist_entry(node, struct siginfo_node, list);
  521. if (entry->si.si_signo == sig)
  522. {
  523. memcpy(&(entry->si), &si, sizeof(siginfo_t));
  524. rt_spin_unlock_irqrestore(&_thread_signal_lock, level);
  525. return 0;
  526. }
  527. }
  528. }
  529. rt_spin_unlock_irqrestore(&_thread_signal_lock, level);
  530. si_node = (struct siginfo_node *) rt_mp_alloc(_siginfo_pool, 0);
  531. if (si_node)
  532. {
  533. rt_slist_init(&(si_node->list));
  534. memcpy(&(si_node->si), &si, sizeof(siginfo_t));
  535. level = rt_spin_lock_irqsave(&_thread_signal_lock);
  536. if (tid->si_list)
  537. {
  538. struct siginfo_node *si_list;
  539. si_list = (struct siginfo_node *)tid->si_list;
  540. rt_slist_append(&(si_list->list), &(si_node->list));
  541. }
  542. else
  543. {
  544. tid->si_list = si_node;
  545. }
  546. /* a new signal */
  547. tid->sig_pending |= sig_mask(sig);
  548. rt_spin_unlock_irqrestore(&_thread_signal_lock, level);
  549. }
  550. else
  551. {
  552. LOG_E("The allocation of signal info node failed.");
  553. return -RT_EEMPTY;
  554. }
  555. /* deliver signal to this thread */
  556. _signal_deliver(tid);
  557. return RT_EOK;
  558. }
  559. int rt_system_signal_init(void)
  560. {
  561. _siginfo_pool = rt_mp_create("signal", RT_SIG_INFO_MAX, sizeof(struct siginfo_node));
  562. if (_siginfo_pool == RT_NULL)
  563. {
  564. LOG_E("create memory pool for signal info failed.");
  565. RT_ASSERT(0);
  566. }
  567. return 0;
  568. }
  569. #endif /* RT_USING_SIGNALS */