IPC Flashcards
All info taken from different sources... https://www.cs.unc.edu/~dewan/242/s07/notes/ipc/node3.html
What is IPC?
Inter-process communication (IPC) is a set of methods for data interchange among potential multiple threads in one or more processes
Other names for IPC
inter-thread communication, inter-application communication
2 types of processes.
Independent process.
Co-operating process.
An independent process is not affected by the execution of other processes while a co-operating process can be affected by other executing processes.
What ways can processes communicate with each other?
- Shared Memory
- Message passing
1) Shared memory communication, how does this work?
By writing and reading shared variables
1) How does one process know when the other process wrote new info?
In some cases it wouldn’t know. - This would be in a load balancing program that just looks at the current load of the other process in the storage
When it does know - use polling (puts undue burden on the cpu)
Or it gets a software interrupt
Or semaphores or conditions could be used
1) When using Semaphores what happens?
Process q could block till p changes s and sends signal that unblocks q
But these solutions don’t allow q to block automatically if s cannot contain all data.
- Here you need to use semaphores as an external protocol to implement a buffer
1) What is the most efficient way to implement shared memory applications? (what function - in the Linux and Solaris 2.x OS)
mmap() function
or shmget() - another way to let multiple processes attach a segment of physical memory to their virtual address spaces
1) mmap() function
The mmap() function shall establish a mapping between a process’ address space and a file, shared memory object, or typed memory object.
1) shmget() function
returns the identifier of the System V shared memory segment associated with the value of the argument key. It may be used either to obtain the identifier of a previously created shared memory segment (when shmflg is zero and key does not have the value IPC_PRIVATE), or to create a new set.
Is conventional shared memory distributed or centralized? and why?
It is centralized, found on one machine. This is because (even though distributed shared memory over LANs has been worked on) even if we implemented distributed shared memory (without message passing it is not ideal)
Is shared memory used with client-server interaction?
No, not the best abstraction for clients sending server requests (requires coding as data structures unless structures encapsulated in monitors)
message passing is more appropriate
functions to create and handle interrupts
Interrupt(process id, interrupt number) - service call letting a process cause an interrupt in another
Handle(interrupt number, handler) - associates a handler with an interrupt
When a software interrupt is initiated what is allowed to be communicated?
Software interrupts allow only one bit information to be communicated -
that an event associated with the interrupt number has occurred.
They are typically used by an operating system to inform a process about the following events:
- The user typed the ``attention key’’.
- An alarm scheduled by the process has expired.
- Some limit, such as file size or virtual time, has been exceeded.
What are Interrupt traps, software interrupts, and exceptions?
With all of them an event is processed asynchronously by a handler procedure.
Interrupt and trap numbers defined by hardware which is also responsible for calling the procedure in kernel