rt_list_entry()的作用是根据成员的地址,推出结构体的地址。由于node是rt_list_node类型,而object结构体内有一个rt_list_t,这两个结构体是一样的: struct rt_list_node{struct rt_list_node*next;/**< point to next node. */struct rt_list_node*prev;/**< po
RT_TIMER_SKIP_LIST_LEVEL被定义为1,暂时不清楚RT_TIMER_SKIP_LIST_LEVEL这个变量的作用。可能是为日...
可以看出 rt_list_entry 的作用是先计算链表在其他结构体内的偏移地址,在通过链表的地址偏移地址,就是当前结构体的地址。 /** * @brief 蓝牙监听器的类型定义 */ typedef struct st_bluetooth_listener { pfn_on_bluetooth_event_t onEvent; /**< 事件处理函数 */ void *ctx; /**< 监听器的上下文环境 ...
对应到这里的宏,第一条初始化语句为pos = rt_list_entry((head)->next, typeof(*pos), member);,是一个对pos的赋值语句,所以这里结合代码和上面的注释就能很容易知道第一个参数pos就类似普通for循环的循环变量。初始化又用到了另外一个宏rt_list_entry,此宏相关的代码如下: /** @brief get the struct ...
node是information->object_list中的某个对象指针,来自于某个rt_object结构体中的成员rt_list_t list。 调用rt_list_entry()函数,根据成员(rt_list_t list)的地址获得结构体 rt_object 的地址(对象指针)。 information =rt_object_get_information(RT_Object_Class_Thread);for(node = information->object_list...
rt_list_t list;/* 对象列表 */rt_list_t tlist;/* 线程列表 *//* 栈指针与入口指针 */void*sp;/* 栈指针 */void*entry;/* 入口函数指针 */void*parameter;/* 参数 */void*stack_addr;/* 栈地址指针 */rt_uint32_t stack_size;/* 栈大小 *//* 错误代码 */rt_err_t error;/* 线程错...
t = rt_list_entry(rt_soft_timer_list[RT_TIMER_SKIP_LIST_LEVEL - 1].next, struct rt_timer, row[RT_TIMER_SKIP_LIST_LEVEL - 1]); current_tick = rt_tick_get(); /* * It supposes that the new tick shall less than the half duration of ...
(number<<3)+__rt_ffs(rt_thread_ready_table[number])-1;#endif// 获取rt_thread_priority_table[highest_ready_priority]链表的第一个节点to_thread=rt_list_entry(rt_thread_priority_table[highest_ready_priority].next,structrt_thread,tlist);...// 切换上下文rt_hw_context_switch(...,to_thread...
2.tlist用于rt_thread的一个双向链表,把每个rt_thread实例通过链表链接起来,方便通过name成员来查找对应的rt_thread. 3.sp一个数据指针,指向线程栈当前使用的地址,线程切换之后,用来保存MCU中寄存器sp中的数据。 4.entry一个函数指针,指向线程的入口函数。