Loading...
Searching...
No Matches
vspace::internals::Mutex Class Reference

`#include <vspace.h>`

## Public Member Functions

| Mutex ()
| ~Mutex ()
void | lock ()
void | unlock ()

## Private Attributes

int | _owner
int | _locklevel
vaddr_t | _lock

## Detailed Description

Definition at line 1706 of file vspace.h.

## Constructor & Destructor Documentation

## Mutex()

vspace::internals::Mutex::Mutex | ( |  | ) |

inline

Definition at line 1713 of file vspace.h.

: _owner(-1), _locklevel(0), _lock(vmem_alloc(1)) {
}
vspace::internals::Mutex::_lock
vaddr_t _lock
Definition vspace.h:1710
vspace::internals::Mutex::_owner
int _owner
Definition vspace.h:1708
vspace::internals::Mutex::_locklevel
int _locklevel
Definition vspace.h:1709
vspace::internals::vmem_alloc
vaddr_t vmem_alloc(size_t size)
Definition vspace.cc:854

## ~Mutex()

vspace::internals::Mutex::~Mutex | ( |  | ) |

inline

Definition at line 1715 of file vspace.h.

{
vmem_free(_lock);
}
vspace::internals::vmem_free
void vmem_free(vaddr_t vaddr)
Definition vspace.cc:802

## Member Function Documentation

## lock()

void vspace::internals::Mutex::lock | ( |  | ) |

inline

Definition at line 1718 of file vspace.h.

{
if (_owner == vmem.current_process) {
_locklevel++;
} else {
lock_file(vmem.fd, METABLOCK_SIZE + _lock);
_owner = vmem.current_process;
_locklevel = 1;
}
}
vspace::internals::lock_file
void lock_file(int fd, size_t offset, size_t len)
Definition vspace.cc:913
vspace::internals::METABLOCK_SIZE
static const size_t METABLOCK_SIZE
Definition vspace.h:1420
vspace::internals::vmem
static VMem & vmem
Definition vspace.h:1635
vspace::internals::VMem::fd
int fd
Definition vspace.h:1590
vspace::internals::VMem::current_process
int current_process
Definition vspace.h:1592

## unlock()

void vspace::internals::Mutex::unlock | ( |  | ) |

inline

Definition at line 1727 of file vspace.h.

{
if (--_locklevel == 0) {
assert(_owner == vmem.current_process);
_owner = -1;
unlock_file(vmem.fd, METABLOCK_SIZE + _lock);
}
}
vspace::internals::unlock_file
void unlock_file(int fd, size_t offset, size_t len)
Definition vspace.cc:919
assert
#define assert(A)
Definition svd_si.h:3

## Field Documentation

## _lock

vaddr_t vspace::internals::Mutex::_lock

private

Definition at line 1710 of file vspace.h.

## _locklevel

int vspace::internals::Mutex::_locklevel

private

Definition at line 1709 of file vspace.h.

## _owner

int vspace::internals::Mutex::_owner

private

Definition at line 1708 of file vspace.h.

The documentation for this class was generated from the following file:

- kernel/oswrapper/vspace.h