3 struct realtime
* realtime_Init(int pid
, long period_sec
, long period_nsec
, long running_time_sec
, long running_time_nsec
){
4 struct realtime
*this = (struct realtime
*) g_malloc(sizeof(struct realtime
));
5 realtimeContext_Init(&this->_fsm
, this);
7 this->period_sec
=period_sec
;
8 this->period_nsec
=period_nsec
;
9 this->running_time_sec
= running_time_sec
;
10 this->running_time_nsec
= running_time_nsec
;
11 this->schedin_ts_sec
=0;//needed for first event
12 this->schedin_ts_nsec
=0;
15 void realtime_destroyfsm(struct realtime
*this){
16 //remove fsm from fsm_list
20 void realtime_warning(struct realtime
*this, long ts_sec
, long ts_nsec
){
21 printf("WARNING: real-time process, pid %d was scheduled in after tolerable period @ %ld.%09ld.\n", this->pid
, ts_sec
, ts_nsec
);
23 void realtime_report_insufficient_scheduling_time(struct realtime
*this, long ts_sec
, long ts_nsec
){
24 printf("WARNING: real-time process, pid %d was scheduled out early @%ld.%09ld.\n", this->pid
, ts_sec
, ts_nsec
);
26 int latency(struct realtime
*this, long ts_sec
, long ts_nsec
){
27 //2 successive schedin are seperated by more than period
28 long delta_sec
= ts_sec
- this->schedin_ts_sec
;
29 long delta_nsec
= ts_nsec
- this->schedin_ts_nsec
;
30 if(delta_sec
< this->period_sec
)
32 else if(delta_sec
== this->period_sec
)
33 if(delta_nsec
< this->period_nsec
)
37 int running_enough(struct realtime
*this, long ts_sec
, long ts_nsec
){
38 if(ts_sec
- this->schedin_ts_sec
> this->running_time_sec
)
40 else if(ts_sec
- this->schedin_ts_sec
== this->running_time_sec
)
41 if(ts_nsec
- this->running_time_nsec
> this->running_time_nsec
)
45 void realtime_save_ts(struct realtime
*this, long ts_sec
, long ts_nsec
){
46 this->schedin_ts_sec
= ts_sec
;
47 this->schedin_ts_nsec
= ts_nsec
;
This page took 0.036674 seconds and 5 git commands to generate.