浏览代码

[kernel] 当tick为0时rt_thread_sleep不应该挂起线程

Ylne 2 年之前
父节点
当前提交
bfa357958d
共有 1 个文件被更改,包括 5 次插入0 次删除
  1. 5 0
      src/thread.c

+ 5 - 0
src/thread.c

@@ -572,6 +572,11 @@ rt_err_t rt_thread_sleep(rt_tick_t tick)
     rt_base_t level;
     struct rt_thread *thread;
 
+    if (tick == 0)
+    {
+        return -RT_EINVAL;
+    }
+
     /* set to current thread */
     thread = rt_thread_self();
     RT_ASSERT(thread != RT_NULL);