Os Shared Memory

From Java4c

Shared memory is a memory-area, which is able to access from more as one process. It is a possibility given in some platforms. A process in this meaning is a portion of software maybe with more as one thread, which is running on the same platform simultaneously with other processes. But the processes are separated in the usage of the resources. Especially they haven't a common memory. It is to protect the processes against failures in the software.

The shared memory is not a mechanism, which is able to use on any platform. Therefore it is not a part of the common OSAL interface definition.

Use InterProcessComm as means of expression instead:

If shared memory is used, it is a problem of the communication between processes. Therefore the mechanism of InterProcessCommunication should be used instead:

  • InterProcessComm.open(ChannelSpec); to open a communication channel. It may create a shared-memory-access-object.
  • InterProcessComm.receive(...);: Receive any data from another process. It may check the shared memory whether expected information are given. It is not specified which addresses and which information inside the shared memory are checked. The receive operation is a broadcast-receive. To specify a finer granularity in information-receiving, there should be more as one open(...)-operations which are associated to parts of information in the shared memory. The receive(...)-operation is more wait for event-adequate as read memory. But usual it is it, which are expected in a communication between processes. The user should rather think about I will use the shared memory but I have to get events from another process. If receive is used for shared memory, the receive(..., sender)-method can look to control bits in more as one ranges in shared memory. It can return several data specifying the source of the data in the sender.
  • InterProcessComm.send(data, address);: it sets informations, maybe setting values in the shared memory. The address can be select which range, the data are the byte-data for the range. It is equal to send an information to a specified channel.
  • The methods InterProcessComm.capacityToSendWithoutBlocking(requestedNumber) and dataAvailable() can be used to poll the data situation.

If specific data struct are used inside a shared memory, it should be recognized as a problem of a driver level, not as part of a user program.

Personal tools