LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-28-2012, 02:55 AM   #1
rpittala
Member
 
Registered: Jan 2012
Location: PUNE
Distribution: SunOS sun4v sparc sun4v Solaris
Posts: 102
Blog Entries: 1

Rep: Reputation: Disabled
Red face why I need IPC`s when I have global variables ?


suppose I have two processes p1, p2 and i am using the updated value of p2 in p1. So, to do this kind of operation why I need to use such a huge IPC`s ???

we can use a simple global variable for the above operations and that solves the problem.

In such case what is the use of IPC`s ?

Last edited by rpittala; 01-28-2012 at 03:22 AM. Reason: elabarating the question
 
Old 01-28-2012, 03:11 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
do not demand replys "ASAP", someone will answer you as and when they feel like it.

And please actually describe your question in a useful amount of detail. If you feel you can just copy and paste the title, you're doing it wrong.
 
Old 01-28-2012, 11:54 AM   #3
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
Quote:
Originally Posted by rpittala
we can use a simple global variable for the above operations and that solves the problem.
Processes run in their own, separate memory space. There is no such thing as a "global variable" shared between two processes.

You may have two processes, each running the same executable, which means each references all its variables with the same names, but each variable is unique to each process. There is no sharing.

Think of it a different way. Let's pretend what you describe is how things work. Let's take the example above (e.g. two processes running the same executable). Suppose I run process A to do task #1 and process B to do task #2. Task #1 and task #2 might require different values for the global variables to perform their respective tasks. So what happens? Task #1 and task #2 "fight" each other or get "confused" because the other process changed the value of a global variable.

If you want two processes to communicate, you must use IPC of some form.

Contrast this with threads. Threads run inside the same memory space as the process that started the thread(s). Global variables can be used for some communication between threads--because the variable name resolves to the same location in the same memory space.
 
1 members found this post helpful.
Old 01-30-2012, 06:33 AM   #4
rpittala
Member
 
Registered: Jan 2012
Location: PUNE
Distribution: SunOS sun4v sparc sun4v Solaris
Posts: 102

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
Hi All,
What are the advantages of a double pointer?
FYI,
I know some what about double pointer the below code and its functionality I know
#include<stdio.h>
#include<stdlib.h>
void double_fun(int **q)
{
*q=malloc(10);
**q=10;
}
int main()
{
int *p;
double_fun(&p);
printf("%d \n",*p);
}
Please explain some more points about the double pointer other than the above program.

expecting explanation with programs
 
Old 01-30-2012, 06:42 AM   #5
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
please acknowledge the responses you have been given, don't just ask another question. And don't "expect" anything. We are volunteers here.
 
Old 04-10-2019, 11:32 AM   #6
rpittala
Member
 
Registered: Jan 2012
Location: PUNE
Distribution: SunOS sun4v sparc sun4v Solaris
Posts: 102

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
Exclamation when I have static volatile global variable, why do I need an IPC ?

what if I have a volatile global variable which I want to use it for inter process communication, why do I need an IPC then ?
will it work only for single core communication ? why not for multi core communication ?

Last edited by rpittala; 04-14-2019 at 01:57 AM. Reason: for more information/clarity
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] BASH: Global Variables carolflb Linux - Newbie 4 01-23-2010 07:55 AM
global variables Swapna173 Linux - Newbie 2 03-19-2009 01:01 AM
Local vs Global variables wujee Programming 1 03-11-2005 11:43 PM
exporting global variables neo77777 Programming 6 09-18-2002 01:46 PM
global environmental variables antadam Linux - General 2 10-11-2001 06:36 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:37 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration