- 追加された行はこの色です。
- 削除された行はこの色です。
*参照元 [#e960ad50]
#backlinks
*説明 [#j5806e48]
-パス: 複数あり
--CONFIG_DEBUG_LOCK_ALLOC 有効: [[linux-2.6.33/include/linux/mutex.h]]
--CONFIG_DEBUG_LOCK_ALLOC 無効: [[linux-2.6.33/kernel/mutex.c]]
-FIXME: これは何?
--説明
**引数 [#sf5da1d0]
-
-struct mutex *lock
--
--[[linux-2.6.33/mutex]]
**返り値 [#lae8a7c2]
-なし
**参考 [#yc2d0fc4]
*実装 [#uf432457]
**include/linux/mutex.h [#q37b1f0c]
#ifdef CONFIG_DEBUG_LOCK_ALLOC
-
--[[linux-2.6.33/CONFIG_DEBUG_LOCK_ALLOC]]
#define mutex_lock(lock) mutex_lock_nested(lock, 0)
(略)
-
--[[linux-2.6.33/mutex_lock_nested()]]
#else
-
extern void mutex_lock(struct mutex *lock);
(略)
-
#endif
**kernel/mutex.c [#s707b57f]
/***
* mutex_lock - acquire the mutex
* @lock: the mutex to be acquired
*
* Lock the mutex exclusively for this task. If the mutex is not
* available right now, it will sleep until it can get it.
*
* The mutex must later on be released by the same task that
* acquired it. Recursive locking is not allowed. The task
* may not exit without first unlocking the mutex. Also, kernel
* memory where the mutex resides mutex must not be freed with
* the mutex still locked. The mutex must first be initialized
* (or statically defined) before it can be locked. memset()-ing
* the mutex to 0 is not allowed.
*
* ( The CONFIG_DEBUG_MUTEXES .config option turns on debugging
* checks that will enforce the restrictions and will also do
* deadlock debugging. )
*
* This function is similar to (but not equivalent to) down().
*/
void __sched mutex_lock(struct mutex *lock)
{
might_sleep();
-
--[[linux-2.6.33/might_sleep()]]
/*
* The locking fastpath is the 1->0 transition from
* 'unlocked' into 'locked' state.
*/
__mutex_fastpath_lock(&lock->count, __mutex_lock_slowpath);
-高速にロックカウントを減らして、ミューテックスをロック状態にする。
--[[linux-2.6.33/__mutex_fastpath_lock()]]
-既にロックされていたら __mutex_lock_slowpath でロック状態にする。
--[[linux-2.6.33/__mutex_lock_slowpath()]]
mutex_set_owner(lock);
-現在実行中のタスクをミューテックスの所有者に設定する。
--[[linux-2.6.33/mutex_set_owner()]]
}
EXPORT_SYMBOL(mutex_lock);
-特にライセンスの区別なくシンボルを公開する。
--[[linux-2.6.33/EXPORT_SYMBOL()]]
*コメント [#u5b0e2fb]