diff --git a/include/vxworks/taskInfo.h b/include/vxworks/taskInfo.h index 61315d5..27b3cc6 100644 --- a/include/vxworks/taskInfo.h +++ b/include/vxworks/taskInfo.h @@ -50,6 +50,8 @@ TASK_ID taskNameToId(const char *name); TASK_ID taskIdDefault(TASK_ID task_id); +BOOL taskIsSafe(TASK_ID task_id); + BOOL taskIsReady(TASK_ID task_id); BOOL taskIsSuspended (TASK_ID task_id); diff --git a/vxworks/taskLib.c b/vxworks/taskLib.c index f6253b2..7dd52ae 100644 --- a/vxworks/taskLib.c +++ b/vxworks/taskLib.c @@ -595,7 +595,7 @@ STATUS taskSafe(void) } pthread_mutex_lock(¤t->safelock); - + current->safeCnt = 1; return OK; } @@ -615,11 +615,24 @@ STATUS taskUnsafe(void) return ERROR; } + current->safeCnt = 0; pthread_mutex_unlock(¤t->safelock); return OK; } +BOOL taskIsSafe(TASK_ID tid) +{ + struct wind_task *task = find_wind_task(tid); + + if (task == NULL) { + errno = S_objLib_OBJ_ID_ERROR; + return ERROR; + } + + return (task->safeCnt > 0); +} + STATUS taskIdVerify(TASK_ID tid) { struct wind_task *task = find_wind_task(tid); diff --git a/vxworks/taskLib.h b/vxworks/taskLib.h index 299d059..f743270 100644 --- a/vxworks/taskLib.h +++ b/vxworks/taskLib.h @@ -42,6 +42,7 @@ struct wind_task_args { struct wind_task { pthread_mutex_t safelock; + int safeCnt; sem_t barrier; struct WIND_TCB *tcb;