LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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, 03:55 AM   #1
rpittala
Member
 
Registered: Jan 2012
Location: PUNE
Distribution: SunOS sun4v sparc sun4v Solaris
Posts: 56
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 04:22 AM. Reason: elabarating the question
 
Old 01-28-2012, 04:11 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
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, 12:54 PM   #3
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
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, 07:33 AM   #4
rpittala
Member
 
Registered: Jan 2012
Location: PUNE
Distribution: SunOS sun4v sparc sun4v Solaris
Posts: 56
Blog Entries: 1

Original Poster
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, 07:42 AM   #5
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
please acknowledge the responses you have been given, don't just ask another question. And don't "expect" anything. We are volunteers here.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 08:55 AM
global variables Swapna173 Linux - Newbie 2 03-19-2009 02:01 AM
Local vs Global variables wujee Programming 1 03-12-2005 12:43 AM
exporting global variables neo77777 Programming 6 09-18-2002 02:46 PM
global environmental variables antadam Linux - General 2 10-11-2001 07:36 AM


All times are GMT -5. The time now is 02:45 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration