Linux Scroll

Just another WordPress.com site

ipcs

IPC stands for Inter-process Communication.

This technique allows the processes to communicate with each another.
Since each process has its own address space and unique user space, how does the process communicate each other?
The answer is Kernel, the heart of the Linux operating system that has access to the whole memory. So we can request the kernel to allocate the space which can be used to communicate between processes.
The process can also communicate by having a file accessible to both the processes. Processes can open, and read/write the file, which requires lot of I/O operation that consumes time.
Different Types of IPCS

There are various IPC’s which allows a process to communicate with another processes, either in the same computer or different computer in the same network.

* Pipes – Provides a way for processes to communicate with each another by exchanging messages. Named pipes provide a way for processes running on different computer systems to communicate over the network.

* Shared Memory – Processes can exchange values in the shared memory. One process will create a portion of memory which other process can access.

* Message Queue – It is a structured and ordered list of memory segments where processes store or retrieve data.

* Semaphores – Provides a synchronizing mechanism for processes that are accessing the same resource. No data is passed with a semaphore; it simply coordinates access to shared resources.

ipcs – report status of interprocess communication facilities

SYNOPSIS

ipcs [-mqs] [-abcopt] [-C core] [-N namelist]


The following options restrict the display to the corresponding
facilities.

(none) This is equivalent to -mqs.
-m Display information about active shared memory
segments.
-q Display information about active message queues.
-s Display information about active semaphores.

The following options add columns of data to the display. See "Column
Description" below.

-b Display largest-allowable-size information: for
message queues: QBYTES; for shared memory
segments: SEGSZ; for semaphores: NSEMS.

-o Display information on outstanding usage: for
message queues: CBYTES, QNUM; for shared memory
segments: NATTCH.

List all IPC facilities:

# ipcs -a


------ Shared Memory Segments --------
key shmid owner perms bytes nattch status

0x0000270f 325713925 root 666 1 2

------ Semaphore Arrays --------
key semid owner perms nsems
0x0103eefd 0 root 664 1

------ Message Queues --------
key msqid owner perms used-bytes messages
0x000005a4 32768 root 644 0 0

List all the message queue:

# ipcs -q

------ Message Queues --------
key msqid owner perms used-bytes messages
0x000005a4 32768 root 644 0 0

List all the Semaphores:

# ipcs -s

------ Semaphore Arrays --------
key semid owner perms nsems
0x0103eefd 0 root 664 1

List all the Shared Memory:

# ipcs -m


------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0x0000270f 325713925 root 666 1 2

Lists the limits:

# ipcs -m -l

------ Shared Memory Limits --------
max number of segments = 4096
max seg size (kbytes) = 67108864
max total shared memory (kbytes) = 17179869184
min seg size (bytes) = 1

-l option gives the system limits for each ipc facility

Check the detail:

# ipcs -s -i 32769

# ipcs -q -i msqid
# ipcs -s -i semid
# ipcs -m -i shmid
-i option provides detailed information

List Creator and Owner Details:

# ipcs -q -c

# ipcs -s -c
# ipcs -m -c
-c option lists creator userid and groupid and owner userid and group id.

Status of current usage:

# ipcs -u


------ Shared Memory Status --------
segments allocated 30
pages allocated 102
pages resident 77
pages swapped 0
Swap performance: 0 attempts 0 successes

------ Semaphore Status --------
used arrays = 49
allocated semaphores = 252

------ Messages: Status --------
allocated queues = 1
used headers = 0
used space = 0 bytes

Last accessed time:

# ipcs -s -t

Process ids that accessed IPC facility recently:

# ipcs -m -p
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: