My Project
Public Member Functions | Private Attributes
vspace::internals::FastLock Class Reference

#include <vspace.h>

Public Member Functions

 FastLock (vaddr_t offset=0)
 
void lock ()
 
void unlock ()
 

Private Attributes

vaddr_t _offset
 

Detailed Description

Definition at line 98 of file vspace.h.

Constructor & Destructor Documentation

◆ FastLock()

vspace::internals::FastLock::FastLock ( vaddr_t  offset = 0)
inline

Definition at line 112 of file vspace.h.

112  : _offset(offset) {
113  }
STATIC_VAR int offset
Definition: janet.cc:29

Member Function Documentation

◆ lock()

void vspace::internals::FastLock::lock ( )

Definition at line 120 of file vspace.cc.

120  {
121 #ifdef HAVE_CPP_THREADS
122  while (_lock.test_and_set()) {
123  }
124  bool empty = _owner < 0;
125  if (empty) {
126  _owner = vmem.current_process;
127  } else {
128  int p = vmem.current_process;
129  vmem.metapage->process_info[p].next = -1;
130  if (_head < 0)
131  _head = p;
132  else
133  vmem.metapage->process_info[_tail].next = p;
134  _tail = p;
135  }
136  _lock.clear();
137  if (!empty)
138  wait_signal(false);
139 #else
141 #endif
142 }
int p
Definition: cfModGcd.cc:4078
void lock_file(int fd, size_t offset, size_t len)
Definition: vspace.cc:294
ipc_signal_t wait_signal(bool lock)
Definition: vspace.cc:413
static VMem & vmem
Definition: vspace.h:300
ProcessInfo process_info[MAX_PROCESS]
Definition: vspace.h:180
MetaPage * metapage
Definition: vspace.h:253

◆ unlock()

void vspace::internals::FastLock::unlock ( )

Definition at line 144 of file vspace.cc.

144  {
145 #ifdef HAVE_CPP_THREADS
146  while (_lock.test_and_set()) {
147  }
148  _owner = _head;
149  if (_owner >= 0)
150  _head = vmem.metapage->process_info[_head].next;
151  _lock.clear();
152  if (_owner >= 0)
153  send_signal(_owner, 0, false);
154 #else
156 #endif
157 }
void unlock_file(int fd, size_t offset, size_t len)
Definition: vspace.cc:300
bool send_signal(int processno, ipc_signal_t sig, bool lock)
Definition: vspace.cc:347

Field Documentation

◆ _offset

vaddr_t vspace::internals::FastLock::_offset
private

Definition at line 104 of file vspace.h.


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