📄 evc.c
字号:
/*************************************************************************/
/* */
/* Copyright (c) 1993-1998 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 */
/* */
/* evc.c PLUS 1.3 */
/* */
/* COMPONENT */
/* */
/* EV - Event Group Management */
/* */
/* DESCRIPTION */
/* */
/* This file contains the core routines for the Event Group */
/* Management component. */
/* */
/* AUTHOR */
/* */
/* William E. Lamie, Accelerated Technology, Inc. */
/* */
/* 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 */
/* */
/* NAME DATE REMARKS */
/* */
/* W. Lamie 03-01-1993 Created initial version 1.0 */
/* D. Lamie 04-19-1993 Verified version 1.0 */
/* W. Lamie 08-09-1993 Corrected pointer retrieval */
/* loop, resulting in version 1.0a */
/* D. Lamie 08-09-1993 Verified version 1.0a */
/* W. Lamie 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 */
/* R. Pfaff - */
/* D. Lamie 03-18-1994 Verified version 1.1 */
/* M.Q. Qian 04-17-1996 updated to version 1.2 */
/* M. Trippi 10-28-1997 Corrected a problem where */
/* NU_Set_Events may not resume all */
/* waiting tasks. (SPR190) Created */
/* version 1.2a. */
/* M. Trippi 03-24-1998 Released version 1.3. */
/* */
/*************************************************************************/
#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 */
/* 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. */
/* */
/* AUTHOR */
/* */
/* William E. Lamie, Accelerated Technology, Inc. */
/* */
/* 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 */
/* */
/* 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 Changed function interfaces to */
/* match those in prototype, */
/* added register options, */
/* resulting in version 1.1 */
/* R. Pfaff - */
/* D. Lamie 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 */
/* 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++;
/* Release protection against access to the list of created event
groups. */
TCT_Unprotect();
/* 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. */
/* */
/* AUTHOR */
/* */
/* William E. Lamie, Accelerated Technology, Inc. */
/* */
/* 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 */
/* */
/* W. Lamie 03-01-1993 Created initial version 1.0 */
/* D. Lamie 04-19-1993 Verified version 1.0 */
/* W. Lamie 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 */
/* R. Pfaff - */
/* D. Lamie 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 */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -