问题
Is there a library for C that provides priority queues? I'm interested in open source libraries that are commonly installed on Linux machines, something of the kind of glib, which provides some data structures.
回答1:
Some random link:
- PQLib
- libpqueue
- pqueue-heap-c
Edit:
In general, books dealing with Linux Kernel and Linux System Programming contain valuable materials related to queues and their implemention details.
回答2:
You may be able to just use message queues, depending on how big the queues need to be.
With posix message queues (see man mq_overview
) you can set message priorities.
Alternately, with System V message queues (msgget()
, msgsnd()
, msgrcv()
), you can use the message type as a priority and try retrieving each priority (type) in sequence from highest priority to lowest.
In either case they're standard IPC, and should be available on any normal Linux distribution.
来源:https://stackoverflow.com/questions/8544856/is-there-a-library-for-c-that-provides-priority-queues