Showing posts with label IPC. Show all posts
Showing posts with label IPC. Show all posts

Wednesday, May 20, 2015

Inter/Intra Process Communication Part-2


This is still in draft stage , I have to publish them else I coudn't access my own blogs from my work place.

They are kind of nazi , I can't login into my blog.


There is good article to create  threads

http://www.thegeekstuff.com/2012/04/create-threads-in-linux/

But this has led me to think about fork(), that creates child process . I am under impression that child process is just one more thread, but I have to confirm that now.


Also the code given is in C. I have to parallely work in Java. So have to check that also.

So this post at the end will have all the above things.

In case somone tries to execute code given in the link .

They have to write below command for compile ( provided u have saved file as thread.c)

> gcc -pthread -o output thread.c
>./output


and see how it behaves, for me it first printed second program and then first program

The other things I need to do before I forgot are
1) Code wise  difference between thread creation and child process creation
2) How to post signals to threads of same child and thread of different child
3) In case we want to post some signal to a particular thread of a child, how to do that.

Inter/Intra Process Communication Part-1


I am in love with technology...but this love is difficult.  Technology is so vast , that its hard to get a good grip on something.

Now while going thru the VoLTE post, I realized I need to study something about sockets.

That has led me to study about IPC ( Inter Process Communication)

As per wikipedia there a lot of ways to have IPC.

But I will just focus on those which I see in code or come across my daily life.


They will be

1) Pipes

2) Sockets

3) Message Queue

4) Shared Memory

5) Semaphore

6) Signal

Now what I am looking for is differences between these approaches and simple code for these.

This is nice link on wiki  http://en.wikipedia.org/wiki/Inter-process_communication


A bit knowledge about Operating System , since if things goes as planned :)  then we will need conceptual wise understanding of OS concepts.

Process is a executable code of the program you have written.

Threads are the running instances of you process ( or executable code) . There can be many threads per process, depending on OS support.

Also threads common to same process share the memory and variables.

True multitasking happens in CPU having more than one core or processor.  For single processor, we have time-slice concept where we slice time between different threads to have a feel of multitasking.

Multitasking is a broader term , which means multiple task running at same time. Task are nothing but threads ( IMP POINT is  THEY CAN BE OF SAME PROCESS OR DIFFERENT PROCESS).

So multiprocessing system are nothing but multitasking system.  In most of the books they just use multiprocessing in place of multitasking , even though their meaning might meant  SINGLE PROCESS MULTIPLE THREADS running at the same time.


So given this context, we have to see how can we send data between

1) THREADS OF SAME PROCESS.  Can be term as intra-process communication
2) THREADS OF DIFFERENT PROCESS . in short  inter-process communication.


So now basically we know why we are studying about IPC.

Things to done by me :
1) Making C program which have 2 threads


Some useful links I came across/referred during this post

1) http://www.yendor.com/programming/unix/unp/unp.html

2) http://technotif.com/basic-guide-interprocess-communication-pipes/

3)https://www.google.co.kr/url?sa=t&rct=j&q=&esrc=s&source=web&cd=5&ved=0CDwQFjAE&url=http%3A%2F%2Fwww.cs.unc.edu%2F~dewan%2F734%2Fcurrent%2Flectures%2F6-ipc.pdf&ei=qU5dVduCGsjBmAWv0YD4CQ&usg=AFQjCNFE9VYmu5VPnnr7uxILm8M0Z3yHtA&sig2=KEhqnHdHF9KK7E0NSiK5ig&bvm=bv.93756505,d.dGY
4)