Sponsored Content
Top Forums Programming Linux Shell Piping w/Shared Memory Post 302991488 by jim mcnamara on Saturday 11th of February 2017 08:14:01 AM
Old 02-11-2017
Welcome the the UNIX forums.

You do not use pipes with shared memory, necessarily. You are reading and writing in memory to your own process memory, part of which is shared among processes. So each child process is reading and writing it's own memory, too.

What you are talking about is IPC. Interprocess communication. Pipes are one method, shared memory segments are another. Pipes use physical files on disk, shared memory transfers data between processes using a segment of memory both processes 'own' and can read and usually write.

You need to do some reading, the help you need is beyond the scope of these forums.
If you get stuck we can help. This tutorial is written in an offhand conversational way, most people enjoy reading it.

Beej's Guide to Unix IPC

More formal:
6 Linux Interprocess Communications

Last edited by jim mcnamara; 02-11-2017 at 09:23 AM..
This User Gave Thanks to jim mcnamara For This Post:
 

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Shared memory shortage but lots of unused memory

I am running HP-UX B.11.11. I'm increasing a parameter for a database engine so that it uses more memory to buffer the disk drive (to speed up performance). I have over 5GB of memory not being used. But when I try to start the DB with the increased buffer parameter I get told. "Not... (1 Reply)
Discussion started by: cjcamaro
1 Replies

2. Linux

all about shared memory

Hi all :confused: , I am new to unix.I have been asked to implement shared memory in user's mode.What does this mean?What is the difference it makes in kernel mode and in users mode?What are the advantages of this impemenation(user's mode)? And also i would like to know why exactly shared... (0 Replies)
Discussion started by: vijaya2006
0 Replies

3. Programming

memory sharing - not shared memory -

hi, this is the problem: i want to swap a linked list between 4 processes (unrelated), is there any way i can do that just by sending a pointer to a structure? //example typedef struct node { int x; char c; struct node *next; } node; or i should send the items ( x,c ) by... (9 Replies)
Discussion started by: elzalem
9 Replies

4. Programming

Shared memory in shared library

I need to create a shared library to access an in memory DB. The DB is not huge, but big enough to make it cumbersome to carry around in every single process using the shared library. Luckily, it is pretty static information, so I don't need to worry much about synchronizing the data between... (12 Replies)
Discussion started by: DreamWarrior
12 Replies

5. Programming

Shared memory for shared library

I am writing a shared library in Linux (but compatible with other UNIXes) and I want to allow multiple instances to share a piece of memory -- 1 byte is enough. What's the "best" way to do this? I want to optimize for speed and portability. Obviously, I'll have to worry about mutual exclusion. (0 Replies)
Discussion started by: otheus
0 Replies

6. Red Hat

about shared memory space in Linux !

Dear Friends , I am confused about shared memory in Linux . plz look @ the below output : $ df -h Filesystem Size Used Avail Use% Mounted on /dev/sda1 126G 61G 59G 52% / tmpfs 1.7G 0 1.7G 0% /dev/shm Here , I see that every time... (1 Reply)
Discussion started by: shipon_97
1 Replies

7. Red Hat

Shared memory in linux

Hello, I am using Linux os. $ df -k /dev/shm Filesystem 1K-blocks Used Available Use% Mounted on tmpfs 2023256 1065000 958256 53% /dev/shm $ Based on my google this, it is shared memory. What is this shared memory and where exactly it is used? Can you... (5 Replies)
Discussion started by: govindts
5 Replies

8. Red Hat

Unable to remove shared memory in Redhat Linux

unable to remove shared memory using ipcrm -m in linux $ ipcs -m ------ Shared Memory Segments -------- key shmid owner perms bytes nattch status 0x00000000 32768 root 644 80 2 0x00000000 65537 root ... (4 Replies)
Discussion started by: LinuxLearner
4 Replies

9. Programming

Shared library with acces to shared memory.

Hello. I am new to this forum and I would like to ask for advice about low level POSIX programming. I have to implement a POSIX compliant C shared library. A file will have some variables and the shared library will have some functions which need those variables. There is one special... (5 Replies)
Discussion started by: iamjag
5 Replies
SHMAT(3P)						     POSIX Programmer's Manual							 SHMAT(3P)

PROLOG
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the correspond- ing Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux. NAME
shmat - XSI shared memory attach operation SYNOPSIS
#include <sys/shm.h> void *shmat(int shmid, const void *shmaddr, int shmflg); DESCRIPTION
The shmat() function operates on XSI shared memory (see the Base Definitions volume of IEEE Std 1003.1-2001, Section 3.340, Shared Memory Object). It is unspecified whether this function interoperates with the realtime interprocess communication facilities defined in Realtime . The shmat() function attaches the shared memory segment associated with the shared memory identifier specified by shmid to the address space of the calling process. The segment is attached at the address specified by one of the following criteria: * If shmaddr is a null pointer, the segment is attached at the first available address as selected by the system. * If shmaddr is not a null pointer and (shmflg &SHM_RND) is non-zero, the segment is attached at the address given by (shmaddr -((uintptr_t)shmaddr %SHMLBA)). The character '%' is the C-language remainder operator. * If shmaddr is not a null pointer and (shmflg &SHM_RND) is 0, the segment is attached at the address given by shmaddr. * The segment is attached for reading if (shmflg &SHM_RDONLY) is non-zero and the calling process has read permission; otherwise, if it is 0 and the calling process has read and write permission, the segment is attached for reading and writing. RETURN VALUE
Upon successful completion, shmat() shall increment the value of shm_nattch in the data structure associated with the shared memory ID of the attached shared memory segment and return the segment's start address. Otherwise, the shared memory segment shall not be attached, shmat() shall return -1, and errno shall be set to indicate the error. ERRORS
The shmat() function shall fail if: EACCES Operation permission is denied to the calling process; see XSI Interprocess Communication . EINVAL The value of shmid is not a valid shared memory identifier, the shmaddr is not a null pointer, and the value of (shmaddr -((uintptr_t)shmaddr %SHMLBA)) is an illegal address for attaching shared memory; or the shmaddr is not a null pointer, (shmflg &SHM_RND) is 0, and the value of shmaddr is an illegal address for attaching shared memory. EMFILE The number of shared memory segments attached to the calling process would exceed the system-imposed limit. ENOMEM The available data space is not large enough to accommodate the shared memory segment. The following sections are informative. EXAMPLES
None. APPLICATION USAGE
The POSIX Realtime Extension defines alternative interfaces for interprocess communication. Application developers who need to use IPC should design their applications so that modules using the IPC routines described in XSI Interprocess Communication can be easily modified to use the alternative interfaces. RATIONALE
None. FUTURE DIRECTIONS
None. SEE ALSO
XSI Interprocess Communication, Realtime, exec() , exit(), fork(), shmctl(), shmdt(), shmget(), shm_open(), shm_unlink(), the Base Defini- tions volume of IEEE Std 1003.1-2001, <sys/shm.h> COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2003 Edition, Standard for Information Technol- ogy -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html . IEEE
/The Open Group 2003 SHMAT(3P)
All times are GMT -4. The time now is 07:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy