Michaelvys
Newbie level 3
I fixed bug uCOS-III in os_flag.c. This eliminates the exception when used OSFlagPend and OSFlagPost with the same OS_FLAG_GRP in one thread.
I added in the structure OS_FLAG_GRP of the variable Prio and apply it in OSFlagPost, that prevent appear the exception.
oc.h
======================
#if OS_CFG_FLAG_EN > 0u
struct os_flag_grp { /* Event Flag Group */
OS_OBJ_TYPE Type; /* Should be set to OS_EVENT_TYPE_FLAG */
CPU_CHAR *NamePtr;
OS_PEND_LIST PendList; /* List of tasks waiting on event flag group */
OS_FLAGS Flags; /* 8, 16 or 32 bit flags */
CPU_TS TS; /* Timestamp of when last post occurred */
#if OS_CFG_DBG_EN > 0u
OS_OBJ_QTY DbgIx;
#endif
int Prio; /* Revision by Michael Vysotsky correct bug */
};
#endif
======================
os_flag.c
======================
OS_FLAGS OSFlagPend(....)
{
........
break;
#endif
default:
CPU_CRITICAL_EXIT();
*p_err = OS_ERR_OPT_INVALID;
return ((OS_FLAGS)0);
}
p_grp->Prio = pend_data.TCBPtr->Prio; /* Revision by Michael Vysotsky */
OSSched(); /* Find next HPT ready to run */
CPU_CRITICAL_ENTER();
switch (OSTCBCurPtr->PendStatus) {
case OS_STATUS_PEND_OK: /* We got the vent flags */
if (p_ts != (CPU_TS *)0) {
*p_ts = OSTCBCurPtr->TS;
}
*p_err = OS_ERR_NONE;
break;
.....
}
OS_FLAGS OS_FlagPost(......)
{
.......
p_grp->TS = ts;
p_pend_list = &p_grp->PendList;
if((p_pend_data = p_pend_list->HeadPtr)&&(p_grp->Prio != OSTCBCurPtr->Prio)) /* Revision Michael Vysotsky */
p_tcb = p_pend_data->TCBPtr;
while (p_tcb != (OS_TCB *)0) { /* Go through all tasks waiting on event flag(s) */
p_pend_data_next = p_pend_data->NextPtr;
.......
}
I added in the structure OS_FLAG_GRP of the variable Prio and apply it in OSFlagPost, that prevent appear the exception.
oc.h
======================
#if OS_CFG_FLAG_EN > 0u
struct os_flag_grp { /* Event Flag Group */
OS_OBJ_TYPE Type; /* Should be set to OS_EVENT_TYPE_FLAG */
CPU_CHAR *NamePtr;
OS_PEND_LIST PendList; /* List of tasks waiting on event flag group */
OS_FLAGS Flags; /* 8, 16 or 32 bit flags */
CPU_TS TS; /* Timestamp of when last post occurred */
#if OS_CFG_DBG_EN > 0u
OS_OBJ_QTY DbgIx;
#endif
int Prio; /* Revision by Michael Vysotsky correct bug */
};
#endif
======================
os_flag.c
======================
OS_FLAGS OSFlagPend(....)
{
........
break;
#endif
default:
CPU_CRITICAL_EXIT();
*p_err = OS_ERR_OPT_INVALID;
return ((OS_FLAGS)0);
}
p_grp->Prio = pend_data.TCBPtr->Prio; /* Revision by Michael Vysotsky */
OSSched(); /* Find next HPT ready to run */
CPU_CRITICAL_ENTER();
switch (OSTCBCurPtr->PendStatus) {
case OS_STATUS_PEND_OK: /* We got the vent flags */
if (p_ts != (CPU_TS *)0) {
*p_ts = OSTCBCurPtr->TS;
}
*p_err = OS_ERR_NONE;
break;
.....
}
OS_FLAGS OS_FlagPost(......)
{
.......
p_grp->TS = ts;
p_pend_list = &p_grp->PendList;
if((p_pend_data = p_pend_list->HeadPtr)&&(p_grp->Prio != OSTCBCurPtr->Prio)) /* Revision Michael Vysotsky */
p_tcb = p_pend_data->TCBPtr;
while (p_tcb != (OS_TCB *)0) { /* Go through all tasks waiting on event flag(s) */
p_pend_data_next = p_pend_data->NextPtr;
.......
}