📄 tcce.c
字号:
/*************************************************************************/
/* */
/* Copyright (c) 1993-1996 Accelerated Technology, Inc. */
/* */
/* PROPRIETARY RIGHTS of Accelerated Technology are involved in the */
/* subject matter of this material. All manufacturing, reproduction, */
/* use, and sales rights pertaining to this subject matter are governed */
/* by the license agreement. The recipient of this software implicitly */
/* accepts the terms of the license. */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* FILE NAME VERSION */
/* */
/* tcce.c PLUS 1.2 */
/* */
/* COMPONENT */
/* */
/* TC - Thread Control */
/* */
/* DESCRIPTION */
/* */
/* This file contains error checking routines for the functions in */
/* the Thread Control component. This permits easy removal of */
/* error checking logic when it is not needed. */
/* */
/* AUTHOR */
/* */
/* William E. Lamie, Accelerated Technology, Inc. */
/* */
/* DATA STRUCTURES */
/* */
/* None */
/* */
/* FUNCTIONS */
/* */
/* TCCE_Create_Task Create a task */
/* TCCE_Create_HISR Create HISR */
/* TCCE_Delete_HISR Delete HISR */
/* TCCE_Delete_Task Delete a task */
/* TCCE_Reset_Task Reset a task */
/* TCCE_Terminate_Task Terminate a task */
/* TCCE_Resume_Service Resume a task service call */
/* TCCE_Suspend_Service Suspend a task service call */
/* TCCE_Relinquish Relinquish task execution */
/* TCCE_Task_Sleep Task sleep request */
/* TCCE_Suspend_Error Check for suspend req error */
/* TCCE_Activate_HISR Activate an HISR */
/* TCCE_Validate_Resume Validates resume requests */
/* */
/* DEPENDENCIES */
/* */
/* tc_extr.h Thread Control functions */
/* */
/* HISTORY */
/* */
/* NAME DATE REMARKS */
/* */
/* W. Lamie 03-01-1993 Created initial version 1.0 */
/* D. Lamie 04-19-1993 Verified version 1.0 */
/* W. Lamie 03-01-1994 Modified logic that checked task */
/* status without protection of */
/* scheduling structures, */
/* resulting in version 1.0a */
/* D. Lamie 03-01-1994 Verified version 1.0a */
/* W. Lamie 03-01-1994 Moved non-core error checking */
/* functions to a supplemental */
/* file, and modified function */
/* interfaces, added validate */
/* resume service, resulting in */
/* version 1.1 */
/* R. Pfaff - */
/* D. Lamie 03-18-1994 Verified version 1.1 */
/* B. Sellew 03-19-1996 Added error checking to */
/* TCCE_Task_Sleep, resulting */
/* in version 1.1+ (spr037) */
/* M.Q. Qian 04-17-1996 updated to version 1.2 */
/* */
/*************************************************************************/
#define NU_SOURCE_FILE
#include "tc_extr.h" /* Thread control functions */
/* Define external inner-component global data references. */
extern TC_TCB *TCD_Execute_Task;
extern VOID *TCD_Current_Thread;
/*************************************************************************/
/* */
/* FUNCTION */
/* */
/* TCCE_Create_Task */
/* */
/* DESCRIPTION */
/* */
/* This function performs error checking on the parameters supplied */
/* to the create task function. */
/* */
/* AUTHOR */
/* */
/* William E. Lamie, Accelerated Technology, Inc. */
/* */
/* CALLED BY */
/* */
/* Application */
/* */
/* CALLS */
/* */
/* TCC_Create_Task Actual create task function */
/* */
/* INPUTS */
/* */
/* task_ptr Task control block pointer */
/* name Task name */
/* task_entry Entry function of the task */
/* argc Optional task parameter */
/* argv Optional task parameter */
/* stack_address Pointer to start of stack */
/* stack_size Size of task stack in bytes */
/* priority Task priority */
/* time_slice Task time slice */
/* preempt Task preemptability flag */
/* auto_start Automatic task start */
/* */
/* OUTPUTS */
/* */
/* NU_SUCCESS Successful request */
/* NU_INVALID_TASK Task control block pointer */
/* is NULL */
/* NU_INVALID_ENTRY Task entry function is NULL */
/* NU_INVALID_MEMORY Stack pointer is NULL */
/* NU_INVALID_SIZE Stack size is too small */
/* NU_INVALID_PRIORITY Invalid task priority */
/* NU_INVALID_PREEMPT Invalid preemption selection */
/* NU_INVALID_START Invalid start selection */
/* */
/* HISTORY */
/* */
/* NAME DATE REMARKS */
/* */
/* W. Lamie 03-01-1993 Created initial version 1.0 */
/* D. Lamie 04-19-1993 Verified version 1.0 */
/* W. Lamie 03-01-1994 Modified function interface, */
/* added register optimizations, */
/* resulting in version 1.1 */
/* R. Pfaff - */
/* D. Lamie 03-18-1994 Verified version 1.1 */
/* */
/*************************************************************************/
STATUS TCCE_Create_Task(NU_TASK *task_ptr, CHAR *name,
VOID (*task_entry)(UNSIGNED, VOID *), UNSIGNED argc, VOID *argv,
VOID *stack_address, UNSIGNED stack_size,
OPTION priority, UNSIGNED time_slice,
OPTION preempt, OPTION auto_start)
{
TC_TCB *task; /* Task control block ptr */
STATUS status; /* Completion status */
/* Move input task control block pointer into internal pointer. */
task = (TC_TCB *) task_ptr;
/* Check each parameter. */
if ((task == NU_NULL) || (task -> tc_id == TC_TASK_ID))
/* Invalid task control block pointer. */
status = NU_INVALID_TASK;
else if (task_entry == NU_NULL)
/* Invalid task entry function pointer. */
status = NU_INVALID_ENTRY;
else if (stack_address == NU_NULL)
/* Invalid stack starting address. */
status = NU_INVALID_MEMORY;
else if (stack_size < NU_MIN_STACK_SIZE)
/* Invalid stack size. */
status = NU_INVALID_SIZE;
else if (((INT) priority) >= TC_PRIORITIES)
/* Invalid task priority. */
status = NU_INVALID_PRIORITY;
else if ((preempt != NU_PREEMPT) && (preempt != NU_NO_PREEMPT))
/* Invalid preemption. */
status = NU_INVALID_PREEMPT;
else if ((auto_start != NU_START) && (auto_start != NU_NO_START))
/* Invalid start selection. */
status = NU_INVALID_START;
else
/* Call the actual function to create a task. All the parameters
appear to be correct. */
status = TCC_Create_Task(task_ptr, name, task_entry, argc, argv,
stack_address, stack_size, priority, time_slice, preempt, auto_start);
/* Return completion status. */
return(status);
}
/*************************************************************************/
/* */
/* FUNCTION */
/* */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -