VxWorks 学习笔记-Semaphores
来源:互联网 发布:医疗软件业务 编辑:程序博客网 时间:2024/05/15 12:25
§ Semaphores
1.Overview
Binary semaphores: Synchronization
-
申请、和释放由不同的任务执行。
-
Caveat: if the event repeats too quickly, information may be lost.
Mutual exclusion semaphores: Mutual Exclusion
-
有owner的概念。
-
申请和释放由同一个任务(owner)执行。
-
一个任务可以申请多次。
-
只有owner才可以释放。
Counting semaphores
2.More about Mutual exclusion semaphores
Deletion Safety (owner exists)
-
The deletion safety option prevents a task from being deleted while it owns the semaphore.
-
SEM_DELETE_SAFE options
-
STATUS taskDeleteForce (tid)
Unbounded Priority Inversion
-
Problem exists
-
Priority inheritance algorithm solves the unbounded priority inversion problem.
-
Enabled on mutex semaphores by specifying the SEM_INVERSION_SAFE option during semMCreate( ).
编程建议
-
编写访问资源的库函数
-
在库函数中使用互斥机制
-
用户只通过库函数访问资源
Deadlock Problem
-
Problem description
-
Solutions: 1) 只使用一个信号量保护资源, 2) 所有任务按照相同的顺序访问资源
其他注意事项
-
不能在ISR 中使用;
-
Critical region 尽量短;
Locking Out Preemption
-
When doing something quick frequently, it may be preferable to disable preemption instead of taking a mutex.
-
Does not disable interrupts.
-
taskLock( )/taskUnlock( ) is faster than semGive( )/semTake( ).
ISR’s and Mutual Exclusion (ISR VS. Task)
-
ISR’s can’t use mutex semaphores.
-
Task sharing a resource with an ISR may need to disable interrupts.
-
To disable/re-enable interrupts: int intLock( ), void intUnlock (lockKey)
- VxWorks 学习笔记-Semaphores
- VxWorks 学习笔记-Reconfiguring VxWorks
- VxWorks学习笔记-Real-Time Multitasking
- vxWorks学习笔记
- VxWorks 操作系统学习笔记
- VxWorks 操作系统学习笔记
- VxWorks学习笔记 -- 信号量
- VxWorks 操作系统学习笔记
- VxWorks 操作系统学习笔记
- VxWorks 操作系统学习笔记
- vxWorks学习笔记
- VxWorks学习笔记 -- 任务管理
- VxWorks 学习笔记-IO and File System
- VxWorks学习笔记——VxWorks基本操作系统
- Semaphores
- Semaphores
- VxWorks BSP学习笔记_串口驱动
- 《VxWorks学习笔记》——实时系统
- 如何在javascript写本地文件
- sql server日期时间函数
- The diagrams of intra4x4 prediciton
- 使用XML的五种场合[精华]
- 好女人是疼出来的
- VxWorks 学习笔记-Semaphores
- 水晶报表Crystal Reports XI服务器版
- 自定义控制title提示框
- Oracle 的入门心得-->强烈推荐Oracle 的入门心得-->强烈推荐Oracle 的入门心得-->强烈推荐
- PECompact v2.79 beta 1 Retail by jamie
- 测试一下
- 哪有VS2003的帮助文档下载,急急!!
- 怎样用javaScript计算两个日期字符串相差的天数?
- ORACLE技术中国用户讨论组