My Project
Loading...
Searching...
No Matches
vspace Namespace Reference

Namespaces

namespace  internals

Data Structures

struct  Result
struct  Status
struct  VRef
struct  VRef< void >
struct  ZRef
class  VString
class  VMap
struct  DictSpec
class  Semaphore
class  Queue
class  SyncVar
class  Event
class  EventSet
class  WaitSemaphoreEvent
class  EnqueueEvent
class  DequeueEvent
class  SyncReadEvent

Typedefs

typedef VMap< DictSpecVDict
typedef internals::Mutex FastLock
typedef internals::Mutex Mutex

Enumerations

enum  ErrCode {
  ErrNone , ErrGeneral , ErrFile , ErrMMap ,
  ErrOS
}

Functions

pid_t fork_process ()
static Status vmem_init ()
static void vmem_deinit ()
template<typename T>
VRef< Tvnull ()
template<typename T>
VRef< Tvnew ()
template<typename T>
VRef< Tvnew_uninitialized ()
template<typename T>
VRef< Tvnew_array (size_t n)
template<typename T>
VRef< Tvnew_uninitialized_array (size_t n)
template<typename T, typename Arg>
VRef< Tvnew (Arg arg)
template<typename T, typename Arg1, typename Arg2>
VRef< Tvnew (Arg1 arg1, Arg2 arg2)
template<typename T, typename Arg1, typename Arg2, typename Arg3>
VRef< Tvnew (Arg1 arg1, Arg2 arg2, Arg3 arg3)
template<typename T, typename Arg1, typename Arg2, typename Arg3, typename Arg4>
VRef< Tvnew (Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4)
template<typename T, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5>
VRef< Tvnew (Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5)
template<typename T>
ZRef< Tznull ()
template<typename T>
ZRef< Tznew ()
template<typename T>
ZRef< Tznew_uninitialized ()
template<typename T>
ZRef< Tznew_array (size_t n)
template<typename T>
ZRef< Tznew_uninitialized_array (size_t n)
template<typename T, typename Arg>
ZRef< Tznew (Arg arg)
template<typename T, typename Arg1, typename Arg2>
ZRef< Tznew (Arg1 arg1, Arg2 arg2)
template<typename T, typename Arg1, typename Arg2, typename Arg3>
ZRef< Tznew (Arg1 arg1, Arg2 arg2, Arg3 arg3)
static VRef< VStringvstring (const char *s)
static VRef< VStringvstring (const char *s, size_t len)
static VRef< VStringvstring (size_t len)

Typedef Documentation

◆ FastLock

Definition at line 2340 of file vspace.h.

◆ Mutex

Definition at line 2343 of file vspace.h.

◆ VDict

Definition at line 2333 of file vspace.h.

Enumeration Type Documentation

◆ ErrCode

Enumerator
ErrNone 
ErrGeneral 
ErrFile 
ErrMMap 
ErrOS 

Definition at line 1375 of file vspace.h.

1375 {
1376 ErrNone,
1377 ErrGeneral,
1378 ErrFile,
1379 ErrMMap,
1380 ErrOS,
1381};
@ ErrGeneral
Definition vspace.h:1377
@ ErrOS
Definition vspace.h:1380
@ ErrNone
Definition vspace.h:1376
@ ErrFile
Definition vspace.h:1378
@ ErrMMap
Definition vspace.h:1379

Function Documentation

◆ fork_process()

pid_t vspace::fork_process ( )

Definition at line 1108 of file vspace.cc.

1108 {
1109 using namespace internals;
1110 lock_metapage();
1111 for (int p = 0; p < MAX_PROCESS; p++) {
1112 if (vmem.metapage->process_info[p].pid == 0) {
1113 pid_t pid = fork();
1114 if (pid < 0) {
1115 // error
1116 return -1;
1117 } else if (pid == 0) {
1118 // child process
1119 int parent = vmem.current_process;
1120 vmem.current_process = p;
1121 lock_metapage();
1122 vmem.metapage->process_info[p].pid = getpid();
1123 unlock_metapage();
1124 send_signal(parent);
1125 } else {
1126 // parent process
1128 wait_signal();
1129 // child has unlocked metapage, so we don't need to.
1130 }
1131 return pid;
1132 }
1133 }
1135 return -1;
1136}
int p
Definition cfModGcd.cc:4086
void unlock_metapage()
Definition vspace.cc:950
ipc_signal_t wait_signal(bool lock)
Definition vspace.cc:1102

◆ vmem_deinit()

void vspace::vmem_deinit ( )
inlinestatic

Definition at line 1742 of file vspace.h.

1742 {
1743 internals::vmem.deinit();
1744}
static VMem & vmem
Definition vspace.h:1635

◆ vmem_init()

Status vspace::vmem_init ( )
inlinestatic

Definition at line 1738 of file vspace.h.

1738 {
1739 return internals::vmem.init();
1740}

◆ vnew() [1/6]

template<typename T>
VRef< T > vspace::vnew ( )

Definition at line 1872 of file vspace.h.

1872 {
1874 new (result.to_ptr()) T();
1875 return result;
1876}
return result
STATIC_VAR jList * T
Definition janet.cc:30
static VRef< T > alloc(size_t n=1)
Definition vspace.h:1802

◆ vnew() [2/6]

template<typename T, typename Arg>
VRef< T > vspace::vnew ( Arg arg)

Definition at line 1901 of file vspace.h.

1901 {
1903 new (result.to_ptr()) T(arg);
1904 return result;
1905}

◆ vnew() [3/6]

template<typename T, typename Arg1, typename Arg2>
VRef< T > vspace::vnew ( Arg1 arg1,
Arg2 arg2 )

Definition at line 1908 of file vspace.h.

1908 {
1910 new (result.to_ptr()) T(arg1, arg2);
1911 return result;
1912}

◆ vnew() [4/6]

template<typename T, typename Arg1, typename Arg2, typename Arg3>
VRef< T > vspace::vnew ( Arg1 arg1,
Arg2 arg2,
Arg3 arg3 )

Definition at line 1915 of file vspace.h.

1915 {
1917 new (result.to_ptr()) T(arg1, arg2, arg3);
1918 return result;
1919}

◆ vnew() [5/6]

template<typename T, typename Arg1, typename Arg2, typename Arg3, typename Arg4>
VRef< T > vspace::vnew ( Arg1 arg1,
Arg2 arg2,
Arg3 arg3,
Arg4 arg4 )

Definition at line 1923 of file vspace.h.

1923 {
1925 new (result.to_ptr()) T(arg1, arg2, arg3, arg4);
1926 return result;
1927}

◆ vnew() [6/6]

template<typename T, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5>
VRef< T > vspace::vnew ( Arg1 arg1,
Arg2 arg2,
Arg3 arg3,
Arg4 arg4,
Arg5 arg5 )

Definition at line 1931 of file vspace.h.

1931 {
1933 new (result.to_ptr()) T(arg1, arg2, arg3, arg4, arg5);
1934 return result;
1935}

◆ vnew_array()

template<typename T>
VRef< T > vspace::vnew_array ( size_t n)

Definition at line 1885 of file vspace.h.

1885 {
1887 T *ptr = result.as_ptr();
1888 for (size_t i = 0; i < n; i++) {
1889 new (ptr + i) T();
1890 }
1891 return result;
1892}
int i
Definition cfEzgcd.cc:132

◆ vnew_uninitialized()

template<typename T>
VRef< T > vspace::vnew_uninitialized ( )

Definition at line 1879 of file vspace.h.

1879 {
1881 return result;
1882}

◆ vnew_uninitialized_array()

template<typename T>
VRef< T > vspace::vnew_uninitialized_array ( size_t n)

Definition at line 1895 of file vspace.h.

1895 {
1897 return result;
1898}

◆ vnull()

template<typename T>
VRef< T > vspace::vnull ( )

Definition at line 1867 of file vspace.h.

1867 {
1869}
const vaddr_t VADDR_NULL
Definition vspace.h:1417
static VRef< T > from_vaddr(internals::vaddr_t vaddr)
Definition vspace.h:1755

◆ vstring() [1/3]

VRef< VString > vspace::vstring ( const char * s)
inlinestatic

Definition at line 2101 of file vspace.h.

2101 {
2102 return vnew<VString>(s);
2103}
const CanonicalForm int s
Definition facAbsFact.cc:51
VRef< T > vnew()
Definition vspace.h:1872

◆ vstring() [2/3]

VRef< VString > vspace::vstring ( const char * s,
size_t len )
inlinestatic

Definition at line 2105 of file vspace.h.

2105 {
2106 return vnew<VString>(s, len);
2107}

◆ vstring() [3/3]

VRef< VString > vspace::vstring ( size_t len)
inlinestatic

Definition at line 2109 of file vspace.h.

2109 {
2110 return vnew<VString>(len);
2111}

◆ znew() [1/4]

template<typename T>
ZRef< T > vspace::znew ( )

Definition at line 2015 of file vspace.h.

2015 {
2017 new (result.to_ptr()) T();
2018 return result;
2019}
static internals::vaddr_t alloc()
Definition vspace.h:2004

◆ znew() [2/4]

template<typename T, typename Arg>
ZRef< T > vspace::znew ( Arg arg)

Definition at line 2044 of file vspace.h.

2044 {
2046 new (result.to_ptr()) T(arg);
2047 return result;
2048}

◆ znew() [3/4]

template<typename T, typename Arg1, typename Arg2>
ZRef< T > vspace::znew ( Arg1 arg1,
Arg2 arg2 )

Definition at line 2051 of file vspace.h.

2051 {
2053 new (result.to_ptr()) T(arg1, arg2);
2054 return result;
2055}

◆ znew() [4/4]

template<typename T, typename Arg1, typename Arg2, typename Arg3>
ZRef< T > vspace::znew ( Arg1 arg1,
Arg2 arg2,
Arg3 arg3 )

Definition at line 2058 of file vspace.h.

2058 {
2060 new (result.to_ptr()) T(arg1, arg2, arg3);
2061 return result;
2062}

◆ znew_array()

template<typename T>
ZRef< T > vspace::znew_array ( size_t n)

Definition at line 2028 of file vspace.h.

2028 {
2030 T *ptr = result.as_ptr();
2031 for (size_t i = 0; i < n; i++) {
2032 new (ptr + i) T();
2033 }
2034 return result;
2035}

◆ znew_uninitialized()

template<typename T>
ZRef< T > vspace::znew_uninitialized ( )

Definition at line 2022 of file vspace.h.

2022 {
2024 return result;
2025}

◆ znew_uninitialized_array()

template<typename T>
ZRef< T > vspace::znew_uninitialized_array ( size_t n)

Definition at line 2038 of file vspace.h.

2038 {
2040 return result;
2041}

◆ znull()

template<typename T>
ZRef< T > vspace::znull ( )

Definition at line 2010 of file vspace.h.

2010 {
2012}