Bounded capacity- There is a certain pre-determined finite capacity in the queue. Senders must block if the queue is full, until space becomes available in the queue, but may be either blocking or non-blocking otherwise. Unbounded capacity - The queue has a theoretical infinite capacity, so senders are never forced to block. 3.5 Examples of IPC Systems 3.5.1 An Example: POSIX Shared Memory ( Eighth Edition Version ) The first step in using shared memory is for one of the processes involved to allocate some shared memory, using shmget: int segment_id = shmget( IPC_PRIVATE, size, S_IRUSR | S_IWUSR ); The first parameter specifies the key ( identifier ) of the segment. IPC_PRIVATE creates a new shared memory segment. The second parameter indicates how big the shared memory segment is to be, in bytes. The parameter is a set of bitwise ORed flags. In this case the segment is being created for reading and writing. The return value of shmget is an integer identifier Any process which wishes to use the shared memory must the attach shared memory to their address space, using shmat: char * shared_memory = ( char * ) shmat( segment_id, NULL, 0 ); The first parameter specifies the key ( identifier ) of the segment that the process wishes to attach to its address space The second parameter indicates where the process wishes to have the segment attached. NULL indicates that the system should decide. The third parameter is a flag for read-only operation. Zero indicates read-write; One indicates readonly. The return value of shmat is a void *, which the process can use ( type cast ) as appropriate. In this example it is being used as a character pointer. Then processes may access the memory the pointer returned by shmat, for example using sprintf:
Bounded capacity- There is a certain pre-determined finite capacity in the queue. Senders must block if the queue is full, until space becomes available in the queue, but may be either blocking or non-blocking otherwise. Unbounded capacity - The queue has a theoretical infinite capacity, so senders are never forced to block. 3.5 Examples of IPC Systems 3.5.1 An Example: POSIX Shared Memory ( Eighth Edition Version ) The first step in using shared memory is for one of the processes involved to allocate some shared memory, using shmget: int segment_id = shmget( IPC_PRIVATE, size, S_IRUSR | S_IWUSR ); The first parameter specifies the key ( identifier ) of the segment. IPC_PRIVATE creates a new shared memory segment. The second parameter indicates how big the shared memory segment is to be, in bytes. The parameter is a set of bitwise ORed flags. In this case the segment is being created for reading and writing. The return value of shmget is an integer identifier Any process which wishes to use the shared memory must attach the shared memory to their address space, using shmat: char * shared_memory = ( char * ) shmat( segment_id, NULL, 0 ); The first parameter specifies the key ( identifier ) of the segment that the process wishes to attach to its address space The second parameter indicates where the process wishes to have the segment attached. NULL indicates that the system should decide. The third parameter is a flag for read-only operation. Zero indicates read-write; One indicates readonly. The return value of shmat is a void *, which the process can use ( type cast ) as appropriate. In this example it is being used as a character pointer. Then processes may access the memory the pointer returned by shmat, for example using sprintf:
session-5.docx