Friday, April 1, 2016

OMNeT++/OMNEST priority schedule for the event at the same time

In OMNeT++/OMNEST, sometimes two events may arrive at the same time. However, the OMNeT++/OMNEST can only handle both events in sequence based on the arrival time of each event. If we hope to always handle a event before the other event, we can use the following function to handle this problem.

setSchedulingPriority(short p)

where p is the priority, the smaller number of p has higher priority.
refer to.
https://omnetpp.org/doc/omnetpp/api/classcMessage.html#a205278b4eaf8a54a901537f6e6cfae59


Examples:
cMessage *timer1 = new cMessage("tiemr1");
cMessage *timer2 = new cMessage("tiemr2");

timer1->setSchedulingPriority(1); // lower priority
timer1->setSchedulingPriority(-1); // high priority

send(timer1, Gate);
send(timer2, Gate);