📄 sem.h
字号:
/*
* Copyright 2003 by Texas Instruments Incorporated.
* All rights reserved. Property of Texas Instruments Incorporated.
* Restricted rights to use, duplicate or disclose this code are
* granted through contract.
*
*/
/* "@(#) DSP/BIOS 4.90.270 12-18-03 (barracuda-o04)" */
/*
* ======== sem.h ========
*
*/
#ifndef SEM_
#define SEM_
#include <knl.h>
#include <obj.h>
#include <que.h>
#include <sys.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* ======== SEM_Obj ========
*!
*! Warning! If any fields are added here, be sure to change COUNT in
*! sem_dec.s##.
*/
typedef struct SEM_Obj *SEM_Handle;
typedef Void (*SEM_Fxn)(SEM_Handle);
typedef struct SEM_Obj {
KNL_Job job; /* handles interrupt-level posting */
Int count; /* semaphore value */
QUE_Obj pendQ; /* tasks wait here */
#ifdef PRIORITY
Uns type; /* bit mask SEM_PRIORITY (0x1) or SEM_FIFO (0x0) */
#endif
} SEM_Obj;
typedef struct SEM_Attrs {
Uns type;
} SEM_Attrs;
#define SEM_OBJECT(obj, count) SEM_Obj obj = { \
{ /* job */ \
{ NULL, NULL }, /* wListElem */ \
0, /* wCount */ \
(KNL_Fxn)_SEM_dopost, /* fxn */ \
}, \
count, /* count */ \
{ &obj.pendQ, &obj.pendQ }, /* pendQ */ \
}
#ifdef PRIORITY
/*
* bit mask for SEM_Attrs 'type' field -- default is (0x0)
*/
#define SEM_FIFO 0x0
#define SEM_PRIORITY 0x1
#endif
extern SEM_Attrs SEM_ATTRS; /* declared in sem_crea.c */
#define SEM_count(sem) ((sem)->count + (sem)->job.wCount)
#define SEM_new(_sem, _count) (_sem)->count = _count; \
QUE_new(&(_sem)->pendQ); \
(_sem)->job.wCount = 0; \
(_sem)->job.fxn = (KNL_Fxn)_SEM_dopost
#define SEM_reset(sem, cnt) ((sem)->count = (cnt))
extern Void SEM_post(SEM_Handle sem);
extern SEM_Handle SEM_create(Int count, SEM_Attrs *attrs);
extern Void SEM_delete(SEM_Handle sem);
extern Void SEM_ipost(SEM_Handle sem);
extern Bool SEM_pend(SEM_Handle sem, Uns timeout);
extern Void SEM_print(SEM_Handle sem);
/*
extern Bool _SEM_dec(SEM_Handle sem);
*/
extern Void _SEM_dopost(SEM_Handle sem);
/*
* The definitions below are needed as these are used by
* the expanded version of KNL_exit in SEM_postEnterKnl and SEM_pendEnterKnl
*/
#ifdef _6x_
extern far SWI_Obj KNL_swi;
extern far FXN_Obj *SWI_D_curfxn;
#else
extern SWI_Obj KNL_swi;
extern FXN_Obj *SWI_D_curfxn;
#endif
extern Uns SWI_D_curmask;
#ifdef __cplusplus
}
#endif /* extern "C" */
#endif /* SEM_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -