Sponsored Content
Top Forums Programming Shared Memory Between C Programs Post 302513522 by cmcmanus3 on Wednesday 13th of April 2011 12:32:42 PM
Old 04-13-2011
Shared Memory Between C Programs

I'm involved in a project with multiple teams which are developing C code for a Linux machine and we would like to have our program pass data to one of the other group's programs. The immediate idea is to have shared memory between the programs which would simply consist of variables whose size and offset from the beginning of the file are specified and have one program read from it while the other writes to it.

Will we run into any problems if we simply treat this file like any other file in our respective programs (i.e. fd = open(....) and just write to/read from fd at our leisure) or are there special steps that need to be taken in order to avoid simultaneously accessing the same data or something of that nature?
 

10 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. UNIX for Advanced & Expert Users

Memory resident programs

How can you make a program as Memory resident in AIX. If I make a program as a memory resident program whether all the parts of the program like code and data (stack) segements of the program will be loaded in to the Memory. For Ex: I have a C code which is creating array of 10000 long ints... (4 Replies)
Discussion started by: Pola Balaji
4 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. UNIX for Dummies Questions & Answers

What programs access shared library file

I was curious how to tell which programs are accessing a file (libobjc.A.dylib) in /usr/lib This file seems to be the culprit in a bunch of Safari crashes, and I just wanted to know if and what other programs use it. Also, I was curious what a good way to find out what files are being written... (4 Replies)
Discussion started by: glev2005
4 Replies

7. UNIX for Advanced & Expert Users

Shared hosting, how to install programs and libraries in your home folder

Hi all I hope I am posting in the right section. If not please excuse me and redirect me to the right section. Here is my problem: I am using a shared hosting plan at Godady. I have shell access and of course my own folder. I would like to be able to install programs in my own folder... (4 Replies)
Discussion started by: PiniFarini
4 Replies

8. 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

9. Shell Programming and Scripting

Use programs in shared folder except ones in my home dir

(0 Replies)
Discussion started by: beca123456
0 Replies

10. UNIX for Dummies Questions & Answers

Use programs in shared folder except ones in my home dir

I am using a cluster where all the programs are located in a shared folder (I can only read but not modify anything in this folder). The path of the share folder is in my .bashrc file (and thus also in my $PATH - first position): source /home/shared/bashrc But some of the programs are... (5 Replies)
Discussion started by: beca123456
5 Replies
SETFSGID(2)						     Linux Programmer's Manual						       SETFSGID(2)

NAME
setfsgid - set group identity used for file system checks SYNOPSIS
#include <unistd.h> /* glibc uses <sys/fsuid.h> */ int setfsgid(uid_t fsgid); DESCRIPTION
The system call setfsgid() sets the group ID that the Linux kernel uses to check for all accesses to the file system. Normally, the value of fsgid will shadow the value of the effective group ID. In fact, whenever the effective group ID is changed, fsgid will also be changed to the new value of the effective group ID. Explicit calls to setfsuid(2) and setfsgid() are usually only used by programs such as the Linux NFS server that need to change what user and group ID is used for file access without a corresponding change in the real and effective user and group IDs. A change in the normal user IDs for a program such as the NFS server is a security hole that can expose it to unwanted signals. (But see below.) setfsgid() will only succeed if the caller is the superuser or if fsgid matches either the real group ID, effective group ID, saved set- group-ID, or the current value of fsgid. RETURN VALUE
On success, the previous value of fsgid is returned. On error, the current value of fsgid is returned. VERSIONS
This system call is present in Linux since version 1.2. CONFORMING TO
setfsgid() is Linux-specific and should not be used in programs intended to be portable. NOTES
When glibc determines that the argument is not a valid group ID, it will return -1 and set errno to EINVAL without attempting the system call. Note that at the time this system call was introduced, a process could send a signal to a process with the same effective user ID. Today signal permission handling is slightly different. BUGS
No error messages of any kind are returned to the caller. At the very least, EPERM should be returned when the call fails (because the caller lacks the CAP_SETGID capability). SEE ALSO
kill(2), setfsuid(2), capabilities(7), credentials(7) COLOPHON
This page is part of release 3.27 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. Linux 2008-12-05 SETFSGID(2)
All times are GMT -4. The time now is 03:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy