📄 smce.c
字号:
#include "SWITCH.h"
#if NU_SEM_EN
/*************************************************************************/
/* */
/* Copyright (c) 1993-2001 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 */
/* */
/* smce.c PLUS 1.13 */
/* */
/* COMPONENT */
/* */
/* SM - Semaphore Management */
/* */
/* DESCRIPTION */
/* */
/* This file contains the error checking routines for the core */
/* functions of the Semaphore component. This permits easy removal */
/* of error checking logic when it is not needed. */
/* */
/* AUTHOR */
/* */
/* Accelerated Technology, Inc. */
/* */
/* DATA STRUCTURES */
/* */
/* None */
/* */
/* FUNCTIONS */
/* */
/* SMCE_Create_Semaphore Create a semaphore */
/* SMCE_Delete_Semaphore Delete a semaphore */
/* SMCE_Obtain_Semaphore Obtain an instance of a */
/* semaphore */
/* SMCE_Release_Semaphore Release an instance of a */
/* semaphore */
/* */
/* DEPENDENCIES */
/* */
/* cs_extr.h Common Service functions */
/* tc_extr.h Thread Control functions */
/* sm_extr.h Semaphore functions */
/* */
/* HISTORY */
/* */
/* DATE REMARKS */
/* */
/* 03-01-1993 Created initial version 1.0 */
/* 04-19-1993 Verified version 1.0 */
/* 05-15-1993 Corrected comment problem in */
/* the header, making the new */
/* version 1.0a */
/* 05-15-1993 Verified version 1.0a */
/* 03-01-1994 Split original error checking */
/* file and changed function */
/* interfaces, resulting in */
/* version 1.1 */
/* */
/* 03-18-1994 Verified version 1.1 */
/* 04-17-1996 updated to version 1.2 */
/* 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 "sm_extr.h" /* Semaphore functions */
/*************************************************************************/
/* */
/* FUNCTION */
/* */
/* SMCE_Create_Semaphore */
/* */
/* DESCRIPTION */
/* */
/* This function performs error checking on the parameters supplied */
/* to the create semaphore function. */
/* */
/* AUTHOR */
/* */
/* Accelerated Technology, Inc. */
/* */
/* CALLED BY */
/* */
/* Application */
/* */
/* CALLS */
/* */
/* SMC_Create_Semaphore Actual semaphore create func.*/
/* */
/* INPUTS */
/* */
/* semaphore_ptr Semaphore control block ptr */
/* name Semaphore name */
/* initial_count Initial semaphore instance */
/* count */
/* suspend_type Suspension type */
/* */
/* OUTPUTS */
/* */
/* NU_INVALID_SEMAPHORE Semaphore control block ptr */
/* is NULL */
/* NU_INVALID_SUSPEND Semaphore suspension is */
/* invalid */
/* */
/* HISTORY */
/* */
/* DATE REMARKS */
/* */
/* 03-01-1993 Created initial version 1.0 */
/* 04-19-1993 Verified version 1.0 */
/* 03-01-1994 Modified function interface, */
/* resulting in version 1.1 */
/* */
/* 03-18-1994 Verified version 1.1 */
/* */
/*************************************************************************/
STATUS SMCE_Create_Semaphore(NU_SEMAPHORE *semaphore_ptr, CHAR *name,
UNSIGNED initial_count, OPTION suspend_type)
{
SM_SCB *semaphore; /* Semaphore control blk ptr */
STATUS status; /* Completion status */
/* Move input semaphore pointer into internal pointer. */
semaphore = (SM_SCB *) semaphore_ptr;
/* Check for a NULL semaphore pointer or an already created semaphore. */
if ((semaphore == NU_NULL) || (semaphore -> sm_id == SM_SEMAPHORE_ID))
/* Invalid semaphore control block pointer. */
status = NU_INVALID_SEMAPHORE;
else if ((suspend_type != NU_FIFO) && (suspend_type != NU_PRIORITY))
/* Invalid suspension type. */
status = NU_INVALID_SUSPEND;
else
/* Call the actual service to create the semaphore. */
status = SMC_Create_Semaphore(semaphore_ptr, name, initial_count,
suspend_type);
/* Return completion status. */
return(status);
}
/*************************************************************************/
/* */
/* FUNCTION */
/* */
/* SMCE_Delete_Semaphore */
/* */
/* DESCRIPTION */
/* */
/* This function performs error checking on the parameters supplied */
/* to the delete semaphore function. */
/* */
/* AUTHOR */
/* */
/* Accelerated Technology, Inc. */
/* */
/* CALLED BY */
/* */
/* Application */
/* */
/* CALLS */
/* */
/* SMC_Delete_Semaphore Actual delete semaphore func.*/
/* */
/* INPUTS */
/* */
/* semaphore_ptr Semaphore control block ptr */
/* */
/* OUTPUTS */
/* */
/* NU_INVALID_SEMAPHORE Invalid semaphore pointer */
/* */
/* HISTORY */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -