XWOS API  4.0
XWOS C/C++ API参考手册
载入中...
搜索中...
未找到
seqlock.h
浏览该文件的文档.
1
13#ifndef __xwos_osal_lock_seqlock_h__
14#define __xwos_osal_lock_seqlock_h__
15
16#include <xwos/standard.h>
18#include <xwos/osal/irq.h>
19
112struct xwos_sqlk {
113 xwosdl_sqlk_t ossql;
114};
115
119#define XWOS_SQLK_INITIALIZER { .ossql = XWOSDL_SQLK_INITIALIZER, }
120
124#define XWOS_SQLK_GRANULARITY XWOSDL_SQLK_GRANULARITY
125
133void xwos_sqlk_init(struct xwos_sqlk * sql)
134{
135 xwosdl_sqlk_init(&sql->ossql);
136}
137
149{
150 return xwosdl_sqlk_rd_begin(&sql->ossql);
151}
152
163bool xwos_sqlk_rd_retry(struct xwos_sqlk * sql, xwsq_t start)
164{
165 return xwosdl_sqlk_rd_retry(&sql->ossql, start);
166}
167
176{
177 return xwosdl_sqlk_get_seq(&sql->ossql);
178}
179
190{
191 xwosdl_sqlk_rdex_lock(&sql->ossql);
192}
193
207{
208 return xwosdl_sqlk_rdex_trylock(&sql->ossql);
209}
210
219{
220 xwosdl_sqlk_rdex_unlock(&sql->ossql);
221}
222
234{
235 xwosdl_sqlk_rdex_lock_cpuirq(&sql->ossql);
236}
237
251{
252 return xwosdl_sqlk_rdex_trylock_cpuirq(&sql->ossql);
253}
254
263{
264 xwosdl_sqlk_rdex_unlock_cpuirq(&sql->ossql);
265}
266
279 xwreg_t * cpuirq)
280{
281 xwosdl_sqlk_rdex_lock_cpuirqsv(&sql->ossql, cpuirq);
282}
283
298 xwreg_t * cpuirq)
299{
300 return xwosdl_sqlk_rdex_trylock_cpuirqsv(&sql->ossql, cpuirq);
301}
302
312 xwreg_t cpuirq)
313{
314 xwosdl_sqlk_rdex_unlock_cpuirqrs(&sql->ossql, cpuirq);
315}
316
331 const xwirq_t irqs[],
332 xwsz_t num)
333{
334 xwosdl_sqlk_rdex_lock_irqs(&sql->ossql, irqs, num);
335}
336
353 const xwirq_t irqs[],
354 xwsz_t num)
355{
356 return xwosdl_sqlk_rdex_trylock_irqs(&sql->ossql, irqs, num);
357}
358
369 const xwirq_t irqs[],
370 xwsz_t num)
371{
372 xwosdl_sqlk_rdex_unlock_irqs(&sql->ossql, irqs, num);
373}
374
390 const xwirq_t irqs[],
391 xwreg_t flags[], xwsz_t num)
392{
393 xwosdl_sqlk_rdex_lock_irqssv(&sql->ossql, irqs, flags, num);
394}
395
413 const xwirq_t irqs[],
414 xwreg_t flags[], xwsz_t num)
415{
416 return xwosdl_sqlk_rdex_trylock_irqssv(&sql->ossql, irqs, flags, num);
417}
418
430 const xwirq_t irqs[],
431 xwreg_t flags[], xwsz_t num)
432{
433 xwosdl_sqlk_rdex_unlock_irqsrs(&sql->ossql, irqs, flags, num);
434}
435
448{
449 xwosdl_sqlk_rdex_lock_bh(&sql->ossql);
450}
451
466{
467 return xwosdl_sqlk_rdex_trylock_bh(&sql->ossql);
468}
469
478{
479 xwosdl_sqlk_rdex_unlock_bh(&sql->ossql);
480}
481
491void xwos_sqlk_wr_lock(struct xwos_sqlk * sql)
492{
493 xwosdl_sqlk_wr_lock(&sql->ossql);
494}
495
507{
508 return xwosdl_sqlk_wr_trylock(&sql->ossql);
509}
510
521{
522 xwosdl_sqlk_wr_unlock(&sql->ossql);
523}
524
536{
537 xwosdl_sqlk_wr_lock_cpuirq(&sql->ossql);
538}
539
553{
554 return xwosdl_sqlk_wr_trylock_cpuirq(&sql->ossql);
555}
556
565{
566 xwosdl_sqlk_wr_unlock_cpuirq(&sql->ossql);
567}
568
581 xwreg_t * cpuirq)
582{
583 xwosdl_sqlk_wr_lock_cpuirqsv(&sql->ossql, cpuirq);
584}
585
600 xwreg_t * cpuirq)
601{
602 return xwosdl_sqlk_wr_trylock_cpuirqsv(&sql->ossql, cpuirq);
603}
604
614 xwreg_t cpuirq)
615{
616 xwosdl_sqlk_wr_unlock_cpuirqrs(&sql->ossql, cpuirq);
617}
618
633 const xwirq_t irqs[],
634 xwsz_t num)
635{
636 xwosdl_sqlk_wr_lock_irqs(&sql->ossql, irqs, num);
637}
638
655 const xwirq_t irqs[],
656 xwsz_t num)
657{
658 return xwosdl_sqlk_wr_trylock_irqs(&sql->ossql, irqs, num);
659}
660
671 const xwirq_t irqs[],
672 xwsz_t num)
673{
674 xwosdl_sqlk_wr_unlock_irqs(&sql->ossql, irqs, num);
675}
676
677
693 const xwirq_t irqs[],
694 xwreg_t flags[], xwsz_t num)
695{
696 xwosdl_sqlk_wr_lock_irqssv(&sql->ossql, irqs, flags, num);
697}
698
716 const xwirq_t irqs[],
717 xwreg_t flags[], xwsz_t num)
718{
719 return xwosdl_sqlk_wr_trylock_irqssv(&sql->ossql, irqs, flags, num);
720}
721
733 const xwirq_t irqs[],
734 xwreg_t flags[], xwsz_t num)
735{
736 xwosdl_sqlk_wr_unlock_irqsrs(&sql->ossql, irqs, flags, num);
737}
738
751{
752 xwosdl_sqlk_wr_lock_bh(&sql->ossql);
753}
754
769{
770 return xwosdl_sqlk_wr_trylock_bh(&sql->ossql);
771}
772
783{
784 xwosdl_sqlk_wr_unlock_bh(&sql->ossql);
785}
786
791#endif /* xwos/osal/lock/seqlock.h */
#define __xwos_inline_api
Definition compiler.h:179
signed long xwer_t
Definition type.h:554
signed int xwirq_t
Definition type.h:517
unsigned long xwsz_t
Definition type.h:339
unsigned long xwsq_t
Definition type.h:445
xwptr_t xwreg_t
Definition type.h:409
static xwer_t xwos_sqlk_wr_trylock_cpuirqsv(struct xwos_sqlk *sql, xwreg_t *cpuirq)
XWOS API:尝试开启写临界区,保存本地CPU的中断标志并关闭
Definition seqlock.h:599
static void xwos_sqlk_rdex_lock(struct xwos_sqlk *sql)
XWOS API:开启独占读临界区
Definition seqlock.h:189
static void xwos_sqlk_wr_unlock(struct xwos_sqlk *sql)
XWOS API:关闭写临界区
Definition seqlock.h:520
static void xwos_sqlk_rdex_unlock_irqsrs(struct xwos_sqlk *sql, const xwirq_t irqs[], xwreg_t flags[], xwsz_t num)
XWOS API:关闭独占读临界区,恢复部分中断的中断标志
Definition seqlock.h:429
static void xwos_sqlk_wr_lock(struct xwos_sqlk *sql)
XWOS API:开启写临界区
Definition seqlock.h:491
static void xwos_sqlk_rdex_unlock_irqs(struct xwos_sqlk *sql, const xwirq_t irqs[], xwsz_t num)
XWOS API:关闭独占读临界区,并开启部分中断
Definition seqlock.h:368
static void xwos_sqlk_init(struct xwos_sqlk *sql)
XWOS API:初始化顺序锁
Definition seqlock.h:133
static void xwos_sqlk_rdex_lock_cpuirq(struct xwos_sqlk *sql)
XWOS API:开启独占读临界区,并关闭本地CPU的中断
Definition seqlock.h:233
static xwer_t xwos_sqlk_wr_trylock_irqssv(struct xwos_sqlk *sql, const xwirq_t irqs[], xwreg_t flags[], xwsz_t num)
XWOS API:尝试开启写临界区,保存部分中断的中断标志并关闭
Definition seqlock.h:715
static void xwos_sqlk_rdex_lock_irqs(struct xwos_sqlk *sql, const xwirq_t irqs[], xwsz_t num)
XWOS API:开启独占读临界区,并关闭部分中断
Definition seqlock.h:330
static void xwos_sqlk_rdex_unlock(struct xwos_sqlk *sql)
XWOS API:关闭独占读临界区
Definition seqlock.h:218
static void xwos_sqlk_wr_unlock_bh(struct xwos_sqlk *sql)
XWOS API:关闭写临界区,开启本地CPU的中断底半部
Definition seqlock.h:782
static void xwos_sqlk_wr_unlock_irqs(struct xwos_sqlk *sql, const xwirq_t irqs[], xwsz_t num)
XWOS API:关闭写临界区,并开启部分中断
Definition seqlock.h:670
static xwsq_t xwos_sqlk_get_seq(struct xwos_sqlk *sql)
XWOS API:获取顺序锁的顺序值
Definition seqlock.h:175
static xwer_t xwos_sqlk_wr_trylock_bh(struct xwos_sqlk *sql)
XWOS API:尝试开启写临界区,关闭本地CPU的中断底半部
Definition seqlock.h:768
static void xwos_sqlk_rdex_unlock_bh(struct xwos_sqlk *sql)
XWOS API:关闭独占读临界区,开启本地CPU的中断底半部
Definition seqlock.h:477
static void xwos_sqlk_wr_lock_irqs(struct xwos_sqlk *sql, const xwirq_t irqs[], xwsz_t num)
XWOS API:开启写临界区,并关闭部分中断
Definition seqlock.h:632
static xwer_t xwos_sqlk_wr_trylock(struct xwos_sqlk *sql)
XWOS API:尝试开启写临界区
Definition seqlock.h:506
static xwer_t xwos_sqlk_rdex_trylock_cpuirq(struct xwos_sqlk *sql)
XWOS API:尝试开启独占读临界区,并关闭本地CPU的中断
Definition seqlock.h:250
static void xwos_sqlk_wr_lock_cpuirq(struct xwos_sqlk *sql)
XWOS API:开启写临界区,并关闭本地CPU的中断
Definition seqlock.h:535
static void xwos_sqlk_wr_lock_irqssv(struct xwos_sqlk *sql, const xwirq_t irqs[], xwreg_t flags[], xwsz_t num)
XWOS API:开启写临界区,保存部分中断的中断标志并关闭
Definition seqlock.h:692
static void xwos_sqlk_wr_unlock_cpuirq(struct xwos_sqlk *sql)
XWOS API:关闭写临界区,并开启本地CPU的中断
Definition seqlock.h:564
static void xwos_sqlk_rdex_unlock_cpuirqrs(struct xwos_sqlk *sql, xwreg_t cpuirq)
XWOS API:关闭独占读临界区,恢复本地CPU的中断标志
Definition seqlock.h:311
static void xwos_sqlk_rdex_lock_irqssv(struct xwos_sqlk *sql, const xwirq_t irqs[], xwreg_t flags[], xwsz_t num)
XWOS API:开启独占读临界区,保存部分中断的中断标志并关闭
Definition seqlock.h:389
static xwer_t xwos_sqlk_rdex_trylock_cpuirqsv(struct xwos_sqlk *sql, xwreg_t *cpuirq)
XWOS API:尝试开启独占读临界区,保存本地CPU的中断标志并关闭
Definition seqlock.h:297
static xwsq_t xwos_sqlk_rd_begin(struct xwos_sqlk *sql)
XWOS API:开启共享读临界区
Definition seqlock.h:148
static void xwos_sqlk_rdex_lock_cpuirqsv(struct xwos_sqlk *sql, xwreg_t *cpuirq)
XWOS API:开启独占读临界区,保存本地CPU的中断标志并关闭
Definition seqlock.h:278
static xwer_t xwos_sqlk_wr_trylock_cpuirq(struct xwos_sqlk *sql)
XWOS API:尝试开启写临界区,并关闭本地CPU的中断
Definition seqlock.h:552
static xwer_t xwos_sqlk_rdex_trylock(struct xwos_sqlk *sql)
XWOS API:尝试开启独占读临界区
Definition seqlock.h:206
static xwer_t xwos_sqlk_rdex_trylock_bh(struct xwos_sqlk *sql)
XWOS API:尝试开启独占读临界区,关闭本地CPU的中断底半部
Definition seqlock.h:465
static void xwos_sqlk_wr_lock_cpuirqsv(struct xwos_sqlk *sql, xwreg_t *cpuirq)
XWOS API:开启写临界区,保存本地CPU的中断标志并关闭
Definition seqlock.h:580
static bool xwos_sqlk_rd_retry(struct xwos_sqlk *sql, xwsq_t start)
XWOS API:关闭共享读临界区,并检查是否需要重试
Definition seqlock.h:163
static void xwos_sqlk_wr_unlock_irqsrs(struct xwos_sqlk *sql, const xwirq_t irqs[], xwreg_t flags[], xwsz_t num)
XWOS API:关闭写临界区,恢复部分中断的中断标志
Definition seqlock.h:732
static xwer_t xwos_sqlk_wr_trylock_irqs(struct xwos_sqlk *sql, const xwirq_t irqs[], xwsz_t num)
XWOS API:尝试开启写临界区,并关闭部分中断
Definition seqlock.h:654
static xwer_t xwos_sqlk_rdex_trylock_irqs(struct xwos_sqlk *sql, const xwirq_t irqs[], xwsz_t num)
XWOS API:尝试开启独占读临界区,并关闭部分中断
Definition seqlock.h:352
static void xwos_sqlk_rdex_lock_bh(struct xwos_sqlk *sql)
XWOS API:开启独占读临界区,关闭本地CPU的中断底半部
Definition seqlock.h:447
static void xwos_sqlk_wr_unlock_cpuirqrs(struct xwos_sqlk *sql, xwreg_t cpuirq)
XWOS API:关闭写临界区,恢复本地CPU的中断标志
Definition seqlock.h:613
static void xwos_sqlk_rdex_unlock_cpuirq(struct xwos_sqlk *sql)
XWOS API:关闭独占读临界区,并开启本地CPU的中断
Definition seqlock.h:262
static xwer_t xwos_sqlk_rdex_trylock_irqssv(struct xwos_sqlk *sql, const xwirq_t irqs[], xwreg_t flags[], xwsz_t num)
XWOS API:尝试开启独占读临界区,保存部分中断的中断标志并关闭
Definition seqlock.h:412
static void xwos_sqlk_wr_lock_bh(struct xwos_sqlk *sql)
XWOS API:开启写临界区,关闭本地CPU的中断底半部
Definition seqlock.h:750
操作系统抽象层:异常与中断
操作系统抽象层:顺序锁接口描述
XWOS API:顺序锁
Definition seqlock.h:112
xwosdl_sqlk_t ossql
Definition seqlock.h:113
XWOS的标准头文件