📄 evc.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 *//* *//* evc.c Nucleus PLUS 1.14 *//* *//* COMPONENT *//* *//* EV - Event Group Management *//* *//* DESCRIPTION *//* *//* This file contains the core routines for the Event Group *//* Management component. *//* *//* DATA STRUCTURES *//* *//* None *//* *//* FUNCTIONS *//* *//* EVC_Create_Event_Group Create an event group *//* EVC_Delete_Event_Group Delete an event group *//* EVC_Set_Events Set events in a group *//* EVC_Retrieve_Events Retrieve events from a group *//* EVC_Cleanup Cleanup on timeout or a *//* terminate condition *//* *//* DEPENDENCIES *//* *//* cs_extr.h Common Service functions *//* tc_extr.h Thread Control functions *//* ev_extr.h Event Group functions *//* hi_extr.h History functions *//* *//* HISTORY *//* *//* DATE REMARKS *//* *//* 03-01-1993 Created initial version 1.0 *//* 04-19-1993 Verified version 1.0 *//* 08-09-1993 Corrected pointer retrieval *//* loop, resulting in version 1.0a *//* 08-09-1993 Verified version 1.0a *//* 03-01-1994 Moved non-core functions into *//* supplemental files, changed *//* function interfaces to match *//* those in prototype, added *//* register options, changed *//* protection logic to reduce *//* overhead, resulting in *//* version 1.1 *//* *//* 03-18-1994 Verified version 1.1 *//* 04-17-1996 updated to version 1.2 *//* 10-28-1997 Corrected a problem where *//* NU_Set_Events may not resume all *//* waiting tasks. (SPR190) Created *//* version 1.2a. *//* 03-24-1998 Released version 1.3 *//* 03-26-1999 Released 1.11m (new release *//* numbering scheme) *//* 04-17-2002 Released version 1.13m *//* 11-07-2002 Released version 1.14 *//*************************************************************************/#define NU_SOURCE_FILE#include "cs_extr.h" /* Common service functions */#include "tc_extr.h" /* Thread control functions */#include "ev_extr.h" /* Event Group functions */#include "hi_extr.h" /* History functions */#include "profiler.h" /* ProView interface *//* Define external inner-component global data references. */extern CS_NODE *EVD_Created_Event_Groups_List;extern UNSIGNED EVD_Total_Event_Groups;extern TC_PROTECT EVD_List_Protect;/* Define internal component function prototypes. */VOID EVC_Cleanup(VOID *information);/*************************************************************************//* *//* FUNCTION *//* *//* EVC_Create_Event_Group *//* *//* DESCRIPTION *//* *//* This function creates an event group and then places it on the *//* list of created event groups. *//* *//* CALLED BY *//* *//* Application *//* EVCE_Create_Event_Group Error checking shell *//* *//* CALLS *//* *//* CSC_Place_On_List Add node to linked-list *//* [HIC_Make_History_Entry] Make entry in history log *//* [TCT_Check_Stack] Stack checking function *//* TCT_Protect Data structure protect *//* TCT_Unprotect Un-protect data structure *//* *//* INPUTS *//* *//* event_group_ptr Event Group control block ptr*//* name Event Group name *//* *//* OUTPUTS *//* *//* NU_SUCCESS *//* *//* HISTORY *//* *//* DATE REMARKS *//* *//* 03-01-1993 Created initial version 1.0 *//* 04-19-1993 Verified version 1.0 *//* 03-01-1994 Changed function interfaces to *//* match those in prototype, *//* added register options, *//* resulting in version 1.1 *//* *//* 03-18-1994 Verified version 1.1 *//* *//*************************************************************************/STATUS EVC_Create_Event_Group(NU_EVENT_GROUP *event_group_ptr, CHAR *name){R1 EV_GCB *event_group; /* Event control block ptr */INT i; /* Working index variable */NU_SUPERV_USER_VARIABLES /* Switch to supervisor mode */ NU_SUPERVISOR_MODE(); /* Move input event group pointer into internal pointer. */ event_group = (EV_GCB *) event_group_ptr;#ifdef NU_ENABLE_STACK_CHECK /* Call stack checking function to check for an overflow condition. */ TCT_Check_Stack();#endif#ifdef NU_ENABLE_HISTORY /* Make an entry that corresponds to this function in the system history log. */ HIC_Make_History_Entry(NU_CREATE_EVENT_GROUP_ID, (UNSIGNED) event_group, (UNSIGNED) name, (UNSIGNED) 0);#endif /* First, clear the event group ID just in case it is an old Event Group Control Block. */ event_group -> ev_id = 0; /* Fill in the event group name. */ for (i = 0; i < NU_MAX_NAME; i++) event_group -> ev_name[i] = name[i]; /* Clear the flags of the event group. */ event_group -> ev_current_events = 0; /* Clear the suspension list pointer. */ event_group -> ev_suspension_list = NU_NULL; /* Clear the number of tasks waiting on the event_group counter. */ event_group -> ev_tasks_waiting = 0; /* Initialize link pointers. */ event_group -> ev_created.cs_previous = NU_NULL; event_group -> ev_created.cs_next = NU_NULL; /* Protect against access to the list of created event_groups. */ TCT_Protect(&EVD_List_Protect); /* At this point the event_group is completely built. The ID can now be set and it can be linked into the created event_group list. */ event_group -> ev_id = EV_EVENT_ID; /* Link the event group into the list of created event groups and increment the total number of event groups in the system. */ CSC_Place_On_List(&EVD_Created_Event_Groups_List, &(event_group -> ev_created)); EVD_Total_Event_Groups++;#ifdef INCLUDE_PROVIEW _RTProf_DumpEventGroup(RT_PROF_CREATE_EVENT_GROUP,event_group, RT_PROF_OK);#endif /*INCLUDE_PROVIEW*/ /* Release protection against access to the list of created event groups. */ TCT_Unprotect(); /* Return to user mode */ NU_USER_MODE(); /* Return successful completion. */ return(NU_SUCCESS);}/*************************************************************************//* *//* FUNCTION *//* *//* EVC_Delete_Event_Group *//* *//* DESCRIPTION *//* *//* This function deletes an event group and removes it from the *//* list of created event groups. All tasks suspended on the *//* event group are resumed. Note that this function does not *//* free the memory associated with the event group control block. *//* *//* CALLED BY *//* *//* Application *//* EVCE_Delete_Event_Group Error checking shell *//* *//* CALLS *//* *//* CSC_Remove_From_List Remove node from list *//* [HIC_Make_History_Entry] Make entry in history log *//* TCC_Resume_Task Resume a suspended task *//* [TCT_Check_Stack] Stack checking function *//* TCT_Control_To_System Transfer control to system *//* TCT_Protect Protect created list *//* TCT_Set_Current_Protect Modify current protection *//* TCT_System_Protect Setup system protection *//* TCT_System_Unprotect Release system protection *//* TCT_Unprotect Release protection *//* *//* INPUTS *//* *//* event_group_ptr Event Group control block ptr*//* *//* OUTPUTS *//* *//* NU_SUCCESS *//* *//* HISTORY *//* *//* NAME DATE REMARKS *//* *//* 03-01-1993 Created initial version 1.0 *//* 04-19-1993 Verified version 1.0 *//* 03-01-1994 Changed function interfaces to *//* match those in prototype, *//* added register options, changed *//* protection logic to reduce *//* overhead, resulting in *//* version 1.1 *//* *//* 03-18-1994 Verified version 1.1 *//* *//*************************************************************************/STATUS EVC_Delete_Event_Group(NU_EVENT_GROUP *event_group_ptr){R1 EV_GCB *event_group; /* Event control block ptr */EV_SUSPEND *suspend_ptr; /* Suspend block pointer */EV_SUSPEND *next_ptr; /* Next suspend block */STATUS preempt; /* Status for resume call */NU_SUPERV_USER_VARIABLES /* Switch to supervisor mode */ NU_SUPERVISOR_MODE(); /* Move input event group pointer into internal pointer. */ event_group = (EV_GCB *) event_group_ptr;#ifdef NU_ENABLE_STACK_CHECK
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -