标题: 请教较新版本内核中mutex的使用 [打印本页] 作者: xiegang112 时间: 2009-06-01 13:01 标题: 请教较新版本内核中mutex的使用 在较新版本中,如2.6.27中,内核有专门的metux子系统,而不是之前使用的binary semaphore.
在文档中,有这样的描述:
'struct mutex' semantics are well-defined and are enforced if
CONFIG_DEBUG_MUTEXES is turned on. Semaphores on the other hand have
virtually no debugging code or instrumentation. The mutex subsystem
checks and enforces the following rules:
* - only one task can hold the mutex at a time
* - only the owner can unlock the mutex
* - multiple unlocks are not permitted
* - recursive locking is not permitted
* - a mutex object must be initialized via the API
* - a mutex object must not be initialized via memset or copying
* - task may not exit with mutex held
* - memory areas where held locks reside must not be freed
* - held mutexes must not be reinitialized
* - mutexes may not be used in hardware or software interrupt
* contexts such as tasklets and timers