RT thread核心物件標誌flag總結

2021-07-14 09:24:55 字數 2457 閱讀 7222

一、核心標誌flag

在核心物件控制塊中有乙個標誌成員flag(rt_uint8_t flag; ),這個標誌在不同有核心物件中具有不同的含義。rt-thread的核心物件有定時器、執行緒、訊號量、互斥鎖、事件、郵箱、訊息佇列、記憶體堆、裝置、模組,這些核心物件都繼承了核心物件的成員,其中也就包含了核心物件的flag成員,因此,核心物件成員flag在這些不同的場合是具體不同的含義的。

二、flag在定時器中的定義   

#define rt_timer_flag_deactivated       0x0             /**< timer is deactive *//

/定時器未啟用,即初始化值

#define rt_timer_flag_activated 0x1 /**< timer is active *//

/定時器啟用,當定時器start後將會置為此狀態

#define rt_timer_flag_one_shot 0x0 /**< one shot timer *//

/單次定時器.即定時器時間一到自動失效

#define rt_timer_flag_periodic 0x2 /**< periodic timer *//

/週期定時器.即時間一到,自動時行下一次定時

#define rt_timer_flag_hard_timer 0x0 /**< hard timer,the timer's callback function will be called in tick isr. *//

/硬時鐘.硬體定時器中斷模式

#define rt_timer_flag_soft_timer 0x4 /**< soft timer,the timer's callback function will be called in timer thread. *//

/軟體時鐘.軟體定時器執行緒模式

struct

rt_thread

{

/*rt object

*/char name[rt_name_max]; /*

*< the name of thread

*/rt_uint8_t type;

/**< type of object

*/rt_uint8_t flags;

/**< thread's flags

*/#ifdef rt_using_module

void *module_id; /*

*/#endif

rt_list_t list;

/**< the object list

*/rt_list_t tlist;

/**< the thread list

*/......

四、flag在ipc中的定義

rtt在ipc物件在訊號量,互斥鎖,事件,郵件,訊息佇列這五類這裡我們統稱為ipc核心物件。flag在這些ipc核心物件中只有兩種定義:  

#define rt_ipc_flag_fifo                0x00            /**< fifoed ipc. @ref ipc. *//

/按佇列先進先出的方式處理.

#define rt_ipc_flag_prio 0x01 /**< prioed ipc. @ref ipc. *//

/按執行緒優先順序的方式處理,即哪個執行緒的優先順序高,則哪個先操作.

五、其他

flag在裝置、記憶體池、記憶體堆中均沒有用到。flag在模組中有用到,bit0被用作帶entry point與否標誌。

六、rt-thread核心總結

在rtthread-2.0.0正式版中,系統核心主要在src資料夾中:

在前面所講的rtthread有關核心的章節中,主要對其中10個原始檔所涉及的核心物件作了詳細介紹:

對於其中kservice.c(有關鍊錶初始化,往前插入,向後插入)、memheap.c(記憶體堆)、mempool.c(內在池)、moudule.c(moudule.h,應用模組)、slab.c(slab記憶體管理演算法)5個部份沒有詳細介紹。

RT thread核心物件標誌flag總結

一 核心標誌flag 在核心物件控制塊中有乙個標誌成員flag rt uint8 t flag 這個標誌在不同有核心物件中具有不同的含義。rt thread的核心物件有定時器 執行緒 訊號量 互斥鎖 事件 郵箱 訊息佇列 記憶體堆 裝置 模組,這些核心物件都繼承了核心物件的成員,其中也就包含了核心物...

RT thread核心之事件

一 事件控制塊 在include rtdef.h中 ifdef rt using event flag defintions in event define rt event flag and 0x01 logic and define rt event flag or 0x02 logic or ...

RT Thread 核心小細節

訊號量 郵箱訊號 排程中斷鎖 事件訊號量是根據初始值分層的,例如訊號量建立時初始值為2,那麼可以在不釋放訊號量的情況下被獲取兩次此訊號量。釋放一次訊號量訊號量的值 semaphore value 就會加一,獲取一次訊號量的值就會減掉一,為零則不能獲取,被掛起。使用if rt mb recv mb,r...