| 総合手引 | セクション 9 | English | オプション |
#include <sys/param.h>
#include <sys/lock.h>
#include <sys/vnode.h>
引数は以下の通りです。
| vp | |||||||||||||||||||||||||||||||
| ロックまたはロック解除される vnode。 | |||||||||||||||||||||||||||||||
| flags | |||||||||||||||||||||||||||||||
以下のロック要求タイプのひとつ。
ロックタイプは、以下のロックフラグと OR されているかもしれません。
ロックタイプは、以下の制御フラグと OR されているかもしれません。
| |||||||||||||||||||||||||||||||
| td | |||||||||||||||||||||||||||||||
| ロックを使用するためのスレッドコンテキスト。 | |||||||||||||||||||||||||||||||
カーネルコードは vnode をロックするために VOP_LOCK() を直接呼び出さずに、 vn_lock() を使用するべきです。
struct vopnode {
int von_flag;
/*
* 他のファイルシステム固有データ
*/
...;
};
#define VON_LOCKED 1
#define VON_WANTED 2
#define VTOVON(vp) ((struct vopnode *) (vp)->v_data)
int
vop_lock(struct vnode *vp)
{
struct vopnode* vop;
start:
while (vp->v_flag & VXLOCK) {
vp->v_flag |= VXWANT;
tsleep((caddr_t)vp, PINOD, "voplk1", 0);
}
if (vp->v_tag == VT_NON)
return ENOENT;
vop = VTOVON(vp);
if (vop->von_flag & VON_LOCKED) {
vop->von_flag |= VON_WANTED;
tsleep((caddr_t) vop, PINOD, "voplk2", 0);
goto start;
}
vop->von_flag |= VON_LOCKED;
return 0;
}
int
vop_unlock(struct vnode *vp)
{
struct vopnode *vop = VTOVON(vp);
if ((vop->von_flag & VON_LOCKED) == 0) {
panic("vop_unlock not locked");
}
vop->von_flag &= ~VON_LOCKED;
if (vop->von_flag & VON_WANTED) {
vop->von_flag &= ~VON_WANTED;
wakeup((caddr_t) vop);
}
return 0;
}
int
vop_islocked(struct vnode *vp)
{
struct vopnode *vop = VTOVON(vp);
if (vop->von_flag & VON_LOCKED)
return 1;
else
return 0;
}
| VOP_LOCK (9) | July 24, 1996 |
| 総合手引 | セクション 9 | English | オプション |
このマニュアルページサービスについてのご意見は Ben Bullock にお知らせください。 Privacy policy.
| “ | "I liken starting one's computing career with Unix, say as an undergraduate, to being born in East Africa. It is intolerably hot, your body is covered with lice and flies, you are malnourished and you suffer from numerous curable diseases. But, as far as young East Africans can tell, this is simply the natural condition and they live within it. By the time they find out differently, it is too late. They already think that the writing of shell scripts is a natural act." | ” |
| — Ken Pier, Xerox PARC | ||