获得当前线程
在程序运行中,相同的一段代码可能会被多个线程执行,在执行的时候可以通过 rt_thread_self(void) 函数获取当前执行的句柄。共同的代码被执行时确定当前占用这个线程的句柄。
让出处理资源
rt_thread_yield(void) 让出处理器资源,执行正确返回 RT_EOK。这个函数让当前的进程让出共同调用的资源,然后让调度器找出当前最高优先级的线程运行,当让出后,这个线程又会回到READY(就绪)状态。等待下次线程执行。
线程睡眠
让进程进入休眠
rt_thread_sleep(rt_tick_t tick) 按照时钟节拍数进行阻塞。休眠几个街拍
rt_thread_delay(rt_tick_t tick) 同上
rt_thread_mdelay(rt_int32_t ms) 设置线程阻塞时间,让线程阻塞时间按照毫秒阻塞
线程控制
- This function will control thread behaviors according to control command.
@param thread the specified thread to be controlled
@param cmd the control command, which includes
//RT THREAD CTRL CHANGE PRIORITY for changing priority level of thread;改变优先级*arg传入优先级
//RT THREA