Comparing and Evaluating The Performance of Inter Process Communication Models in Linux Environment
Comparing and Evaluating The Performance of Inter Process Communication Models in Linux Environment
National Conference on Social, Mobile, Analytics And Cloud Services (NCSMAC-2016) organized by Department of CSA, School
of Computing Sciences and Engineering, Periyar Maniammai University, 15th & 16th Sep 2016 51 | P a g e
Special Issue Published in International Journal of Trend in Research and Development (IJTRD),
ISSN: 2394-9333, www.ijtrd.com
parent process exits before child or child exits before parent. The filedes[1] is for writing. The return value is 0 for the success
following states are possible in the parent and child process condition, -1 is returned for error. The errno represents the status
communications. of error such as field is not valid, too many file descriptors etc.
C. Two-Way Communications with Pipes
When a child process exits, the signal is to be sent to the
parent indicating the child‟s deaths state. After In the multiple communication process, the two way protocol is
acknowledging, the child process and its status is used to communicate both directions, starts in parent to child and
removed from the process table. The duration of time child to parent. The communication system what we require here
between child exits and its acknowledgment to the is to open two pipes – one pipe from source to destination and
parent is called childs "zombie" state. other from destination to source. In this system of
When a parent process terminates, the child process communication, the situation of arising deadlock is an
associated with parent is known as orphan process. An unavoidable one.
orphan process will be considered as child of „init‟ D. Deadlock
process. The child process is automatically inherited by
the 'init' process has the process number 1. The purpose During the inter processes communication, more than one
of; init‟ process is to ensure that no child process is in processes are waiting for resources at the same time. The
“zombie” state. The written „init‟ process properly requested resources or event might be used by other processes in
acknowledges the death of its child process to the the same environment. The deadlock situation occurs when two
parent. processes communicate via two pipes. Here are two scenarios
When the parent process is not properly coded, the child that could lead to such a deadlock:
remains in the zombie state forever. Such processes can When two pipes are connected for two processes, the
be noticed by running the 'ps' command (shows the conditions such as both pipes are empty, but both processes
process list), and seeing processes having the string are in a state to read data from their input pipes. Here each
"<defunct>" as their command name. pipe will block on each other and thus in stuck situation.
A. The wait() System Call The second condition is more complex. Here two processes
(A & B) are communicated via pipes. Each pipe has a
The wait() system call is invoked when the parent process is temporary storage with a limited size of buffer. When a
required to know the status of child process. The state change of process A wants to write data on pipe A, it fills the data on
child is considered to be: the child process is terminated, the the buffer A by write () call. The buffer is kept to read by
process is stopped, and the process is resumed. It is one of the the read process. When the buffer is full, the read operation
way to acknowledge the parent process about the death of the is allowed to execute and write() system call will be
child process. During the wait() is invoked, the process is blocked until the buffer gets free space. Both processes
suspended until one of its child processes exits. The call returns write operations will get blocked if the buffer is full and no
to exit status of child. read() occurs. Current two processes will be in deadlock.
V. COMMUNICATIONS VIA PIPES VI. SYSTEM V IPC
One or more related task may have the communication through The complex situation of inter process communication can be
pipe. In this manner, one task is dependent on previous task. So handled by invoking the mechanism called message queues,
the new task is started from the earlier one as they are supposed shared memory, and semaphores. The message queues
to accomplish some related tasks. mechanism is used to send and receive the messages among the
A. What Is a Pipe? inter processes, whereas the shared memory concept is used to
allow the processes to share data in memory. The semaphore
A pipe is a special command in UNIX, used to control from system is used to synchronize the process of resource access in
where the input of command comes and where the output must multi process situation. It is a control variable that is used to
go. It is used to connect two or more command together in a control the access of common resources in a parallel
stream and control the input and output of the command. This communication system. The semaphore variable may change its
mechanism considers the two processes such as ancestor and status according to the condition specified by the programmer.
successor and sends a byte stream from one to other. The The variable is used as a control variable to access the system
protocol must be carefully designed to utilize the pipe resources.
mechanism. The two way communication requires a parallel
pipes to communicate. VII. PERMISSION ISSUES
The pipe protocol assures that the order, in which data is written A. Private Vs. Public
to the pipe, is the same order as that in which data is read from The multiple processes can also be controlled or monitored by
the pipe. It assures that the data flow will be in the order from assigning privileges on access of resources. The access specifier
source to destination and no interruption occurs until one of the is either private or public. Private access specification for a
process exits. resource allows its own process or its child process to access
B. The pipe() System Call whereas the public specification on a resource allows any
process to access.
The pipe() system call has two types of file descriptors as an
argument. The file descriptor refers to a pipe inode, and places
them in the array pointed to by fields. filedes[0] is for reading,
National Conference on Social, Mobile, Analytics And Cloud Services (NCSMAC-2016) organized by Department of CSA, School
of Computing Sciences and Engineering, Periyar Maniammai University, 15th & 16th Sep 2016 52 | P a g e
Special Issue Published in International Journal of Trend in Research and Development (IJTRD),
ISSN: 2394-9333, www.ijtrd.com
B. System Utilities To Administer System-V IPC Resources When the process is started, it is being allocated a memory
segment to hold the runtime stack, a memory segment to hold the
As the inter process communication system is live outside the
programs code (the code segment), and a memory area for data
scope of a single process, the mechanism of maintaining the
(the data segment). Each such segment might be composed of
process status is required. The process of accounting deleted
many memory pages. When ever the process needs to allocate
resources, crashed resources, number of exiting resources is
more memory, new pages are being allocated for it, to enlarge its
needed to establish. Two utilities are used to administer the
data segment.
overall processes like 'ipcs' - to check usage of SysV IPC
resources, and 'ipcrm' - to remove such resources. When a process is being forked off from another process, the
memory page table of the parent process is being copied to the
The command 'ipcs' shows the utilization report for the
child process, but not the pages themselves. If the child process
resources. It gives the statistics such as identifier, owner, size of
will try to update any of these pages, then this page specifically
resources, and access permissions for various resources such as
will be copied, and then only the copy of the child process will
shared memory segments, semaphore arrays and message
be modified. This behavior is very effcient for processes that call
queues. Different unique report will be generated for each
fork () and immediately use the exec () system call to replace the
resource types. The command has flag representation to exhibit
program it runs.
the particular type of resources. It can also be enterd by the user
at the command „ipcs‟. The command which has '-m' refers the X. COMPARISON MODEL
shared Memory segments, „-q‟ represents message Queues and '-
An overview of actual transaction processing system built by
s' for Semaphore arrays. The command like 'ipcs' with the '-l' flag
using System V IPC. The name space used by System V IPC is
is used to view the limits or size of the system and '-u' flag
an advantage not a problem if we use file descriptors. Because
represents the memory usage statistics.
identifiers allow the process to send the message to a message
VIII. MESSAGE QUEUES queue with a single function call. Bulk of data transferred from
one process to another process. We have created a bench mark
The way of establishing protocol is one of the problems with
program using pipes and message queues. In both the cases, the
pipes. This protocol is based on sending separate messages. The
various sizes of data are inputted for both the programs and we
pipe() system is based on byte stream. The input data stream
have analysied the performance and response rate. The size of
from the pipe is needed to be converted in to packets before
the data various from bytes to Maga Bytes.
sending to the consecutive command. In the pipe processing
system all the processes are executed in FIFO manner, that the XI. RESULT ANALYSIS
processes are executed in the order they arrived. Priority or
The bi-directional flow of data between the process using the
intermediate accessing is a difficult task. The intermediate
message queues and pipes are analyzed by giving various sizes
process must wait until the entire proceeding task to complete its
of data. The test consisted of the program that created IPC
processes. This means that before reading any part of the stream
channel called fork and sent various Bytes ,KiloBytes and Maga
must consume all the bytes sent before the piece you're looking
Bytes data from parent to the child. Data was sent using various
for, and thus it is needed to construct queuing mechanism on
calls to msgsend, with a message length of various byte sizes, for
which data can be placed.
the message queue, and various calls to write, with the length of
A. Creating A Message Queue – msgget () various bytes size for the stream pipe. We got the timing
comparision table for pipes, message queues and sockets.
The msgget() system call is used to initiate a message queue. The
command has two attributes of parameters such as a queue key, Table 1: Timing comparison of two models
and flags. The key is one among the following:
Pipes D1
IPC_PRIVATE - used to create a private message
S.No Data Size Start time End time
queue.
A positive integer - used to create (or access) a publicly-
accessible message queue. 1. 32 bytes 20:21:22 20:21:22 0
The second parameter contains flags which are used to denote 2 306 bytes 20:22:01 20:22:02 1
the control on which the system is processed.
3. 3.0 KB 20:23:38 20:23:40 2
IX. BACKGROUND - VIRTUAL MEMORY
MANAGEMENT UNDER UNIX 4. 30 KB 20:24:00 20:24:01 1
To achieve virtual memory, the system divides memory into 5. 270.4 KB 20:24:20 20:24:23 3
small pages each of the same size. For each process, a table
6. 1.6MB 20:24:46 20:24:50 4
mapping virtual memory pages into physical memory pages is
kept. When the process is scheduled for running, its memory 7. 33MB 20:25:05 20:26:00 55
table is loaded by the operating system, and each memory access
causes a mapping (by the CPU) to a physical memory page. If 8. 99.0 MB 20:26:25 20:29:06 161
the virtual memory page is not found in memory, it is looked up
in swap space, and loaded from there (this operation is also
called 'page in').
National Conference on Social, Mobile, Analytics And Cloud Services (NCSMAC-2016) organized by Department of CSA, School
of Computing Sciences and Engineering, Periyar Maniammai University, 15th & 16th Sep 2016 53 | P a g e
Special Issue Published in International Journal of Trend in Research and Development (IJTRD),
ISSN: 2394-9333, www.ijtrd.com
Table1. Timing analysis of Pipes Table2. Comparison of user ,system, Clock Times
IPC SVR4
Datagram sockets
USER System Clock
Data Size Start time End D4 Message 0.7 19.6 20.1
time
32 bytes 21:03:12 21:03:13 1
Queues
Pipes 0.5 21.4 21.9
306 bytes 21:07:31 21:07:32 1
Data was sent using various calls to write, with the length of
3.0 KB 21:09:07 21:09:08 1 various bytes size for the stream pipe. We got the timing
30 KB 21:04:55 21:04:56 1
comparison table for pipes. The following graph figure 1
represents the performance of pipes for various sizes of data
270.4 KB 21:05:22 21:05:23 1 mentioned in table1. The performance curve states that response
time varies when there is a bulk of data inputted.
1.6MB 21:05:51 21:05:52 1
Streaming sockets
S.No Data Size Start time End time D3
Streaming sockets
S.No Data Size Start time End time D3
4. 30 KB 20:00:38 20:00:39 1
Figure 2. Response time for message queues
5. 270.4 KB 21:01:55 21:01:57 2
The user, System and clock for the 20 Mega bytes of data is
analysis with pipes and message queues. The times are all in
seconds.
National Conference on Social, Mobile, Analytics And Cloud Services (NCSMAC-2016) organized by Department of CSA, School
of Computing Sciences and Engineering, Periyar Maniammai University, 15th & 16th Sep 2016 54 | P a g e
Special Issue Published in International Journal of Trend in Research and Development (IJTRD),
ISSN: 2394-9333, www.ijtrd.com
the queue and them terminate, the message queue is not deleted.
They remain in the system until specifically read or deleted: by
some executing ipcrm(1) command or by the system being
rebooted . Compare this with the pipe which is completely
removed when the process to reference it terminates. The
message queues are that they are reliable, flow controlled, record
oriented and can be processed in other than first in first out order.
The streams also possess all these properties, although an open is
required before sending to a stream and close required when we
are finished. Both message stream and pipes are connection less.
The message types are identified by the priorities. We compare
the reponse time of pipes, message queues,streaming sockets and
datagram sockets for small and large size of data datagram
sockets perform better than streaming sockets. But for the bulk
Figure 4. Response time for Datagram Sockets size of data datagram sockets overcomes the message queues,
streaming sockets and pipes.
Figure5. states that ,when we compare the response time of pipes
and message queues, for smaller size of data message queues References
perform better than pipes. When the data size increases, the
performance of the pipes is better than message queues. When [1]. Comparing Some IPC Methods on Unix by Gene Michael
the data size is 99.0 MB the response time for pipe is 161 toverSunday, 27 January 2002
seconds and for message queue is 220 seconds and streaming [2]. Mike Gancarz, The Unix Philosophy. (1995) Digital Press;
sockets is 6 seconds and datagram socket is 2 secongs Newton, MA. ISBN 1-55558-123-4.
[3]. Performance analysis of five interprocess communication
mechanisms across UNIX operating systems Patricia K.
Immich, Ravi S. Bhagavatula and Dr. Ravi
PendseDepartment of Electrical and Computer
Engineering, Wichita State University, 1845 Fairmount
Box 44, Wichita, KS 67260, USA 3 May 2003
[4]. www.ebooknetworking.net/ebooks/unix-kernel-interproce
ss-communication-parameters.html
[5]. Named Pipe Security, Interprocess Communitions:
Platform SDK, MSDN Library, January 2001.
[6]. Berkeley UNIX System Calls and Interprocess
Communication, January 1987.
[7]. R.Klefstad, UNIX Network Programming, Introduction to
Figure 5: Comparison of response time for pipe, queue and UNIX Local and Remote Interprocess Communication,
sockets
CONCLUSION
The fundamental problem System V IPC is that the IPC
structures are system wide and donot have reference count. For
example if we create a message queue, place some message on
National Conference on Social, Mobile, Analytics And Cloud Services (NCSMAC-2016) organized by Department of CSA, School
of Computing Sciences and Engineering, Periyar Maniammai University, 15th & 16th Sep 2016 55 | P a g e