diff options
| author | guochuangjian <[email protected]> | 2018-08-05 15:08:50 +0800 |
|---|---|---|
| committer | guochuangjian <[email protected]> | 2018-08-05 15:08:50 +0800 |
| commit | 3de51fe25688f0b6c7cb9f9d424861654fb09e49 (patch) | |
| tree | dcf4a170b00deace7860187e3ff9c2e6495e0923 /src/thread.c | |
| parent | 650f06aa1943d439ac049f6bc276b216999e6a56 (diff) | |
| parent | 03bf99a56de255d41655bc8486d50cadbcae22f0 (diff) | |
fix usRcvBufferPos == MB_SER_PDU_SIZE_MAX bug
Diffstat (limited to 'src/thread.c')
| -rw-r--r-- | src/thread.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/thread.c b/src/thread.c index ea0ba0bfc9..b3d91b30d0 100644 --- a/src/thread.c +++ b/src/thread.c @@ -199,6 +199,10 @@ static rt_err_t _rt_thread_init(struct rt_thread *thread, thread->si_list = RT_NULL; #endif +#ifdef RT_USING_LWP + thread->lwp = RT_NULL; +#endif + RT_OBJECT_HOOK_CALL(rt_thread_inited_hook, (thread)); return RT_EOK; @@ -275,6 +279,7 @@ rt_err_t rt_thread_startup(rt_thread_t thread) /* thread check */ RT_ASSERT(thread != RT_NULL); RT_ASSERT((thread->stat & RT_THREAD_STAT_MASK) == RT_THREAD_INIT); + RT_ASSERT(rt_object_get_type((rt_object_t)thread) == RT_Object_Class_Thread); /* set current priority to init priority */ thread->current_priority = thread->init_priority; @@ -318,6 +323,8 @@ rt_err_t rt_thread_detach(rt_thread_t thread) /* thread check */ RT_ASSERT(thread != RT_NULL); + RT_ASSERT(rt_object_get_type((rt_object_t)thread) == RT_Object_Class_Thread); + RT_ASSERT(rt_object_is_systemobject((rt_object_t)thread)); if ((thread->stat & RT_THREAD_STAT_MASK) != RT_THREAD_INIT) { @@ -416,6 +423,8 @@ rt_err_t rt_thread_delete(rt_thread_t thread) /* thread check */ RT_ASSERT(thread != RT_NULL); + RT_ASSERT(rt_object_get_type((rt_object_t)thread) == RT_Object_Class_Thread); + RT_ASSERT(rt_object_is_systemobject((rt_object_t)thread) == RT_FALSE); if ((thread->stat & RT_THREAD_STAT_MASK) != RT_THREAD_INIT) { @@ -504,6 +513,7 @@ rt_err_t rt_thread_sleep(rt_tick_t tick) /* set to current thread */ thread = rt_current_thread; RT_ASSERT(thread != RT_NULL); + RT_ASSERT(rt_object_get_type((rt_object_t)thread) == RT_Object_Class_Thread); /* suspend thread */ rt_thread_suspend(thread); @@ -538,6 +548,23 @@ rt_err_t rt_thread_delay(rt_tick_t tick) RTM_EXPORT(rt_thread_delay); /** + * This function will let current thread delay for some milliseconds. + * + * @param tick the delay time + * + * @return RT_EOK + */ +rt_err_t rt_thread_mdelay(rt_int32_t ms) +{ + rt_tick_t tick; + + tick = rt_tick_from_millisecond(ms); + + return rt_thread_sleep(tick); +} +RTM_EXPORT(rt_thread_mdelay); + +/** * This function will control thread behaviors according to control command. * * @param thread the specified thread to be controlled @@ -555,6 +582,7 @@ rt_err_t rt_thread_control(rt_thread_t thread, int cmd, void *arg) /* thread check */ RT_ASSERT(thread != RT_NULL); + RT_ASSERT(rt_object_get_type((rt_object_t)thread) == RT_Object_Class_Thread); switch (cmd) { @@ -633,6 +661,7 @@ rt_err_t rt_thread_suspend(rt_thread_t thread) /* thread check */ RT_ASSERT(thread != RT_NULL); + RT_ASSERT(rt_object_get_type((rt_object_t)thread) == RT_Object_Class_Thread); RT_DEBUG_LOG(RT_DEBUG_THREAD, ("thread suspend: %s\n", thread->name)); @@ -675,6 +704,7 @@ rt_err_t rt_thread_resume(rt_thread_t thread) /* thread check */ RT_ASSERT(thread != RT_NULL); + RT_ASSERT(rt_object_get_type((rt_object_t)thread) == RT_Object_Class_Thread); RT_DEBUG_LOG(RT_DEBUG_THREAD, ("thread resume: %s\n", thread->name)); @@ -720,6 +750,7 @@ void rt_thread_timeout(void *parameter) /* thread check */ RT_ASSERT(thread != RT_NULL); RT_ASSERT((thread->stat & RT_THREAD_STAT_MASK) == RT_THREAD_SUSPEND); + RT_ASSERT(rt_object_get_type((rt_object_t)thread) == RT_Object_Class_Thread); /* set error number */ thread->error = -RT_ETIMEOUT; |
