Question:
Can We use Senaphores, message Queues, mail boxes and all IPCs in multiprocessing?
vijay
2006-11-16 23:24:17 UTC
Hi presently Iam working with IPCs on LINUX as welll as Windows. But I got confussion can alll IPCs are working in Multipcocess. can we sahring all between multipcocesses like shared memeory, message ques, semophores etc? if it works How we synchonize and co-ordinate multi processes?
Three answers:
Innocence Redefined
2006-11-20 19:59:03 UTC
I've no practical experience in working on these, I'm just writing the methods by which u can establish IPC (and in which condition u've to apply which method)... I've studied those on textbooks...

BROAD-CATEGORIES :

(1)Shared resources / mainly shared-memory

[here 2 processes share a common resource, that can be memory also. Semaphore is used in this method... remember Producer-Consumer problem? It does fall in this category]

(2)Message-passing

[here kernel is used as the intermediate medium. Mail-box, msg-queues 're used in this method]

- - - - - - --- - -- - - - -- - - - - - - -- - - -- - - - - - - - -

MOSTLY-USED METHODS ...



METHOD 1(Pipes):

This allows the flow of data in one direction only. Data from the output is usually buffered until the input process receives it which must have a common origin.

METHOD 2(Named Pipes):

This is a pipe with a specific name. It can be used in processes that do not have a shared common process origin. Example is FIFO where the data is written to a pipe is first named.

METHOD 3(Message queuing):

This allows messages to be passed between messages using either a single queue or several message queues. This is managed by the system kernel. These messages are co-ordinated using an application program interface (API)

METHOD4(Semaphores):

This is used in solving problems associated with synchronization and avoiding race conditions. They are integers values which are greater than or equal to zero

METHOD5(Shared Memory): This allows the interchange of data through a defined area of memory. Semaphore value has to be obtained before data can get access to shared memory.

METHOD6(Sockets):

This method is mostly used to communicate over a network, between a client and a server. It allows for a standard connection which I computer and operating system independent.
anonymous
2016-03-29 03:15:33 UTC
2
smartsuman2k1
2006-11-20 08:59:26 UTC
U can use those in ur programs.

when ever u call semaphores, the process will be switched from usermode to kernel mode and that system call will be executed there. The process switches back to user mode.



U can try these commands in ur programs. if u observe fork is also a system call that u can use in ur programs to create a new process.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...