Commit e92caaf5 authored by claes's avatar claes

All io processes and thread supervises all other with halt action

parent db5dc0fa
......@@ -14,6 +14,7 @@
#include "pwr_class.h"
#include "pwrb_c_cyclesup.h"
#include "co_time.h"
#include "co_cdh.h"
#include "rt_gdh.h"
#include "rt_gdh_msg.h"
#include "rt_csup_msg.h"
......@@ -34,6 +35,7 @@ csup_Init (
{
lst_sEntry *lh;
pwr_tObjid cid;
pwr_tObjid pid;
csup_sObject *cp;
int tv_sec;
pwr_tFloat32 max_delay;
......@@ -47,9 +49,9 @@ csup_Init (
lst_Init(NULL, lh, NULL);
for (
*sts = gdh_GetChild(tid, &cid);
*sts = gdh_GetClassList(pwr_cClass_CycleSup, &cid);
ODD(*sts);
*sts = gdh_GetNextSibling(cid, &cid)
*sts = gdh_GetNextObject(cid, &cid)
) {
cp = calloc(1, sizeof(*cp));
cp->aref.Objid = cid;
......@@ -57,12 +59,14 @@ csup_Init (
if (EVEN(*sts))
goto error;
if ( ODD(gdh_GetParent( cid, &pid)) && cdh_ObjidIsEqual( pid, tid))
cp->is_owner = 1;
lst_InsertSucc(NULL, lh, &cp->le, cp);
max_delay = cp->o->MaxDelay;
cp->o->DelayLimit.tv_sec = tv_sec = (int)max_delay;
cp->o->DelayLimit.tv_nsec = (int)((max_delay - (float)tv_sec + FLT_EPSILON) * 1.0e9);
printf("maxdelay: %f, tv_sec: %d, tv_nsec: %d\n", cp->o->MaxDelay,
cp->o->DelayLimit.tv_sec, cp->o->DelayLimit.tv_nsec);
// printf("maxdelay: %f, tv_sec: %d, tv_nsec: %d\n", cp->o->MaxDelay, cp->o->DelayLimit.tv_sec, cp->o->DelayLimit.tv_nsec);
errh_Info("maxdelay: %f, tv_sec: %d, tv_nsec: %d", cp->o->MaxDelay,
cp->o->DelayLimit.tv_sec, cp->o->DelayLimit.tv_nsec);
}
......@@ -98,40 +102,53 @@ csup_Exec (
while ((cp = lst_Succ(NULL, lh, &lh)) != NULL) {
pwr_sClass_CycleSup *o = cp->o;
if (time_Dcomp(&o->NextLimit, NULL) > 0) {
if (time_Dcomp(stop, &o->NextLimit) > 0) {
if (!o->Delayed) {
o->DelayedTime = *now;
o->Delayed = TRUE;
o->Timely = FALSE;
if ( cp->is_owner) {
if (time_Dcomp(&o->NextLimit, NULL) > 0) {
if (time_Dcomp(stop, &o->NextLimit) > 0) {
if (!o->Delayed) {
o->DelayedTime = *now;
o->Delayed = TRUE;
o->Timely = FALSE;
}
o->DelayCount++;
o->LastDelay = *now;
action = MAX(action, o->DelayAction);
} else if (!o->Timely) {
o->Timely = TRUE;
o->TimelyTime = *now;
}
o->DelayCount++;
o->LastDelay = *now;
action = MAX(action, o->DelayAction);
} else if (!o->Timely) {
o->Timely = TRUE;
o->TimelyTime = *now;
}
}
if ((o->DelayLimit.tv_sec & 1<<31) != (o->DelayLimit.tv_nsec & 1<<31)) {
printf("DelayLimit.tv_sec: %d, DelayLimit.tv_nsec: %d\n", o->DelayLimit.tv_sec, o->DelayLimit.tv_nsec);
errh_Info("DelayLimit.tv_sec: %d, DelayLimit.tv_nsec: %d", o->DelayLimit.tv_sec, o->DelayLimit.tv_nsec);
}
if ((next_start->tv_sec & 1<<31) != (next_start->tv_nsec & 1<<31)) {
printf("next_start->tv_sec: %d, next_start->tv_nsec: %d\n", next_start->tv_sec, next_start->tv_nsec);
errh_Info("next_start->tv_sec: %d, next_start->tv_nsec: %d", next_start->tv_sec, next_start->tv_nsec);
}
time_Dadd(&nextLimit, next_start, &o->DelayLimit);
if ((o->DelayLimit.tv_sec & 1<<31) != (o->DelayLimit.tv_nsec & 1<<31)) {
// printf("DelayLimit.tv_sec: %d, DelayLimit.tv_nsec: %d\n", o->DelayLimit.tv_sec, o->DelayLimit.tv_nsec);
errh_Info("DelayLimit.tv_sec: %d, DelayLimit.tv_nsec: %d", o->DelayLimit.tv_sec, o->DelayLimit.tv_nsec);
}
if ((next_start->tv_sec & 1<<31) != (next_start->tv_nsec & 1<<31)) {
// printf("next_start->tv_sec: %d, next_start->tv_nsec: %d\n", next_start->tv_sec, next_start->tv_nsec);
errh_Info("next_start->tv_sec: %d, next_start->tv_nsec: %d", next_start->tv_sec, next_start->tv_nsec);
}
time_Dadd(&nextLimit, next_start, &o->DelayLimit);
/* If we update the tv_nsec field first it is
possible that emon will detect a slip even if it is not. */
/* If we update the tv_nsec field first it is
possible that emon will detect a slip even if it is not. */
o->NextLimit.tv_sec = nextLimit.tv_sec;
o->NextLimit.tv_nsec = nextLimit.tv_nsec;
o->NextLimit.tv_sec = nextLimit.tv_sec;
o->NextLimit.tv_nsec = nextLimit.tv_nsec;
o->CycleCount++;
o->CycleCount++;
}
else {
/* Not owner, check stall delay */
if ( o->DelayAction == 2) {
if (time_Dcomp(&o->NextLimit, NULL) > 0 &&
time_Dcomp(stop, &o->NextLimit) > 0) {
o->DelayCount++;
o->LastDelay = *now;
action = MAX(action, o->DelayAction);
}
}
}
}
return action;
}
......
......@@ -17,6 +17,7 @@ typedef struct {
pwr_sClass_CycleSup *o;
pwr_sAttrRef aref;
pwr_tDlid dlid;
int is_owner;
} csup_sObject;
void csup_Exit(pwr_tStatus*, lst_sEntry*);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment