Coda Distributed File System
Functions
lock_pt.c File Reference
#include <pthread.h>
#include <assert.h>
#include <lwp/lwp.h>
#include <lwp/lock.h>
#include "lwp.private_pt.h"
Include dependency graph for lock_pt.c:

Functions

void Lock_Init (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)
 

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

◆ 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

◆ 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.