Thursday, May 8, 2008

inter process communicatipn

IPC means communication between two processes,
some of ipc's
1. signal
2.pipes
3.named pipes
4.message queues
5. semaphore
6.shared memory
signal:
A signal is a limited form of inter-process communication used in Unix, Unix-like, and other POSIX-compliant operating systems. Essentially it is an asynchronous notification sent to a process in order to notify it of an event that occurred. When a signal is sent to a process, the operating system interrupts the process' normal flow of execution. Execution can be interrupted during any non-atomic instruction. If the process has previously registered a signal handler, that routine is executed. Otherwise the default signal handler is executed.

The Single Unix Specification specifies the following signals which are defined in :

SIGABRT - process aborted
SIGALRM - signal raised by alarm
SIGBUS - bus error: "access to undefined portion of memory object"
SIGCHLD - child process terminated, stopped (*or continued)
SIGCONT - continue if stopped
SIGFPE - floating point exception: "erroneous arithmetic operation"
SIGHUP - hangup
SIGILL - illegal instruction
SIGINT - interrupt
SIGKILL - kill
SIGPIPE - write to pipe with no one reading
SIGQUIT - quit and dump core
SIGSEGV - segmentation violation
SIGSTOP - stop executing temporarily
SIGTERM - termination
SIGTSTP - terminal stop signal
SIGTTIN - background process attempting to read ("in")
SIGTTOU - background process attempting to write ("out")
SIGUSR1 - user defined 1
SIGUSR2 - user defined 2
SIGPOLL - pollable event
SIGPROF - profiling timer expired
SIGSYS - bad syscall
SIGTRAP - trace/breakpoint trap
SIGURG - urgent data available on socket
SIGVTALRM - signal raised by timer counting virtual time: "virtual timer expired"
SIGXCPU - CPU time limit exceeded
SIGXFSZ - file size limit exceeded

2.pipes:
pipes allow communication between two process,one at time.this is uni directional.
for example we have 2 process A & B
A ------------ B
(pipe)
A is writing data to pipe ,after completion writing in pipe,then after B will read from the pipe . that one process at a time .
1 A is writing in pipe then B will read from pipe not both (R/W) at a time
2 B is writing in pipe then A will read from pipe,not both(R/W) at atime

named pipe:
In computing, a named pipe (also FIFO for its behaviour) is an extension to the traditional pipe concept on Unix and Unix-like systems, and is one of the methods of inter-process communication. The concept is also found in Microsoft Windows, although the semantics differ substantially. A traditional pipe is "unnamed" because it exists anonymously and persists only for as long as the process is running. A named pipe is system-persistent and exists beyond the life of the process and must be "unlinked" or deleted once it is no longer being used. Processes generally attach to the named pipe (usually appearing as a file) to perform IPC (inter-process communication).

mesage queue:
Two (or more) processes can exchange information via access to a common system message queue. The sending process places via some (OS) message-passing module a message onto a queue which can be read by another process Each message is given an identification or type so that processes can select the appropriate message. Process must share a common key in order to gain access to the queue in the first place

semaphore: it allows synchronistion between two process.
for example:
If 4 systems connected to 1 printer at that time we are creating 2 semphore for a printer one sem give ' on' other 'off' (1 /0 in machine lang). suppose 1 system is doing printing at that time the 2 give a reqyest to print,then but sem is in on position, then 2 system will be in waiting state. For synchronising between two processe we are using semaphores.
Advantages:
protected, shared variable
counter for resource access synchronisation
operations:
increment counter atomically
wait (until non-null) and decrement atomically
invented by E. Dijkstra
operations P (wait-and-dec) and V (increment), also up and down

1 comment:

Anonymous said...

Hi ,

I am Rajesh from SiliconIndia. I am also an avid blogger for a while now and participating actively in Indian blogosphere. I read your blog posting and found them very interesting and informative. We would love to see a copy of your blogs posted here, whenever you are posting it on blogger.com. Here are some of the benefits of posting your blogs here:

We have a strong community of 500,000 Indian professionals
Best blogs of 2008 to be published in a book "SiliconIndia bLoG PrinT"
Best blog to be printed in SliconIndia & SmartTechie magazines each month
Chance to be featured on homepage everyday


We appreciate your community initiative here and in helping build a more powerful India! Also, if you have any ideas or want to volunteer to help for SiliconIndia, we would be more than excited to get your help.