XWOS API  4.0
XWOS C/C++ API参考手册
载入中...
搜索中...
未找到
sem.h
浏览该文件的文档.
1
13#ifndef __xwos_osal_sync_sem_h__
14#define __xwos_osal_sync_sem_h__
15
16#include <xwos/standard.h>
18#include <xwos/osal/time.h>
19#include <xwos/osal/sync/sel.h>
20
95struct xwos_sem {
96 struct xwosdl_sem ossem;
97};
98
102typedef struct {
103 struct xwos_sem * sem;
105} xwos_sem_d;
106
110#define XWOS_SEM_NILD ((xwos_sem_d){NULL, 0,})
111
126{
127 return xwosdl_sem_init(&sem->ossem, val, max);
128}
129
141{
142 return xwosdl_sem_fini(&sem->ossem);
143}
144
160{
161 return xwosdl_sem_grab(&sem->ossem);
162}
163
179{
180 return xwosdl_sem_put(&sem->ossem);
181}
182
198{
199 return xwosdl_sem_create((xwosdl_sem_d *)semd, val, max);
200}
201
213{
214 return xwosdl_sem_delete(&semd.sem->ossem, semd.tik);
215}
216
230{
231 return xwosdl_sem_acquire(&semd.sem->ossem, semd.tik);
232}
233
247{
248 return xwosdl_sem_release(&semd.sem->ossem, semd.tik);
249}
250
260{
261 return xwosdl_sem_get_tik(&sem->ossem);
262}
263
273{
274 xwos_sem_d semd;
275
276 semd.sem = sem;
277 semd.tik = xwosdl_sem_get_tik(&sem->ossem);
278 return semd;
279}
280
297xwer_t xwos_sem_bind(struct xwos_sem * sem, struct xwos_sel * sel, xwsq_t pos)
298{
299 return xwosdl_sem_bind(&sem->ossem, &sel->ossel, pos);
300}
301
314xwer_t xwos_sem_unbind(struct xwos_sem * sem, struct xwos_sel * sel)
315{
316 return xwosdl_sem_unbind(&sem->ossem, &sel->ossel);
317}
318
336{
337 return xwosdl_sem_freeze(&sem->ossem);
338}
339
355{
356 return xwosdl_sem_thaw(&sem->ossem);
357}
358
374{
375 return xwosdl_sem_post(&sem->ossem);
376}
377
393{
394 return xwosdl_sem_wait(&sem->ossem);
395}
396
419{
420 return xwosdl_sem_wait_to(&sem->ossem, to);
421}
422
437{
438 return xwosdl_sem_wait_unintr(&sem->ossem);
439}
440
455{
456 return xwosdl_sem_trywait(&sem->ossem);
457}
458
471{
472 return xwosdl_sem_get_max(&sem->ossem, max);
473}
474
487{
488 return xwosdl_sem_get_value(&sem->ossem, val);
489}
490
495#endif /* xwos/osal/sync/sem.h */
#define __xwos_inline_api
Definition compiler.h:179
xws64_t xwtm_t
XWOS系统时间 (有符号)
Definition type.h:742
signed long xwer_t
Definition type.h:554
unsigned long xwsq_t
Definition type.h:445
signed long xwssq_t
Definition type.h:461
static xwos_sem_d xwos_sem_get_d(struct xwos_sem *sem)
XWOS API:获取信号量对象描述符
Definition sem.h:272
static xwer_t xwos_sem_get_value(struct xwos_sem *sem, xwssq_t *val)
XWOS API:获取信号量对象计数器的值
Definition sem.h:486
static xwer_t xwos_sem_release(xwos_sem_d semd)
XWOS API:检查对象的标签并减少引用计数
Definition sem.h:246
static xwer_t xwos_sem_get_max(struct xwos_sem *sem, xwssq_t *max)
XWOS API:获取信号量对象计数器的最大值
Definition sem.h:470
static xwer_t xwos_sem_trywait(struct xwos_sem *sem)
XWOS API:尝试获取信号量
Definition sem.h:454
static xwer_t xwos_sem_bind(struct xwos_sem *sem, struct xwos_sel *sel, xwsq_t pos)
XWOS API:绑定信号量对象到信号选择器
Definition sem.h:297
static xwer_t xwos_sem_unbind(struct xwos_sem *sem, struct xwos_sel *sel)
XWOS API:从信号选择器上解绑信号量对象
Definition sem.h:314
static xwer_t xwos_sem_wait(struct xwos_sem *sem)
XWOS API:等待并获取信号量
Definition sem.h:392
static xwer_t xwos_sem_delete(xwos_sem_d semd)
XWOS API:删除动态方式创建的信号量对象
Definition sem.h:212
static xwer_t xwos_sem_grab(struct xwos_sem *sem)
XWOS API:增加信号量对象的引用计数
Definition sem.h:159
static xwer_t xwos_sem_wait_unintr(struct xwos_sem *sem)
XWOS API:等待并获取信号量,且等待不可被中断
Definition sem.h:436
static xwer_t xwos_sem_put(struct xwos_sem *sem)
XWOS API:减少信号量对象的引用计数
Definition sem.h:178
static xwer_t xwos_sem_fini(struct xwos_sem *sem)
XWOS API:销毁静态方式初始化的信号量对象
Definition sem.h:140
static xwer_t xwos_sem_freeze(struct xwos_sem *sem)
XWOS API:冻结信号量对象
Definition sem.h:335
static xwer_t xwos_sem_wait_to(struct xwos_sem *sem, xwtm_t to)
XWOS API:限时等待并获取信号量
Definition sem.h:418
static xwer_t xwos_sem_acquire(xwos_sem_d semd)
XWOS API:检查信号量对象的标签并增加引用计数
Definition sem.h:229
static xwer_t xwos_sem_thaw(struct xwos_sem *sem)
XWOS API:解冻信号量对象
Definition sem.h:354
static xwsq_t xwos_sem_get_tik(struct xwos_sem *sem)
XWOS API:获取信号量对象的标签
Definition sem.h:259
static xwer_t xwos_sem_create(xwos_sem_d *semd, xwssq_t val, xwssq_t max)
XWOS API:动态方式创建信号量对象
Definition sem.h:197
static xwer_t xwos_sem_init(struct xwos_sem *sem, xwssq_t val, xwssq_t max)
XWOS API:静态方式初始化信号量对象
Definition sem.h:125
static xwer_t xwos_sem_post(struct xwos_sem *sem)
XWOS API:发布信号量
Definition sem.h:373
操作系统抽象层:信号量接口描述
XWOS API:信号选择器对象
Definition sel.h:81
struct xwmp_evt ossel
Definition sel.h:82
XWOS API:信号量对象描述符
Definition sem.h:102
struct xwos_sem * sem
Definition sem.h:103
xwsq_t tik
Definition sem.h:104
XWOS API:信号量对象
Definition sem.h:95
struct xwmp_sem ossem
Definition sem.h:96
操作系统抽象层:信号选择器
操作系统抽象层:时间
XWOS的标准头文件