50 void (*
ScheduleNewEvent)(
unsigned int gid_receiver,
simtime_t timestamp,
unsigned int event_type,
void *event_content,
unsigned int event_size);
85 list_pop(lp->queue_in);
88 list_pop(lp->queue_out);
115 return find_lp_by_gid(receiver);
116 return find_lp_by_gid(sender);
134 lp = find_lp_by_gid(msg->sender);
135 slab_free(lp->
mm->slab, msg);
230 slab_free(lp->
mm->slab, msg);
268 switch_to_platform_mode();
273 set_gid(receiver, gid_receiver);
281 rootsim_error(
false,
"Warning: the destination LP %u is out of range. The event has been ignored\n", gid_receiver);
286 rootsim_error(
true,
"LP %u is trying to generate an event (type %d) to %u in the past! (Current LVT = %f, generated event's timestamp = %f) Aborting...\n",
291 if (
unlikely(event_type >= RESERVED_MSG_CODE)) {
292 rootsim_error(
true,
"LP %u is generating an event with type %d which is a reserved type. Switch event type to a value less than %d. Aborting...\n",
309 switch_to_application_mode();
337 while (anti_msg != NULL && anti_msg->send_time > after_simtime) {
340 msg->message_kind = negative;
346 list_delete_by_content(lp->queue_out, anti_msg);
348 anti_msg = anti_msg_prev;
433 register unsigned int i = 0;
500 *msg = rsalloc(
sizeof(
msg_t) + size);
501 bzero(*msg,
sizeof(
msg_t) + size);
504 (*msg)->sender = sender;
505 (*msg)->receiver = receiver;
507 (*msg)->message_kind = positive;
508 (*msg)->timestamp = timestamp;
509 (*msg)->send_time = send_time;
513 if (payload != NULL && size > 0)
514 memcpy((*msg)->event_content, payload, size);
536 hdr->sender = msg->sender;
537 hdr->receiver = msg->receiver;
538 hdr->type = msg->type;
541 hdr->send_time = msg->send_time;
542 hdr->mark = msg->mark;
570 msg->sender = hdr->sender;
571 msg->receiver = hdr->receiver;
572 msg->type = hdr->type;
575 msg->send_time = hdr->send_time;
576 msg->mark = hdr->mark;
591 printf(
"\tsender: %u\n", msg->sender.
to_int);
592 printf(
"\treceiver: %u\n", msg->sender.
to_int);
594 printf(
"\tcolour: %d\n", msg->colour);
596 printf(
"\ttype: %d\n", msg->type);
597 printf(
"\tmessage_kind: %d\n", msg->message_kind);
598 printf(
"\ttimestamp: %f\n", msg->timestamp);
599 printf(
"\tsend_time: %f\n", msg->send_time);
600 printf(
"\tmark: %llu\n", msg->mark);
602 printf(
"\tsize: %d\n", msg->
size);
630 double z = (double)mark;
631 double w = floor((sqrt(8 * z + 1) - 1) / 2.0);
632 double t = (w * w + w) / 2.0;
668 assert(msg->message_kind == positive || msg->message_kind == negative || msg->message_kind == control);
unsigned long long generate_mark(struct lp_struct *lp)
#define likely(exp)
Optimize the branch as likely taken.
Message queueing subsystem.
Core ROOT-Sim functionalities.
#define SLAB_MSG_SIZE
Slab allocator max message size.
void mpi_finalize(void)
Finalize MPI.
unsigned int mark_to_gid(unsigned long long mark)
Tell the GID of the sender of a message, given its mark.
unsigned int max_size
Total space in outgoing_msgs.
simtime_t timestamp
Unique identifier of the message, used for rendez-vous event.
Anything after this value is considered as an impossible message.
void msg_to_hdr(msg_hdr_t *hdr, msg_t *msg)
Convert a message to a message header.
void ParallelScheduleNewEvent(unsigned int gid_receiver, simtime_t timestamp, unsigned int event_type, void *event_content, unsigned int event_size)
Schedule a new message to some LP.
unsigned int to_int
The GID numerical value.
The ROOT-Sim scheduler main module header.
struct memory_map * mm
Memory map of the LP.
void dump_msg_content(msg_t *msg)
Dump the content of a message.
Separation value between model and platform messages.
__thread struct lp_struct * current
This is a per-thread variable pointing to the block state of the LP currently scheduled.
unsigned int find_kernel_by_gid(GID_t gid)
ECS protocol: start synchronizing two LPs for a page fault.
#define list_insert(li, key_name, data)
Insert a new node in the list.
double simtime_t
This defines the type with whom timestamps are represented.
__thread msg_t * current_evt
Memory Manager main header.
unsigned long long mark
Unique identifier within the LP.
unsigned int size
Unique identifier of the message, used for rendez-vous events.
void inter_kernel_comm_finalize(void)
Finalize inter-kernel communication.
void insert_outgoing_msg(msg_t *msg)
Place a message in the temporary LP outgoing buffer.
void Send(msg_t *msg)
Send a message.
unsigned long long rendezvous_mark
Unique identifier of the message, used for antimessages.
void pack_msg(msg_t **msg, GID_t sender, GID_t receiver, int type, simtime_t timestamp, simtime_t send_time, size_t size, void *payload)
Pack a message in a platform-level data structure.
void validate_msg(msg_t *msg)
Perform some sanity checks on a message buffer.
static struct lp_struct * which_slab_to_use(GID_t sender, GID_t receiver)
Find a slab to allocate a message buffer.
void(* ScheduleNewEvent)(unsigned int gid_receiver, simtime_t timestamp, unsigned int event_type, void *event_content, unsigned int event_size)
This is the function pointer to correctly set ScheduleNewEvent API version, depending if we're runnin...
void msg_release(msg_t *msg)
Release a message buffer.
void send_remote_msg(msg_t *msg)
Send a message to a remote LP.
msg_t * get_msg_from_slab(struct lp_struct *lp)
Get a buffer to keep a message.
outgoing_t outgoing_buffer
Buffer used by KLTs for buffering outgoing messages during the execution of an event.
GID_t gid
Global ID of the LP.
short unsigned int state
Current execution state of the LP.
void msg_hdr_release(msg_hdr_t *msg)
Release a message header.
void communication_fini(void)
Finalize the communication subsystem.
void insert_bottom_half(msg_t *msg)
void send_antimessages(struct lp_struct *lp, simtime_t after_simtime)
Send all antimessages for a certain LP.
unsigned int size
How many events is this currently keeping.
Message envelope definition. This is used to handle the output queue and stores information needed to...
msg_t ** outgoing_msgs
Resizable array of message pointers.
simtime_t * min_in_transit
Smallest timestamp of events kept here.
void communication_init(void)
Initialize the communication subsystem.
unsigned int n_prc_tot
Total number of logical processes running in the simulation.
void hdr_to_msg(msg_hdr_t *hdr, msg_t *msg)
convert a message header into a message
void inter_kernel_comm_init(void)
Initialize inter-kernel communication.
unsigned int worker_thread
ID of the worker thread towards which the LP is bound.
msg_hdr_t * get_msg_hdr_from_slab(struct lp_struct *lp)
Get a buffer to keep a message header.
#define unlikely(exp)
Optimize the branch as likely not taken.
void send_outgoing_msgs(struct lp_struct *lp)
Send all pending outgoing messages.
unsigned int kid
Identifier of the local kernel.