CSim documentation

CSim documentation

Home

Creating events

CsEvent *cs_event_new(int (*event_routine)(void *user_data))

Creates a new event. The returned CsEvent structure is used in subsequent schedulings. The function event_routine will be executed the event occurs. The event also includes a count of how many times it was executed.

event_routine: Pointer to the function to be called when the event occurs

Returns:

The new event

Scheduling events

int cs_event_schedule(CsEvent *event, simtime_t time, void *user_data)

Schedules an event for execution at a later time. The event must have been previously created with a cs_event_new call. If the event is scheduled in the past, a warning message is issued. For best performance, schedule events in the order in which they occur.

event: The event to schedule
time: The time at which the event should occur
user_data: Data to be passed on to the event_routine

Returns:

0 if scheduled in the future, -1 if scheduled in the past(a message is also issued)

Relative scheduling

int cs_event_schedule_relative(CsEvent *event, simtime_t offset, void *user_data)

Same as cs_event_schedule, but the scheduled time is specified as an offet from the current clock time.

event: The event to schedule
offset: Scheduled time as an offset from the current clock time
user_data: Data to be passed on to the event_routine

Returns:

0 if offset is positive, -1 if negative(a message is also issued)
Home