diff options
author | Giovanni Di Sirio <gdisirio@gmail.com> | 2016-02-24 10:28:43 +0000 |
---|---|---|
committer | Giovanni Di Sirio <gdisirio@gmail.com> | 2016-02-24 10:28:43 +0000 |
commit | 5181b1e391f3480d375a484fb55e70fd5586a5d1 (patch) | |
tree | f5a52fd64f69f31c40cc55a404c599d61dd70cd7 /os/common/abstractions/nasa_osal/src/osapi.c | |
parent | 54e8a6c9e2a71902af35b4ec25f087719192c130 (diff) | |
download | ChibiOS-5181b1e391f3480d375a484fb55e70fd5586a5d1.tar.gz ChibiOS-5181b1e391f3480d375a484fb55e70fd5586a5d1.tar.bz2 ChibiOS-5181b1e391f3480d375a484fb55e70fd5586a5d1.zip |
Enhanced registry.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8939 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/common/abstractions/nasa_osal/src/osapi.c')
-rw-r--r-- | os/common/abstractions/nasa_osal/src/osapi.c | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/os/common/abstractions/nasa_osal/src/osapi.c b/os/common/abstractions/nasa_osal/src/osapi.c index c84065c34..367d0f2d4 100644 --- a/os/common/abstractions/nasa_osal/src/osapi.c +++ b/os/common/abstractions/nasa_osal/src/osapi.c @@ -1318,8 +1318,12 @@ int32 OS_TaskInstallDeleteHandler(void *function_pointer) { * @api
*/
int32 OS_TaskDelete(uint32 task_id) {
+ thread_t *tp = (thread_t *)task_id;
- (void)task_id;
+ /* Check for thread validity.*/
+ if (chRegFindThreadByPointer(tp) == NULL) {
+ return OS_ERR_INVALID_ID;
+ }
return OS_ERR_NOT_IMPLEMENTED;
}
@@ -1361,6 +1365,11 @@ int32 OS_TaskSetPriority (uint32 task_id, uint32 new_priority) { tprio_t rt_newprio;
thread_t *tp = (thread_t *)task_id;
+ /* Check for thread validity.*/
+ if (chRegFindThreadByPointer(tp) == NULL) {
+ return OS_ERR_INVALID_ID;
+ }
+
/* Checking priority range.*/
if ((new_priority < MIN_PRIORITY) || (new_priority > MAX_PRIORITY)) {
return OS_ERR_INVALID_PRIORITY;
@@ -1373,8 +1382,6 @@ int32 OS_TaskSetPriority (uint32 task_id, uint32 new_priority) { return OS_SUCCESS;
}
- /* TODO: Check presence in registry.*/
-
chSysLock();
/* Changing priority.*/
@@ -1464,19 +1471,15 @@ int32 OS_TaskGetIdByName (uint32 *task_id, const char *task_name) { return OS_ERR_NAME_TOO_LONG;
}
- /* TODO: Check presence in registry.*/
+ /* Searching in the registry.*/
+ tp = chRegFindThreadByName(task_name);
+ if (tp == NULL) {
+ return OS_ERR_NAME_NOT_FOUND;
+ }
- /* Scanning registry.*/
- tp = chRegFirstThread();
- do {
- if (strcmp(chRegGetThreadNameX(tp), task_name) == 0) {
- *task_id = (uint32)tp;
- return OS_SUCCESS;
- }
- tp = chRegNextThread(tp);
- } while (tp != NULL);
+ *task_id = (uint32)tp;
- return OS_ERR_NAME_NOT_FOUND;
+ return OS_SUCCESS;
}
/**
@@ -1494,13 +1497,16 @@ int32 OS_TaskGetInfo(uint32 task_id, OS_task_prop_t *task_prop) { thread_t *tp = (thread_t *)task_id;
size_t wasize = (size_t)tp - (size_t)tp->stklimit + sizeof (thread_t);
+ /* Check for thread validity.*/
+ if (chRegFindThreadByPointer(tp) == NULL) {
+ return OS_ERR_INVALID_ID;
+ }
+
/* NULL pointer checks.*/
if (task_prop == NULL) {
return OS_INVALID_POINTER;
}
- /* TODO: Check presence in registry.*/
-
strncpy(task_prop->name, tp->name, OS_MAX_API_NAME - 1);
task_prop->creator = (uint32)chSysGetIdleThreadX();
task_prop->stack_size = (uint32)MEM_ALIGN_NEXT(wasize, PORT_STACK_ALIGN);
|