Writing values to a shared memory segment

write_shared_memory()

Writing values to shared memory


SYNTAX

write_shared_memory(shm_id, offset, len, options)

Writes the current field values from the associated record buffer into the shared memory segment specified in shm_id . Sculptor ensures that this operation is atomic so that other programs cannot read a partly updated record.

The associated record buffer was specified in the function call that created or linked to the segment.

shm_id

The return value from the function that created or linked to the segment.

offset

The byte offset within the record to start writing from. This feature is for advanced use, and should normally be set to 0.

len

The number of bytes to write. This feature is for advanced use. Set to 0 to write the entire record.

options

May be SHM_KEEP_LOCK or 0.

If options is SHM_KEEP_LOCK, Sculptor prevents other programs writing to the shared memory segment until this program calls write_shared_memory() or read_shared_memory() with options = 0, or calls unlock_shared_memory(). It is very important to hold this lock for a short time only since, when it is set, other programs that try to access this memory segment will go into a non-responding state.

The function returns the number of bytes written.


Shared memory functions

create_shared_memory()

Create a shared memory segment

link_shared_memory()

Link to an existing shared memory segment

read_shared_memory()

Read the current field values from shared memory into associated record buffer

write_shared_memory()

Write the current values from associated record buffer into shared memory

unlock_shared_memory()

Unlock a shared memory segment

unlink_shared_memory()

Unlink a program from a shared memory segment


RELATED TOPICS

Shared memory options in sculptor.h

!record

![o]file