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

# sc\_ShmMessageGrp(3)

The ShmMessageGrp class is an implementation of MessageGrp that allows multiple process to be started that communicate with shared memory.

## NAME

sc::ShmMessageGrp - The **ShmMessageGrp** class is an implementation of **MessageGrp** that allows multiple process to be started that communicate with shared memory.

## SYNOPSIS

`#include <messshm.h>`

Inherits **sc::intMessageGrp**.

### Public Member Functions

**ShmMessageGrp** ()\
 Reads the number of processors from environmental variable NUMPROC.  **ShmMessageGrp** (const **Ref**\< **KeyVal** \> &)\
 The **ShmMessageGrp** **KeyVal** constructor takes a single keyword that specifies the number of processors.  **ShmMessageGrp** (int nprocs)\
 Initialize **ShmMessageGrp** to use nprocs processors.  void **sync** ()\
 Synchronize all of the processors.  **Ref**\< **MessageGrp** \> **clone** (void)\
 Returns a copy of this **MessageGrp** specialization that provides an independent communication context.

### Protected Member Functions

void **basic\_send** (int target, int type, const void \*data, int nbyte)\
 Must be implemented by specializations.  void **basic\_recv** (int type, void \*data, int nbyte)\
 Must be implemented by specializations.  int **basic\_probe** (int type)\
 Must be implemented by specializations.  void **initialize** (int nprocs)\
 void **initialize** ()\
 **msgbuf\_t** \* **NEXT\_MESSAGE** (**msgbuf\_t** \*m)\
 void **get\_change** (int node)\
 void **put\_change** (int node)\
 void **wait\_for\_write** (int node)\
 void **release\_write** (int node)\
 void **print\_buffer** (int node, int **me**)\

### Protected Attributes

**commbuf\_t** \* **commbuf** \[MAXPROCS\]\
 int **shmid**\
 int **semid**\
 int **change\_semid**\
 void \* **sharedmem**\
 struct sembuf **semdec**\
 struct sembuf **seminc**\

### Additional Inherited Members

## Detailed Description

The **ShmMessageGrp** class is an implementation of **MessageGrp** that allows multiple process to be started that communicate with shared memory.

This only provides improved performance if you have multiple CPU's in a symmetric multiprocessor configuration. Nonetheless, it is quite useful on a single CPU for tracking down bugs.

## Constructor & Destructor Documentation

### sc::ShmMessageGrp::ShmMessageGrp (const Ref\< KeyVal \> &)

The **ShmMessageGrp** **KeyVal** constructor takes a single keyword that specifies the number of processors. Here is an example of a **ParsedKeyVal** input that creates a **ShmMessageGrp** that runs on four processors:

```
message<ShmMessageGrp>: n = 4
```

## Member Function Documentation

### int sc::ShmMessageGrp::basic\_probe (int type)` [protected]`, ` [virtual]`

Must be implemented by specializations.

Implements **sc::intMessageGrp**.

### void sc::ShmMessageGrp::basic\_recv (int type, void \* data, int nbyte)` [protected]`, ` [virtual]`

Must be implemented by specializations.

Implements **sc::intMessageGrp**.

### void sc::ShmMessageGrp::basic\_send (int target, int type, const void \* data, int nbyte)` [protected]`, ` [virtual]`

Must be implemented by specializations.

Implements **sc::intMessageGrp**.

### Ref\< MessageGrp \> sc::ShmMessageGrp::clone (void)` [virtual]`

Returns a copy of this **MessageGrp** specialization that provides an independent communication context.

Implements **sc::MessageGrp**.

### void sc::ShmMessageGrp::sync ()` [virtual]`

Synchronize all of the processors.

Reimplemented from **sc::MessageGrp**.

## Author

Generated automatically by Doxygen for MPQC from the source code.
