⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 evc.c

📁 nucleus 2006 source code
💻 C
📖 第 1 页 / 共 3 页
字号:
/*************************************************************************/
/*                                                                       */
/*               Copyright Mentor Graphics Corporation 2004              */
/*                         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.15 */
/*                                                                       */
/* 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            */
/*                                                                       */
/*************************************************************************/
#define         NU_SOURCE_FILE


#include        "plus/inc/cs_extr.h"        /* Common service functions  */
#include        "plus/inc/tc_extr.h"        /* Thread control functions  */
#include        "plus/inc/ev_extr.h"        /* Event Group functions     */
#include        "plus/inc/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.                                    */
/*                                                                       */
/* 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                                                       */
/*                                                                       */
/*************************************************************************/
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 NU_PROFILE_PLUS

    PRF_PLUS_EVC_CREATE_EVENT_GROUP_0

#endif /* NU_PROFILE_PLUS */

    /* 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                                                       */
/*                                                                       */
/*************************************************************************/
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

    /* 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_DELETE_EVENT_GROUP_ID, (UNSIGNED) event_group,
                                        (UNSIGNED) 0, (UNSIGNED) 0);

#endif

    /* Protect against simultaneous access to the event group.  */
    TCT_System_Protect();

#ifdef NU_PROFILE_PLUS

    PRF_PLUS_EVC_DELETE_EVENT_GROUP_0

#endif /* NU_PROFILE_PLUS */

    /* Clear the event group ID.  */
    event_group -> ev_id =  0;

    /* Release protection.  */
    TCT_Unprotect();

    /* Protect against access to the list of created event groups.  */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -