From 758ef390246e6edf0d662e8a609b1350f9e118d0 Mon Sep 17 00:00:00 2001 From: wangqinglin <1139077247@qq.com> Date: Tue, 19 Oct 2021 10:00:01 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=9B=B4=E6=96=B0=E3=80=91=E8=B0=83?= =?UTF-8?q?=E6=95=B4RT=5FASSERT=E5=92=8CRT=5FDEBUG=5FNOT=5FIN=5FINTERRUPT?= =?UTF-8?q?=EF=BC=8C=E7=BB=B4=E6=8C=81=E4=BB=A3=E7=A0=81=E9=A3=8E=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ipc.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/ipc.c b/src/ipc.c index 08e94dc7c7..32018b955f 100755 --- a/src/ipc.c +++ b/src/ipc.c @@ -378,10 +378,11 @@ rt_sem_t rt_sem_create(const char *name, rt_uint32_t value, rt_uint8_t flag) { rt_sem_t sem; - RT_DEBUG_NOT_IN_INTERRUPT; RT_ASSERT(value < 0x10000U); RT_ASSERT((flag == RT_IPC_FLAG_FIFO) || (flag == RT_IPC_FLAG_PRIO)); + RT_DEBUG_NOT_IN_INTERRUPT; + /* allocate object */ sem = (rt_sem_t)rt_object_allocate(RT_Object_Class_Semaphore, name); if (sem == RT_NULL) @@ -421,13 +422,13 @@ RTM_EXPORT(rt_sem_create); */ rt_err_t rt_sem_delete(rt_sem_t sem) { - RT_DEBUG_NOT_IN_INTERRUPT; - /* parameter check */ RT_ASSERT(sem != RT_NULL); RT_ASSERT(rt_object_get_type(&sem->parent.parent) == RT_Object_Class_Semaphore); RT_ASSERT(rt_object_is_systemobject(&sem->parent.parent) == RT_FALSE); + RT_DEBUG_NOT_IN_INTERRUPT; + /* wakeup all suspended threads */ _ipc_list_resume_all(&(sem->parent.suspend_thread)); @@ -850,13 +851,13 @@ RTM_EXPORT(rt_mutex_create); */ rt_err_t rt_mutex_delete(rt_mutex_t mutex) { - RT_DEBUG_NOT_IN_INTERRUPT; - /* parameter check */ RT_ASSERT(mutex != RT_NULL); RT_ASSERT(rt_object_get_type(&mutex->parent.parent) == RT_Object_Class_Mutex); RT_ASSERT(rt_object_is_systemobject(&mutex->parent.parent) == RT_FALSE); + RT_DEBUG_NOT_IN_INTERRUPT; + /* wakeup all suspended threads */ _ipc_list_resume_all(&(mutex->parent.suspend_thread)); @@ -1346,8 +1347,9 @@ rt_event_t rt_event_create(const char *name, rt_uint8_t flag) { rt_event_t event; - RT_DEBUG_NOT_IN_INTERRUPT; RT_ASSERT((flag == RT_IPC_FLAG_FIFO) || (flag == RT_IPC_FLAG_PRIO)); + + RT_DEBUG_NOT_IN_INTERRUPT; /* allocate object */ event = (rt_event_t)rt_object_allocate(RT_Object_Class_Event, name); @@ -1869,9 +1871,10 @@ rt_mailbox_t rt_mb_create(const char *name, rt_size_t size, rt_uint8_t flag) { rt_mailbox_t mb; - RT_DEBUG_NOT_IN_INTERRUPT; RT_ASSERT((flag == RT_IPC_FLAG_FIFO) || (flag == RT_IPC_FLAG_PRIO)); + RT_DEBUG_NOT_IN_INTERRUPT; + /* allocate object */ mb = (rt_mailbox_t)rt_object_allocate(RT_Object_Class_MailBox, name); if (mb == RT_NULL) @@ -1925,13 +1928,13 @@ RTM_EXPORT(rt_mb_create); */ rt_err_t rt_mb_delete(rt_mailbox_t mb) { - RT_DEBUG_NOT_IN_INTERRUPT; - /* parameter check */ RT_ASSERT(mb != RT_NULL); RT_ASSERT(rt_object_get_type(&mb->parent.parent) == RT_Object_Class_MailBox); RT_ASSERT(rt_object_is_systemobject(&mb->parent.parent) == RT_FALSE); + RT_DEBUG_NOT_IN_INTERRUPT; + /* resume all suspended thread */ _ipc_list_resume_all(&(mb->parent.suspend_thread)); @@ -2591,8 +2594,9 @@ rt_mq_t rt_mq_create(const char *name, struct rt_mq_message *head; register rt_base_t temp; - RT_DEBUG_NOT_IN_INTERRUPT; RT_ASSERT((flag == RT_IPC_FLAG_FIFO) || (flag == RT_IPC_FLAG_PRIO)); + + RT_DEBUG_NOT_IN_INTERRUPT; /* allocate object */ mq = (rt_mq_t)rt_object_allocate(RT_Object_Class_MessageQueue, name); @@ -2666,13 +2670,13 @@ RTM_EXPORT(rt_mq_create); */ rt_err_t rt_mq_delete(rt_mq_t mq) { - RT_DEBUG_NOT_IN_INTERRUPT; - /* parameter check */ RT_ASSERT(mq != RT_NULL); RT_ASSERT(rt_object_get_type(&mq->parent.parent) == RT_Object_Class_MessageQueue); RT_ASSERT(rt_object_is_systemobject(&mq->parent.parent) == RT_FALSE); + RT_DEBUG_NOT_IN_INTERRUPT; + /* resume all suspended thread */ _ipc_list_resume_all(&(mq->parent.suspend_thread)); /* also resume all message queue private suspended thread */