ShmFIFO library

ShmFIFO library provides an easy-to-use interface to shared memory for programs.
Download

ShmFIFO library Ranking & Summary

Advertisement

  • Rating:
  • License:
  • GPL
  • Price:
  • FREE
  • Publisher Name:
  • World Wide Web Security
  • Publisher web site:
  • http://www-security.com/shmfifo.html

ShmFIFO library Tags


ShmFIFO library Description

ShmFIFO library provides an easy-to-use interface to shared memory for programs. ShmFIFO library provides an easy-to-use interface to shared memory for programs where one process needs to send blocks of data to other processes.It was developed because pipe(2) and mkfifo(3) have a very small buffer size (4k) and are unsuitable for many applications. Shmfifo allows you to put a block of data in shared memory, get the oldest block of data from shared memory.ShmFIFO library also has the feature to share one instance of a private data structure among all processes which use the library.How to use shmfifoBefore using, shared memory should be created. After creating shared memory, process which wants to use it, should attach to memory. Then it can put and get blocks to FIFO. After process is finished working with FIFO, it calls shfifo_detach. When no processes will use FIFO, shared memory should be deallocated. Usally, lifecycle of shmfifo-based program is following: shmfifo_create fork(2) shmfifo_attach shmfifo_put, shmfifo_get (many times) shmfifo_detach wait(2) or waitpid(2) exit shmfifo_dealloc shmfifo comes with test.c program, which is good sample of how to write programs with shmfifo. It forks into 2 processes, parent generated variable-length blocks, writes checksum into each block and put it into FIFO. Child gets blocks from fifo, check if checksum is valid (it's always valid if there is no bug in program) and prints debug info. after large number of blocks gets transferred, both processes are exit. Additionally, shmfifo allows processes to share one private structure. test.c uses this structure to store counter, which is increased each time when parent cannot put block to FIFO because it's already full and has to wait until child will get block. If small amount of memory allocated for FIFO, then parent will wait more often.Installation:makemake testsu -make installtest.c is sample test program which is builts into 'test' binary. You can run it to test if library is working


ShmFIFO library Related Software