All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-core] xenomai-solo vxWorks: know whether a task is safe or not
@ 2008-09-21 20:34 Niklaus Giger
  2008-09-22 16:17 ` Philippe Gerum
  0 siblings, 1 reply; 5+ messages in thread
From: Niklaus Giger @ 2008-09-21 20:34 UTC (permalink / raw)
  To: xenomai-core

[-- Attachment #1: Type: text/plain, Size: 431 bytes --]

Hi

For various reasons we were forced to examine under vxWorks 5.5 the private
WIND_TCB safeCnt field to determine whether a task was "safe" or not.

With the attached patch I try to add a taskIsSafe procedure to xenomai-solo.
It is probably not free from race condition, as I do not know how to access
a pthread_mutex.

Would such (may be improved) patch find its way into the "official" trunk?

Best regards

-- 
NIklaus Giger


[-- Attachment #2: taskIsSafe.diff --]
[-- Type: text/x-patch, Size: 1369 bytes --]

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(&current->safelock);
-
+	current->safeCnt = 1;
 	return OK;
 }
 
@@ -615,11 +615,24 @@ STATUS taskUnsafe(void)
 		return ERROR;
 	}
 
+	current->safeCnt = 0;
 	pthread_mutex_unlock(&current->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;

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-09-26  8:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-21 20:34 [Xenomai-core] xenomai-solo vxWorks: know whether a task is safe or not Niklaus Giger
2008-09-22 16:17 ` Philippe Gerum
2008-09-22 19:45   ` Niklaus Giger
2008-09-26  8:36     ` Philippe Gerum
2008-09-26  8:37     ` Philippe Gerum

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.