What is the implementation principle of qemu queue?
Today, I will talk to you about the implementation principle of qemu queue, which may not be well understood by many people. in order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.
# define QLIST_HEAD (name, type)\
Struct name {\
Struct type * lh_first; / * first element * /\
}
# define QLIST_HEAD_INITIALIZER (head)\
{NULL}
# define QLIST_ENTRY (type)\
Struct {\
Struct type * le_next; / * next element * /\
Struct type * * le_prev; / * address of previous next element * /\
}
/ *
* List functions.
, /
# define QLIST_INIT (head) do {\
(head)-> lh_first = NULL;\
} while (/ * CONSTCOND*/0)
# define QLIST_INSERT_AFTER (listelm, elm, field) do {\
If (elm)-> field.le_next = (listelm)-> field.le_next)! = NULL)\
(listelm)-> field.le_next- > field.le_prev =\
& (elm)-> field.le_next;\
(listelm)-> field.le_next = (elm);\
(elm)-> field.le_prev = & (listelm)-> field.le_next;\
} while (/ * CONSTCOND*/0)
# define QLIST_INSERT_BEFORE (listelm, elm, field) do {\
(elm)-> field.le_prev = (listelm)-> field.le_prev;\
(elm)-> field.le_next = (listelm);\
* (listelm)-> field.le_prev = (elm);\
(listelm)-> field.le_prev = & (elm)-> field.le_next;\
} while (/ * CONSTCOND*/0)
# define QLIST_INSERT_HEAD (head, elm, field) do {\
If (elm)-> field.le_next = (head)-> lh_first)! = NULL)\
(head)-> lh_first- > field.le_prev = & (elm)-> field.le_next;\
(head)-> lh_first = (elm);\
(elm)-> field.le_prev = & (head)-> lh_first;\
} while (/ * CONSTCOND*/0)
Node- > next points to the next node
Node- > prev is the entry that points to the previous node, so * (node- > prev) is the address of the Nextfield of the previous node.
That is to say (* node- > prev)-> next = = node
After reading the above, do you have any further understanding of how qemu queues are implemented? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.