Browse Source

Add taskIdListSort() support.

master
Hanhui 6 years ago
parent
commit
248a898355
  1. 1
      target/h/taskLibCommon.h
  2. 4
      target/h/version.h
  3. 35
      target/src/taskLib.c

1
target/h/taskLibCommon.h

@ -122,6 +122,7 @@ STATUS taskUnsafe(void);
STATUS taskUndelay(int tid);
STATUS taskCpuAffinitySet(int tid, cpuset_t newAffinity);
STATUS taskCpuAffinityGet(int tid, cpuset_t* pAffinity);
void taskIdListSort(TASK_ID idList[], int nTasks);
#ifdef __cplusplus
}

4
target/h/version.h

@ -35,7 +35,7 @@
#define _LIB_VXWORKS_MAJOR 0
#define _LIB_VXWORKS_MINOR 3
#define _LIB_VXWORKS_MAINT 4
#define _LIB_VXWORKS_MAINT 5
/* there is now a space between the runtime name, and the version */
@ -45,7 +45,7 @@
/* VxWorks compatibility layer */
/* 0.1.1 add cpu affinity */
#define LIB_VXWORKS_VERSION "SylixOS Compatibility Pack 0.3.4"
#define LIB_VXWORKS_VERSION "SylixOS Compatibility Pack 0.3.5"
#ifdef __cplusplus
extern "C" {

35
target/src/taskLib.c

@ -1134,6 +1134,41 @@ STATUS taskCpuAffinityGet(int tid, cpuset_t* pAffinity)
return (OK);
}
/*
* sort the ID list by priority
*/
void taskIdListSort (TASK_ID idList[], int nTasks)
{
FAST TASK_ID tid; /* temp variable to store task ID */
int prevPri; /* previous priority */
int curPri; /* current priority */
FAST TASK_ID *pCurId; /* current task ID */
BOOL change = TRUE; /* variable to control while loop */
FAST TASK_ID *pEndId = &idList[nTasks]; /* last task ID */
if (nTasks == 0) {
return;
}
while (change) {
change = FALSE;
/* Ignore bad taskId's, taskShow() will ignore them */
taskPriorityGet(idList[0], &prevPri);
for (pCurId = &idList[1]; pCurId < pEndId; ++pCurId, prevPri = curPri) {
taskPriorityGet(*pCurId, &curPri);
if (prevPri > curPri) {
tid = *pCurId;
*pCurId = *(pCurId - 1);
*(pCurId - 1) = tid;
change = TRUE;
}
}
}
}
/*
* end
*/

Loading…
Cancel
Save