







Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An overview of inter-process communication (ipc) mechanisms in linux, including message queues, shared memory, and sockets. Ipc enables processes to exchange data and synchronize their execution. Message queues allow for message-passing between processes, while shared memory allows for direct access to a shared region of memory. Sockets enable communication between processes over a network. The basics of each ipc mechanism, including syntax and usage.
Typology: Study notes
1 / 13
This page cannot be seen from the preview
Don't miss anything!








is a program in execution l is an instance of a computer program being sequentially executed l process execution must progress in sequential fashion l process is also called a
job
program is a
passive
entity; process is an
active^
entity
l^ program only contains text; process is associated with code, data, PC,heap, stack, registers, and other information l^ program becomes a process when an executable file is loaded intomemory l^ same program executed multiple times will correspond to differentprocess each time
new – process is being created l running – instructions are being executed l waiting – waiting for some event to occur l ready – waiting to be assigned a processor l terminated – process has finished execution
!
maintains process-specific information l necessary for scheduling
process state l program counter l CPU registers l CPU scheduling information l memory-management information l accounting information l I/O status information
of a process represented in the PCB l^ context switch involves a state
save^ of the current process, and a state
restore
of the process being resumed next l^ switch from
user^ to
kernel^
mode or vice-versa is a
mode^ switch
the system does no useful work while switching l overhead depends on hardware support^ ^ Sun UltraSPARC provides multiple banks of registers^ ^ Intel x86 processors also provide some support
operating systems have a
primordial
process
l^ creating process called
parent process
l^ new process called
child^ process
l^ processes identified and managed via
a process identifier
( pid )
parent and children share all resources l children share subset of parent’s resources l parent and child share no resources
parent and children execute concurrently l parent waits until children terminate
!
child duplicate of parent l child has a program loaded into it
fork^ system call creates new process l exec^ system call used after a
fork^ to replace the process’ memory
space with a new program
^
^ ^ ^
^
^ !"#^ ^ ^ ^ $%&''# ^ ^ (( (%&'') ) ^ #
can explicitly invoke the
exit^ system call to terminate
l^ OS implicitly calls exit l^ child can pass return status to parent (via
wait )
l^ child has exceeded allocated resources l^ task assigned to child is no longer required l^ if parent is exiting^ ^ some operating system do not allow child to continue if its parentterminates^ ^ all children terminated -
cascading termination
producer
process produces information l^ consumer
process consumes the produced information
consumer
cannot use information before it is produced by the
producer
unbounded-buffer
places no practical limit on the size of the buffer l^ bounded-buffer
assumes that there is a fixed buffer size
!
messages are directed and received from mailboxes (also referredto as ports)^ ^ send
(A, message) – send a message to mailbox A ^ receive
(A, message) – receive a message from mailbox A l^ each mailbox has a unique id l^ processes can communicate only if they share a mailbox l^ properties of communication link^ ^ link may be associated with many processes^ ^ each pair of processes may share several communication links^ ^ link may be unidirectional or bi-directional^ ^ multiple receivers may need synchronization l^ mailbox can be held in the process address space or in the kernel
message passing may be either blocking (synchronous) ornon-blocking (asynchronous) l blocking send
has the sender block until the message is received l^ blocking receive
has the receiver block until a message is available
l^ non-blocking
send has the sender send the message and continue l^ non-blocking
receive has the receiver receive a valid message or null
zero capacity – 0 messages^ ^ Sender must wait for receiver l bounded capacity – finite length of
n^ messages
^ Sender must wait if link full l unbounded capacity – infinite length ^ Sender never waits
pipes l FIFOs (names pipes) l message queues l shared memory l sockets
also provides a useful command-line interface
is communication unidirectional or bidirectional?^ ^ Unix pipes only allow unidirectional communication l should communication processes be related?^ ^ anonymous
pipes can only be constructed between parent-child
+,
+, * -+,$."/01 ./
22)34563 -/78
+ .1 - ."1(-+ ((! ( ."1 9$ .1$ .1: ."1: 8 .1 ."1("$ #^
$."/01 ./1 22)34563 -/7+; -/8 ( - +< - +( ."1 # .1$ ("$ #
$."/01 ./1 22)34563 -/7+; -=8 + ) "8 .1 ) /8 #
;"8 ( ."1$ ;/8 ##
output of one command is input to the next command l example:
l^ create a process to run
l^ create a process to run
l^ create a pipe from
to^
l^ the standard output of the process to run
is redirected to a pipe
streaming to the process to run
l^ the standard input of the process to run
^ is redirected to be the pipe
from the process running
^ ^
^ ^
^
^
!"#^
"$^ !%#
"$!&''"()*
^
^
+(('
,-.^
^ /0'1+
^
2
3
^
^
2 3
^ +4
+ 6 ^ 1
^
1
!&'"7!89#:: ^
;
l^ each message should be in a buffer like,^ - $-J
l^ J
can be used to get specific messages
l^ second argument, we use it to terminate queue
uniquely naming the shared segment^ ^ system-wide or anonymous name l specifying access permissions^ ^ read, write, execute l dealing with race conditions^ ^ atomic, synchronized access
^ ^
^ ^
^
^
3<0, ^
^
^ ^
^
^
!&'&"!=)*(3
!"#^
"$^ !%#
"
^
^
^ 9#::
>
^
^ ^
^
^
^
+(('
,-.^
^ /0'1+
^ +4
+^
^
^
^
^
^ ^
^ ^
^
^
^ !&'"7!89#:: ^
;
l^ IPC_PRIVATE
specifies creation of new memory segment of
size
rounded to the system page size l access permissions as for normal file access l returns identifier of shared memory segment
segment_id
l^ command is
to remove shared segment
can be defined as an end-point for communications l two-way communication pipe l can be used in a variety of domains, including
Internet
communication between processes on the same Unix system l special file in the file system
client^ sending requests for information, processing l server^ waiting for user requests l server performing the requested activity and sending updates to client
connection-based, TCP l connection-less, UDP
l^ J l^
$ l
l^ J^
$- l (^) l $-
l
M NN l
l^
!
Java mechanism (API) to perform RPCs l Java remote method protocol (JRMP) only allows calls from one JVM toanother JVM l CORBA is used to support communication with non-JVM code l client obtains reference to remote object, and invokes methods on them