我一直有一些問題,我正在運行幾個任務。我有三個任務,其中一個是LCD更新任務,另外兩個是電機驅動任務。我還有兩個ISR將消息發佈到兩個電機驅動程序任務中。至於傳遞指針安全,我在想創建一個結構:實時操作系統 - 通過分配一個結構並傳遞它通過一個隊列
typedef struct message{
enum BUTTON_1 = 0, BUTTON_2 = 1, NO_BUTTON = 3; //button ISR to increase motor drive
int timestamp; //A timestamp for the RPM of the motors
}
現在,共享內存的問題進來,所以我想:
struct message* update_msg = (struct message*)malloc(sizeof(struct message)); //from here I dont know how to creat an object that fills the space allocated.
我會再發指針通過隊列的結構:
OSTASKQPOST((void *)(st_size)
....
)
在最後一次任務後最終得到的消息,並做它需要與成員變量是什麼,我將不得不解除分配內存。
free(st_size)
會是這樣的似是而非?