![]() |
The ROme OpTimistic Simulator
3.0.0
A General-Purpose Multithreaded Parallel/Distributed Simulation Platform
|
Message queue datatype. More...
#include <datatypes/msg_queue.h>#include <core/core.h>#include <core/sync.h>#include <datatypes/heap.h>#include <lp/lp.h>#include <mm/msg_allocator.h>#include <stdalign.h>
Include dependency graph for msg_queue.c:Go to the source code of this file.
Data Structures | |
| struct | msg_queue |
| A queue synchronized by a spinlock. More... | |
Macros | |
| #define | mqueue(from, to) (&queues[to * n_threads + from]) |
| Utility macro to fetch the correct inner queue. | |
Functions | |
| void | msg_queue_global_init (void) |
| Initializes the message queue at the node level. | |
| void | msg_queue_init (void) |
| Initializes the message queue for the current thread. | |
| void | msg_queue_fini (void) |
| Finalizes the message queue for the current thread. | |
| void | msg_queue_global_fini (void) |
| Finalizes the message queue at the node level. | |
| struct lp_msg * | msg_queue_extract (void) |
| Extracts the next message from the queue. More... | |
| simtime_t | msg_queue_time_peek (void) |
| Peeks the timestamp of the next message from the queue. More... | |
| void | msg_queue_insert (struct lp_msg *msg) |
| Inserts a message in the queue. More... | |
Variables | |
| static struct msg_queue * | queues |
| The queues matrix, linearized in a contiguous array. | |
Message queue datatype.
This is the message queue for the parallel runtime. The design is pretty simple. A queue for n threads is composed by a n * n square matrix of simpler queues. If thread t1 wants to send a message to thread t2 it puts a message in the i-th queue where i = t2 * n + t1. Insertions are then cheap, while extractions lazily lock the queues (costing linear time in the number of worked threads, which seems to be acceptable in practice).
Definition in file msg_queue.c.
| struct lp_msg* msg_queue_extract | ( | void | ) |
Extracts the next message from the queue.
The extracted message is a best effort lowest timestamp for the current thread. Guaranteeing the lowest timestamp may increase the contention on the queues.
Definition at line 98 of file msg_queue.c.
| void msg_queue_insert | ( | struct lp_msg * | msg | ) |
Inserts a message in the queue.
| msg | the message to insert in the queue |
Definition at line 168 of file msg_queue.c.
| simtime_t msg_queue_time_peek | ( | void | ) |
Peeks the timestamp of the next message from the queue.
This returns the lowest timestamp of the next message to be processed for the current thread. This is calculated in a precise fashion since this value is used in the gvt calculation.
Definition at line 137 of file msg_queue.c.