---
name: "sc_ShmMemoryGrp"
section: "3"
platform: "linux"
package: "libsc-doc"
version: "2.3.1-22"
release: "Debian 12 (Bookworm)"
platforms: ["linux"]
url: "https://new.carta.tech/sc_ShmMemoryGrp"
---

# sc\_ShmMemoryGrp(3)

The ShmMemoryGrp concrete class provides an implementation of MsgMemoryGrp.

## NAME

sc::ShmMemoryGrp - The **ShmMemoryGrp** concrete class provides an implementation of **MsgMemoryGrp**.

## SYNOPSIS

`#include <memshm.h>`

Inherits **sc::MsgMemoryGrp**.

### Public Member Functions

**ShmMemoryGrp** (const **Ref**\< **MessageGrp** \> &msg)\
 **ShmMemoryGrp** (const **Ref**\< **KeyVal** \> &)\
 void **set\_localsize** (size\_t)\
 Set the size of locally held memory.  void \* **localdata** ()\
 Returns a pointer to the local data.  void \* **obtain\_readwrite** (**distsize\_t** **offset**, int **size**)\
 Only one thread can have an unreleased obtain\_readwrite at a time.  void \* **obtain\_readonly** (**distsize\_t** **offset**, int **size**)\
 This gives read access to the memory location. No locking is done.  void \* **obtain\_writeonly** (**distsize\_t** **offset**, int **size**)\
 This gives write access to the memory location. No locking is done.  void **release\_readonly** (void \*data, **distsize\_t** **offset**, int **size**)\
 This is called when read access is no longer needed.  void **release\_writeonly** (void \*data, **distsize\_t** **offset**, int **size**)\
 This is called when write access is no longer needed.  void **release\_readwrite** (void \*data, **distsize\_t** **offset**, int **size**)\
 This is called when read/write access is no longer needed.  void **print** (std::ostream &o=**ExEnv::out0**()) const\
 Prints out information about the object.

### Additional Inherited Members

## Detailed Description

The **ShmMemoryGrp** concrete class provides an implementation of **MsgMemoryGrp**.

It uses SYSV IPC to provided shared memory in a system that provide shared memory in hardware. It is very fast and reliable.

## Member Function Documentation

### void \* sc::ShmMemoryGrp::localdata ()` [virtual]`

Returns a pointer to the local data.

Implements **sc::MemoryGrp**.

### void \* sc::ShmMemoryGrp::obtain\_readonly (distsize\_t offset, int size)` [virtual]`

This gives read access to the memory location. No locking is done.

Implements **sc::MemoryGrp**.

### void \* sc::ShmMemoryGrp::obtain\_readwrite (distsize\_t offset, int size)` [virtual]`

Only one thread can have an unreleased obtain\_readwrite at a time. The actual memory region locked can be larger than that requested. If the memory region is already locked this will block. For this reason, data should be held as read/write for as short a time as possible.

Implements **sc::MemoryGrp**.

### void \* sc::ShmMemoryGrp::obtain\_writeonly (distsize\_t offset, int size)` [virtual]`

This gives write access to the memory location. No locking is done.

Implements **sc::MemoryGrp**.

### void sc::ShmMemoryGrp::print (std::ostream & o = ExEnv::out0`()`) const` [virtual]`

Prints out information about the object.

Reimplemented from **sc::MemoryGrp**.

### void sc::ShmMemoryGrp::release\_readonly (void \* data, distsize\_t offset, int size)` [virtual]`

This is called when read access is no longer needed.

Implements **sc::MemoryGrp**.

### void sc::ShmMemoryGrp::release\_readwrite (void \* data, distsize\_t offset, int size)` [virtual]`

This is called when read/write access is no longer needed. The memory will be unlocked.

Implements **sc::MemoryGrp**.

### void sc::ShmMemoryGrp::release\_writeonly (void \* data, distsize\_t offset, int size)` [virtual]`

This is called when write access is no longer needed.

Implements **sc::MemoryGrp**.

### void sc::ShmMemoryGrp::set\_localsize (size\_t)` [virtual]`

Set the size of locally held memory. When memory is accessed using a global offset counting starts at node 0 and proceeds up to node **n()** - 1.

Reimplemented from **sc::MsgMemoryGrp**.

## Author

Generated automatically by Doxygen for MPQC from the source code.
