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

📄 pice.c

📁 抢占
💻 C
📖 第 1 页 / 共 2 页
字号:
{

PI_PCB         *pipe;
STATUS          status;


    /* Move input pipe pointer into internal pointer.  */
    pipe =  (PI_PCB *) pipe_ptr;


    /* Determine if there is an error with the pipe pointer.  */
    if (pipe == NU_NULL)
    
        /* Indicate that the pipe pointer is invalid.  */
        status =  NU_INVALID_PIPE;
        
    else if (pipe -> pi_id != PI_PIPE_ID)
    
        /* Indicate that the pipe pointer is invalid.  */
        status =  NU_INVALID_PIPE;

    else
    
        /* All the parameters are okay, call the actual function to delete
           a pipe.  */
        status =  PIC_Delete_Pipe(pipe_ptr);
                                  
    /* Return completion status.  */
    return(status);
}


/*************************************************************************/
/*                                                                       */
/* FUNCTION                                                              */
/*                                                                       */
/*      PICE_Send_To_Pipe                                                */
/*                                                                       */
/* DESCRIPTION                                                           */
/*                                                                       */
/*      This function performs error checking on the parameters supplied */
/*      to the send message to pipe function.                            */
/*                                                                       */
/* AUTHOR                                                                */
/*                                                                       */
/*      William E. Lamie, Accelerated Technology, Inc.                   */
/*                                                                       */
/* CALLED BY                                                             */
/*                                                                       */
/*      Application                                                      */
/*                                                                       */
/* CALLS                                                                 */
/*                                                                       */
/*      PIC_Send_To_Pipe                    Actual send pipe message     */
/*                                            function                   */
/*      TCCE_Suspend_Error                  Check suspend validity       */
/*                                                                       */
/* INPUTS                                                                */
/*                                                                       */
/*      pipe_ptr                            Pipe control block pointer   */
/*      message                             Pointer to message to send   */
/*      size                                Size of message to send      */
/*      suspend                             Suspension option if full    */
/*                                                                       */
/* OUTPUTS                                                               */
/*                                                                       */
/*      NU_INVALID_PIPE                     Invalid pipe pointer         */
/*      NU_INVALID_POINTER                  Invalid message pointer      */
/*      NU_INVALID_SIZE                     Invalid message size         */
/*      NU_INVALID_SUSPEND                  Invalid suspend request      */
/*                                                                       */
/* 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,     */
/*                                        resulting in version 1.1       */
/*      R. Pfaff -                                                       */
/*      D. Lamie        03-18-1994      Verified version 1.1             */
/*                                                                       */
/*************************************************************************/
STATUS  PICE_Send_To_Pipe(NU_PIPE *pipe_ptr, VOID *message, UNSIGNED size, 
                                                        UNSIGNED suspend)
{

PI_PCB         *pipe;
STATUS          status;


    /* Move input pipe pointer into internal pointer.  */
    pipe =  (PI_PCB *) pipe_ptr;

    /* Determine if there is an error with the pipe pointer.  */
    if (pipe == NU_NULL)
    
        /* Indicate that the pipe pointer is invalid.  */
        status =  NU_INVALID_PIPE;
        
    else if (pipe -> pi_id != PI_PIPE_ID)
    
        /* Indicate that the pipe pointer is invalid.  */
        status =  NU_INVALID_PIPE;

    else if (message == NU_NULL)
    
        /* Indicate that the pointer to the message is invalid.  */
        status =  NU_INVALID_POINTER;

    else if ((pipe -> pi_fixed_size) && (size != pipe -> pi_message_size))
    
        /* Indicate that the message size is invalid.  */
        status =  NU_INVALID_SIZE;

    else if ((!pipe -> pi_fixed_size) && (size > pipe -> pi_message_size))
    
        /* Indicate that the message size is invalid.  */
        status =  NU_INVALID_SIZE;
        
    else if ((suspend) && (TCCE_Suspend_Error()))
    
        /* Indicate that suspension is only valid from a non-task thread.  */
        status =  NU_INVALID_SUSPEND;
    
    else
    
        /* All the parameters are okay, call the actual function to send
           a message to a pipe.  */
        status =  PIC_Send_To_Pipe(pipe_ptr, message, size, suspend);
                                  
    /* Return completion status.  */
    return(status);
}


/*************************************************************************/
/*                                                                       */
/* FUNCTION                                                              */
/*                                                                       */
/*      PICE_Receive_From_Pipe                                           */
/*                                                                       */
/* DESCRIPTION                                                           */
/*                                                                       */
/*      This function performs error checking on the parameters supplied */
/*      to the receive message from pipe function.                       */
/*                                                                       */
/* AUTHOR                                                                */
/*                                                                       */
/*      William E. Lamie, Accelerated Technology, Inc.                   */
/*                                                                       */
/* CALLED BY                                                             */
/*                                                                       */
/*      Application                                                      */
/*                                                                       */
/* CALLS                                                                 */
/*                                                                       */
/*      PIC_Receive_From_Pipe               Actual receive message from  */
/*                                            pipe                       */
/*      TCCE_Suspend_Error                  Check suspend validity       */
/*                                                                       */
/* INPUTS                                                                */
/*                                                                       */
/*      pipe_ptr                            Pipe control block pointer   */
/*      message                             Pointer to message to send   */
/*      size                                Size of the message          */
/*      actual_size                         Size of message received     */
/*      suspend                             Suspension option if empty   */
/*                                                                       */
/* OUTPUTS                                                               */
/*                                                                       */
/*      NU_INVALID_PIPE                     Invalid pipe pointer         */
/*      NU_INVALID_POINTER                  Invalid message pointer      */
/*      NU_INVALID_SIZE                     Invalid message size         */
/*      NU_INVALID_SUSPEND                  Invalid suspend request      */
/*                                                                       */
/* 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,     */
/*                                        resulting in version 1.1       */
/*      R. Pfaff -                                                       */
/*      D. Lamie        03-18-1994      Verified version 1.1             */
/*      M. Trippi       12-19-1995      Changed the variable pipe check  */
/*                                        from "message size not equal   */
/*                                        to pipe message size" to       */
/*                                        "message size greater than     */
/*                                        pipe message size",resulting   */
/*                                        in version 1.1+ (spr065)       */
/*                                                                       */
/*************************************************************************/
STATUS  PICE_Receive_From_Pipe(NU_PIPE *pipe_ptr, VOID *message,
                UNSIGNED size, UNSIGNED *actual_size, UNSIGNED suspend)
{

PI_PCB         *pipe;
STATUS          status;


    /* Move input pipe pointer into internal pointer.  */
    pipe =  (PI_PCB *) pipe_ptr;

    /* Determine if there is an error with the pipe pointer.  */
    if (pipe == NU_NULL)
    
        /* Indicate that the pipe pointer is invalid.  */
        status =  NU_INVALID_PIPE;
        
    else if (pipe -> pi_id != PI_PIPE_ID)
    
        /* Indicate that the pipe pointer is invalid.  */
        status =  NU_INVALID_PIPE;

    else if (message == NU_NULL)
    
        /* Indicate that the pointer to the message is invalid.  */
        status =  NU_INVALID_POINTER;

    else if ((pipe -> pi_fixed_size) && (size != pipe -> pi_message_size))
    
        /* Indicate that the message size is invalid.  */
        status =  NU_INVALID_SIZE;

    else if ((!pipe -> pi_fixed_size) && (size > pipe -> pi_message_size))
    
        /* Indicate that the message size is invalid.  */
        status =  NU_INVALID_SIZE;
        
    else if ((suspend) && (TCCE_Suspend_Error()))
    
        /* Indicate that suspension is only valid from a non-task thread.  */
        status =  NU_INVALID_SUSPEND;
    
    else
    
        /* All the parameters are okay, call the actual function to receive
           a message from a pipe.  */
        status =  PIC_Receive_From_Pipe(pipe_ptr, message, size, actual_size, 
                                                                suspend);
                                  
    /* Return completion status.  */
    return(status);
}


⌨️ 快捷键说明

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