2
我正在使用list_for_each_entry(datastructureptr , &mylinkedlist, head)
遍歷我創建的鏈表。我得到的輸出是最後插入的項目被首先打印。這是預期的產出嗎?是否有任何宏/功能以其他方式打印?在FIFO方式內核中的鏈接列表遍歷
我正在使用list_for_each_entry(datastructureptr , &mylinkedlist, head)
遍歷我創建的鏈表。我得到的輸出是最後插入的項目被首先打印。這是預期的產出嗎?是否有任何宏/功能以其他方式打印?在FIFO方式內核中的鏈接列表遍歷
list_for_each_entry
struct private {
char data[30];
struct list_head head;
};
.......
.....
static struct private mylinkedlist;
....
struct private *datastructureptr=&mylinkedlist;
...
list_for_each_entry(datastructureptr , &mylinkedlist, head)
printk(" %s->\n",datastructureptr->data);
打印項目遍歷從第一個到最後一個項目列表。
您必須確保項目以正確的順序和正確的位置插入。 list_add
插入列表的開頭; list_add_tail
最後。
我給list_add的第二個參數作爲列表頭,所以得到了這樣的輸出。謝謝(你的)信息。 – user567879