|
|
/****************************************************************************/
|
|
|
/* Copyright (c) 2007,许继集团有限公司 */
|
|
|
/* All rights reserved. */
|
|
|
/* */
|
|
|
/* 模块描述: */
|
|
|
/** 多线程管理模块,提供互斥量初始化及操作接口
|
|
|
* @file ai_sem.h */
|
|
|
/* */
|
|
|
/* 日期 作者 注释 */
|
|
|
/* 2007/07/13 ZYZ 创建文件 */
|
|
|
/****************************************************************************/
|
|
|
#ifndef IEC61850_AI_SEM_H
|
|
|
#define IEC61850_AI_SEM_H
|
|
|
|
|
|
#include "glbtypes.h"
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
extern "C" {
|
|
|
#endif
|
|
|
|
|
|
/**
|
|
|
* 初始化互斥量的最大个数为10
|
|
|
*/
|
|
|
#define AI_MAX_SEM_NUM 10
|
|
|
|
|
|
/**
|
|
|
* 枚举定义可以增加自己的互斥量,以下定义为暂时定义
|
|
|
*/
|
|
|
#define AI_SEM_SRVM 0 /**< 站点管理互斥量 */
|
|
|
#define AI_SEM_REQ 1 /**< 请求管理互斥量 */
|
|
|
#define AI_SEM_ASSOC 2 /**< 关联操作互斥量 */
|
|
|
#define AI_SEM_COMMON 9 /**< 全局公用互斥量 */
|
|
|
|
|
|
/**
|
|
|
* 初始化AI_MAX_SEM_NUM个互斥量
|
|
|
* @param ST_VOID
|
|
|
* @retval SD_TRUE 初始化互斥量成功
|
|
|
* @retval SD_FALSE 初始化互斥量失败
|
|
|
*/
|
|
|
ST_BOOLEAN ai_init_sem(ST_VOID);
|
|
|
|
|
|
/**
|
|
|
* 释放互斥量
|
|
|
* @param ST_VOID
|
|
|
* @return ST_VOID
|
|
|
*/
|
|
|
ST_VOID ai_uninit_sem(ST_VOID);
|
|
|
|
|
|
/**
|
|
|
* 锁定互斥量
|
|
|
* @param index 枚举内定义索引,从0开始,最多10个
|
|
|
* @return ST_VOID
|
|
|
*/
|
|
|
ST_VOID ai_lock_sem(ST_INT index);
|
|
|
|
|
|
/**
|
|
|
* 解除锁定互斥量
|
|
|
* @param index 枚举内定义索引,从0开始,最多10个
|
|
|
* @return ST_VOID
|
|
|
*/
|
|
|
ST_VOID ai_unlock_sem(ST_INT index);
|
|
|
|
|
|
#define AI_LOCK_SRVM_RESOURCES() ai_lock_sem(AI_SEM_SRVM)
|
|
|
#define AI_UNLOCK_SRVML_RESOURCES() ai_unlock_sem(AI_SEM_SRVM)
|
|
|
|
|
|
#define AI_LOCK_REQ_RESOURCES() ai_lock_sem(AI_SEM_REQ)
|
|
|
#define AI_UNLOCK_REQ_RESOURCES() ai_unlock_sem(AI_SEM_REQ)
|
|
|
|
|
|
#define AI_LOCK_ASSOC_RESOURCES() ai_lock_sem(AI_SEM_ASSOC)
|
|
|
#define AI_UNLOCK_ASSOC_RESOURCES() ai_unlock_sem(AI_SEM_ASSOC)
|
|
|
|
|
|
#define AI_LOCK_COMMON_RESOURCES() ai_lock_sem(AI_SEM_COMMON)
|
|
|
#define AI_UNLOCK_COMMON_RESOURCES() ai_unlock_sem(AI_SEM_COMMON)
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
}
|
|
|
#endif
|
|
|
#endif /* #ifndef IEC61850_AI_SEM_H */
|