EmbLogic's Blog

Program to show how parent and child processes communicate via a shared memory IPC mechanism

RCS file: simple_shared.c,v
Working file: simple_shared.c
head: 1.11
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 11;    selected revisions: 11
description:
Implementation of IPC mechanism:Shared memory.
Child process is created using fork().
Shared memory segment is created using shmget().
—————————-
revision 1.11
date: 2014/01/19 20:39:18;  author: root;  state: Exp;  lines: +1 -0
After detaching the shared memory segment,deallocate the shared memory segment using shmctl()
system call.
—————————-
revision 1.10
date: 2014/01/19 20:35:05;  author: root;  state: Exp;  lines: +28 -8
Code is working absolutely fine.
After performing the desired operation,Shared memory segment is detached using shmdt().
—————————-
revision 1.9
date: 2014/01/19 14:45:21;  author: root;  state: Exp;  lines: +1 -1
Segmentation fault occurred in the program.
—————————-
revision 1.8
date: 2014/01/19 14:42:02;  author: root;  state: Exp;  lines: +10 -1
A value is stored in the shared memory segment.
The same variable is assigned different values in the parent and child process.
Checking….
—————————-
revision 1.7
date: 2014/01/19 14:32:25;  author: root;  state: Exp;  lines: +5 -1
A check is added to display an error if the call to shmctl is failed.
—————————-
revision 1.6
date: 2014/01/19 14:29:33;  author: root;  state: Exp;  lines: +1 -1
Declaration error fixed.
Issue:spelling mistake of the variable segment_size.
—————————-
revision 1.5
date: 2014/01/19 14:27:37;  author: root;  state: Exp;  lines: +5 -1
shmctl() system call is used to know the size of the created segment.
—————————-
revision 1.4
date: 2014/01/19 13:47:24;  author: root;  state: Exp;  lines: +4 -4
New line character is added to display the messages in an
appropriate way.
—————————-
revision 1.3
date: 2014/01/19 13:40:49;  author: root;  state: Exp;  lines: +2 -1
Warning fixed.
Issue:Comparison between pointer and integer.
Another issue:Misplaced braces.
—————————-
revision 1.2
date: 2014/01/19 13:32:33;  author: root;  state: Exp;  lines: +25 -14
Shared memory segment is attached successfully.
Using the shmat() system call.
—————————-
revision 1.1
date: 2014/01/19 12:59:42;  author: root;  state: Exp;
Initial revision
=============================================================================

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>