Coda Distributed File System
Classes | Macros | Typedefs | Enumerations | Functions
lock.h File Reference
#include <lwp/lwp.h>
Include dependency graph for lock.h:

Go to the source code of this file.

Classes

struct  Lock
 

Macros

#define EXCL_LOCKS   (WRITE_LOCK | SHARED_LOCK)
 

Typedefs

typedef struct Lock Lock
 

Enumerations

enum  lock_how { READ_LOCK = 1 , WRITE_LOCK = 2 , SHARED_LOCK = 4 }
 

Functions

void Lock_Obtain (struct Lock *lock, int how)
 
void Lock_ReleaseR (struct Lock *lock)
 
void Lock_ReleaseW (struct Lock *lock)
 
void ObtainReadLock (struct Lock *lock)
 
void ObtainWriteLock (struct Lock *lock)
 
void ObtainSharedLock (struct Lock *lock)
 
void ReleaseReadLock (struct Lock *lock)
 
void ReleaseWriteLock (struct Lock *lock)
 
void ReleaseSharedLock (struct Lock *lock)
 
int CheckLock (struct Lock *lock)
 
int WriteLocked (struct Lock *lock)
 
void Lock_Init (struct Lock *lock)
 
void ObtainDualLock (struct Lock *lock_1, enum lock_how how_1, struct Lock *lock_2, enum lock_how how_2)
 
void ReleaseDualLock (struct Lock *lock_1, enum lock_how how_1, struct Lock *lock_2, enum lock_how how_2)
 

Macro Definition Documentation

◆ EXCL_LOCKS

#define EXCL_LOCKS   (WRITE_LOCK | SHARED_LOCK)

Typedef Documentation

◆ Lock

typedef struct Lock Lock

Enumeration Type Documentation

◆ lock_how

enum lock_how

Locking type

Enumerator
READ_LOCK 

lock for reading

WRITE_LOCK 

lock for writing

SHARED_LOCK 

as a shared lock

Function Documentation

◆ CheckLock()

int CheckLock ( struct Lock lock)

Check the status of the lock

Parameters
lockpointer to the lock
Returns
0 ff the lock is not acquired. If the lock is currently acquired for reading returns the amount of readers. And -1 if the lock is acquired obtained for writing or as a shared lock.

◆ Lock_Init()

void Lock_Init ( struct Lock lock)

Initialize the Lock structure

Parameters
lockpointer to the lock

◆ Lock_Obtain()

void Lock_Obtain ( struct Lock lock,
int  how 
)

Obtain the lock

Parameters
lockpointer to the lock
howlocking type

◆ Lock_ReleaseR()

void Lock_ReleaseR ( struct Lock lock)

Release lock obtained for reading

Parameters
lockpointer to the lock

◆ Lock_ReleaseW()

void Lock_ReleaseW ( struct Lock lock)

Release lock obtained for writing

Parameters
lockpointer to the lock

◆ ObtainDualLock()

void ObtainDualLock ( struct Lock lock_1,
enum lock_how  how_1,
struct Lock lock_2,
enum lock_how  how_2 
)

Safely obtain two simultaneous locks

Parameters
lock_1pointer to the first lock
how_1first lock's type
lock_2pointer to the second lock
how_2second lock's type

◆ ObtainReadLock()

void ObtainReadLock ( struct Lock lock)

Obtain the lock for reading

Parameters
lockpointer to the lock

◆ ObtainSharedLock()

void ObtainSharedLock ( struct Lock lock)

Obtain the lock as shared lock

Parameters
lockpointer to the lock

◆ ObtainWriteLock()

void ObtainWriteLock ( struct Lock lock)

Obtain the lock for writing

Parameters
lockpointer to the lock

◆ ReleaseDualLock()

void ReleaseDualLock ( struct Lock lock_1,
enum lock_how  how_1,
struct Lock lock_2,
enum lock_how  how_2 
)

Safely release two simultaneous locks

Parameters
lock_1pointer to the first lock
how_1first lock's type
lock_2pointer to the second lock
how_2second lock's type

◆ ReleaseReadLock()

void ReleaseReadLock ( struct Lock lock)

Release the lock obtained for reading

Parameters
lockpointer to the lock

◆ ReleaseSharedLock()

void ReleaseSharedLock ( struct Lock lock)

Release the lock obtained as a shared lock

Parameters
lockpointer to the lock

◆ ReleaseWriteLock()

void ReleaseWriteLock ( struct Lock lock)

Release the lock obtained for writing

Parameters
lockpointer to the lock

◆ WriteLocked()

int WriteLocked ( struct Lock lock)

Check if the lock was acquired for reading

Parameters
lockpointer to the lock
Returns
true (different than zero) if the lock is currently acquired for writing or as a shared lock. 0 otherwise.