changeset 340:de7141ad907e

OSL: os_GetScheduleCount() and os_DestroyTask() done
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sat, 03 May 2014 00:33:45 +0000
parents 2f88c5b89113
children fcbdb2ae1a47
files gsm-fw/gpf/osl/os_pro_fl.c
diffstat 1 files changed, 35 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/gsm-fw/gpf/osl/os_pro_fl.c	Fri May 02 23:44:12 2014 +0000
+++ b/gsm-fw/gpf/osl/os_pro_fl.c	Sat May 03 00:33:45 2014 +0000
@@ -151,3 +151,38 @@
 	*stackend = (u_char *) task->tc_stack_end;
 	return(OS_OK);
 }
+
+GLOBAL LONG
+os_GetScheduleCount(OS_HANDLE task_handle, int *schedule_count)
+{
+	NU_TASK *task_cb;
+
+	if (task_handle > MaxTasks)
+		return(OS_ERROR);
+	if (!TaskTable[task_handle].Name[0])
+		return(OS_ERROR);
+	if (task_handle == OS_NOTASK)
+		task_cb = (NU_TASK *) TCD_Current_Thread;
+	else
+		task_cb = &TaskTable[task_handle].TaskCB.TCB;
+	*schedule_count = task_cb->tc_scheduled;
+	return(OS_OK);
+}
+
+GLOBAL LONG
+os_DestroyTask(OS_HANDLE Caller, OS_HANDLE TaskHandle)
+{
+	STATUS sts;
+
+	if (NU_Terminate_Task(&TaskTable[TaskHandle].TaskCB.TCB) != NU_SUCCESS)
+		return(OS_ERROR);
+	if (NU_Delete_Task(&TaskTable[TaskHandle].TaskCB.TCB) != NU_SUCCESS)
+		return(OS_ERROR);
+	if (os_DeallocateMemory(Caller, TaskTable[TaskHandle].Stack) != OS_OK)
+		return(OS_ERROR);
+	sts = NU_Obtain_Semaphore(&ProSemCB, NU_SUSPEND);
+	TaskTable[TaskHandle].Name[0] = 0;
+	if (sts == NU_SUCCESS)
+		NU_Release_Semaphore(&ProSemCB);
+	return(OS_OK);
+}