--- In [email protected], "John Matthews" <jm5...@...> wrote:
>
> --- In [email protected], Ravi Mishra <ravicse04@> wrote:
> >
> > Please help me and provide your suggetion for finding the cause of crash
> > dump.
>
> Suggestions:
4. Your MacCommon type appears to contain 2 arrays, both indexed by the
macDflow - congestionCounter[] and congestionTimerInstance[]. This implies to
me that it might be better to have a single array of structures, where the
structure type is:
typedef struct
{
int counter;
TimerInstance *timer;
} Congestion;
5. Your code is made more difficult to understand (and hence maintain/debug) by
the length of the lines. You should use pointers - combined with the typedef in
(4) (and a few other bits and pieces) and the code becomes a lot more readable:
void macHandle_CongestionIndication(
VTASK *vtask,
AISUE_PRIMSAISUE_tnl_congestion_ind *congInd)
{
VARIABLE_STR *var = (VARIABLE_STR*) vtask->var;
MacCommon *mac = &var->mac;
Congestion *cong; // new
if (mac->stepsOfCongestionCounter == 0)
{
return;
}
cong = &mac->congestion[macDflow]; // new
switch (congInd->congestionStatus)
{
case no_congestion_AIS_IEsAIS_TnlCongestionStatus:
if (cong->counter > 0)
{
if (cong->timer)
{
timerStopInst(cong->timer);
cong->timer = NULL;
}
cong->counter--;
if (cong->counter > 0)
{
cong->timer = timerStartInst_ms(
vtask,
MAC_CONG_CTRL,
mac->congestionTimerDuration,
(void*)congInd->macDflow);
}
}
break;
case delay_build_up_AIS_IEsAIS_TnlCongestionStatus:
case frame_loss_AIS_IEsAIS_TnlCongestionStatus:
if (cong->counter < mac->stepsOfCongestionCounter)
{
if (cong->counter > 0)
// { missing?
if (cong->timer)
{
timerStopInst(cong->timer);
cong->timer = NULL;
}
cong->counter++;
// Might 'lose' timer here if counter == 0.
cong->timer = timerStartInst_ms(
vtask,
MAC_CONG_CTRL,
mac->congestionTimerDuration,
(void*)congInd->macDflow);
// } missing?
}
break;
default:
Printf("ERR_FATAL\n");
break;
}
}