📄 tcse.c
字号:
/*************************************************************************//* *//* Copyright Mentor Graphics Corporation 2002 *//* All Rights Reserved. *//* *//* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS *//* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS *//* SUBJECT TO LICENSE TERMS. *//* *//*************************************************************************//*************************************************************************//* *//* FILE NAME VERSION *//* *//* tcse.c Nucleus PLUS 1.14 *//* *//* COMPONENT *//* *//* TC - Thread Control *//* *//* DESCRIPTION *//* *//* This file contains error checking routines for the supplemental *//* functions in the Thread Control component. This permits easy *//* removal of error checking logic when it is not needed. *//* *//* DATA STRUCTURES *//* *//* None *//* *//* FUNCTIONS *//* *//* TCSE_Change_Priority Change task's priority *//* TCSE_Change_Preemption Change task's preemption *//* TCSE_Change_Time_Slice Change task's time slice *//* TCSE_Control_Signals Enable and disable signals *//* TCSE_Receive_Signals Receive current signals *//* TCSE_Register_Signal_Handler Register a signal handler *//* TCSE_Send_Signals Send signals to a task *//* TCSE_Activate_HISR Activate an HISR *//* *//* DEPENDENCIES *//* *//* tc_extr.h Thread Control functions *//* *//* HISTORY *//* *//* DATE REMARKS *//* *//* 03-01-1994 Created initial version 1.1 from *//* routines originally in core *//* error checking file *//* *//* 03-18-1994 Verified version 1.1 *//* 04-17-1996 updated to version 1.2 *//* 03-17-1997 Protected Send Signals service *//* from NULL Control Block pointers *//* creating 1.2a. (SPR220) *//* 03-24-1998 Released version 1.3. *//* 04-17-2002 Released version 1.13m *//* 11-07-2002 Released version 1.14 *//*************************************************************************/#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 *//* *//* TCSE_Change_Priority *//* *//* DESCRIPTION *//* *//* This function performs error checking for the change priority *//* service. If an error is detected, this service is ignored and *//* the requested priority is returned. *//* *//* CALLED BY *//* *//* Application *//* *//* CALLS *//* *//* TCS_Change_Priority Actual change priority *//* *//* INPUTS *//* *//* task_ptr Task control block pointer *//* new_priority New priority for task *//* *//* OUTPUTS *//* *//* old_priority Original task priority *//* *//* HISTORY *//* *//* DATE REMARKS *//* *//* 03-01-1993 Created initial version 1.0 *//* 04-19-1993 Verified version 1.0 *//* 03-01-1994 Changed function interface, *//* resulting in version 1.1 *//* *//* 03-18-1994 Verified version 1.1 *//* *//*************************************************************************/OPTION TCSE_Change_Priority(NU_TASK *task_ptr, OPTION new_priority){TC_TCB *task; /* Task control block ptr */OPTION old_priority; /* Previous priority of task */ /* Move input task pointer into internal task pointer. */ task = (TC_TCB *) task_ptr; /* Determine if the task pointer is valid. */ if (task -> tc_id == TC_TASK_ID) /* Nothing seems to be wrong, change the priority as specified. */ old_priority = TCS_Change_Priority(task_ptr, new_priority); else /* Copy the new priority into the old priority. */ old_priority = new_priority; /* Return the previous priority. */ return(old_priority);}/*************************************************************************//* *//* FUNCTION *//* *//* TCSE_Change_Preemption *//* *//* DESCRIPTION *//* *//* This function performs error checking on the change preemption *//* service. If the current thread is not a task thread, this *//* request is ignored. *//* *//* CALLED BY *//* *//* Application *//* *//* CALLS *//* *//* TCS_Change_Preemption Change the preemption posture*//* of the calling task *//* *//* INPUTS *//* *//* preempt Preempt selection parameter *//* *//* OUTPUTS *//* *//* old_preempt Original preempt value *//* *//* HISTORY *//* *//* DATE REMARKS *//* *//* 03-01-1993 Created initial version 1.0 *//* 04-19-1993 Verified version 1.0 *//* *//*************************************************************************/OPTION TCSE_Change_Preemption(OPTION preempt){TC_TCB *task; /* Pointer to task */OPTION old_preempt; /* Pickup the current thread and place it in the task pointer. */ task = (TC_TCB *) TCD_Current_Thread; /* Determine if the current thread is really a task thread. */ if (task -> tc_id == TC_TASK_ID) /* Yes, change the preemption posture. */ old_preempt = TCS_Change_Preemption(preempt); else /* Return the original request. */ old_preempt = preempt; /* Return the previous preemption posture. */ return(old_preempt);}/*************************************************************************//* *//* FUNCTION *//* *//* TCSE_Change_Time_Slice *//* *//* DESCRIPTION *//* *//* This function performs error checking on the change time slice *//* service. If the specified task pointer is invalid, this *//* request is ignored. *//* *//* CALLED BY *//* *//* Application *//* *//* CALLS *//* *//* TCS_Change_Time_Slice Change the time slice of the *//* specified task *//* *//* INPUTS *//* *//* task_ptr Task control block pointer *//* time_slice New time slice value *//* *//* OUTPUTS *//* *//* old_time_slice Old time slice value *//* *//* HISTORY *//* *//* DATE REMARKS *//* *//* 03-01-1993 Created initial version 1.0 *//* 04-19-1993 Verified version 1.0 *//* 03-01-1994 Changed function interface, *//* resulting in version 1.1 *//* *//* 03-18-1994 Verified version 1.1 *//* *//*************************************************************************/UNSIGNED TCSE_Change_Time_Slice(NU_TASK *task_ptr, UNSIGNED time_slice){TC_TCB *task; /* Task control block ptr */UNSIGNED old_time_slice; /* Old time slice value */ /* Move input task pointer into internal pointer. */ task = (TC_TCB *) task_ptr; /* Determine if the task pointer is valid. */ if (task -> tc_id == TC_TASK_ID) /* Yes, change the time slice. */ old_time_slice = TCS_Change_Time_Slice(task_ptr, time_slice); else /* Return the current request. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -