Data Fields
shm_arena Struct Reference

Data Fields

int fd
 
struct arena_headerheader
 
struct shm_mappingmapping
 
int num_mappings
 
uint32_t change_count
 
pthread_mutex_t mapping_mutex
 
pthread_mutex_t rwlock_mutex
 
pthread_key_t rwlock_key
 
void * user_shm_address
 

Detailed Description

local arena object data

Definition at line 430 of file arena.h.

Field Documentation

uint32_t shm_arena::change_count

change_count will be compared with the arena_header change_count in the shared memory arena file to see if the local process object mappings are up to date with the arena file.

Definition at line 464 of file arena.h.

Referenced by shm_arena_create(), shm_arena_print(), shm_arena_print_dot(), shm_arena_print_list(), shm_get(), shm_name(), shm_remove(), shm_remove_name(), shm_size(), and shm_size_name().

int shm_arena::fd

fd is the file descriptor of the arena file being mapped. We could have saved arena filename and closed the file after each mapping change, but that would make the re-openings fail if the file was unlinked before the re-opening and mapping changes.

Definition at line 436 of file arena.h.

Referenced by shm_arena_create(), shm_arena_delete(), and shm_arena_destroy().

struct arena_header* shm_arena::header

header points to the first mapping, mapping[0], which will never change in position or length for the life of the arena object, so we don't need a mutex to access it. It's also special because it has the arena header in it. We have this in addition to an allocated array of mappings. This makes it easier to make this code thread-safe, accessing the arena header in a thread-safe manner would be a real pain if used the array of mappings in mapping below.

Definition at line 446 of file arena.h.

Referenced by shm_arena_create(), shm_arena_print(), shm_arena_print_dot(), shm_arena_print_list(), shm_get(), shm_name(), shm_remove(), shm_remove_name(), shm_size(), and shm_size_name().

struct shm_mapping* shm_arena::mapping

local process memory mappings realloc() is used to add to this array of pointers. This is not NULL terminated. arena->mapping[0].start has the same address as arena->header. Since this is re-allocated when mappings are added or removed we needed header to access mapping[0].start in an easily thread-safe manner.

Definition at line 454 of file arena.h.

Referenced by shm_arena_create(), shm_arena_delete(), shm_arena_print(), shm_arena_print_list(), and shm_remove().

pthread_mutex_t shm_arena::mapping_mutex

Intra-process thread protects mapping, change_count, and num_mappings in each arena object.

Definition at line 468 of file arena.h.

Referenced by shm_arena_create(), shm_arena_print(), shm_arena_print_dot(), shm_arena_print_list(), shm_get(), shm_name(), shm_size(), and shm_size_name().

int shm_arena::num_mappings

number of mappings that are mapped in this local process object in addition to the first mapping. The array mapping (above) is of size num_mappings.

Definition at line 459 of file arena.h.

Referenced by shm_arena_create(), shm_arena_delete(), shm_arena_print(), shm_arena_print_list(), and shm_remove().

pthread_key_t shm_arena::rwlock_key

Key used to get pre-thread recursive arena read-write locks data, which is a struct rwlock_attr. This makes it so that each thread gets and knows that is has the inter-process arena read or write lock.

Definition at line 479 of file arena.h.

Referenced by shm_arena_create(), and shm_arena_delete().

pthread_mutex_t shm_arena::rwlock_mutex

Intra-process thread protects the struct rwlock_attr that is a pre-thread attribute that is keyed with rwlock_key for each arena object.

Definition at line 473 of file arena.h.

Referenced by shm_arena_create().

void* shm_arena::user_shm_address

flag that tells if environment variable SHM_ADDRESS was set when this struct was created. Is NULL if SHM_ADDRESS was not set; is the address if it was set.

Definition at line 484 of file arena.h.

Referenced by shm_arena_create().


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

Shared Memory Arena version RC-0.0.25