|
|
1.1 ! root 1: ! 2: ! 3: shm Device Driver shm ! 4: ! 5: ! 6: ! 7: ! 8: Shared memory device driver ! 9: ! 10: ! 11: The device /dev/shm is an interface to the shared memory device ! 12: driver. It is assigned major device 24 (minor device 0) and can ! 13: be accessed as a character-special device. ! 14: ! 15: Shared memory access operations are performed by seeks, reads, ! 16: and writes through the interface /ddeevv/sshhmm. The desired seek ! 17: location is (sshhmmiidd << 16L) + offset. ! 18: ! 19: Shared memory control operations are performed through the system ! 20: call ioctl. The operations shmctl and shmget are performed with ! 21: an integer parameter array. The first element of the array is ! 22: reserved for the return value (default, -1). Subsequent elements ! 23: represent arguments. ioctl passes SHMCTL, SHMGET, SHMAT, or ! 24: SHMDT as the second argument, and the parameter array as the ! 25: third argument. The first argument is an open file descriptor to ! 26: /dev/shm. Seeks, reads, and writes on shared memory can be per- ! 27: formed through the file descriptor shmfd. ! 28: ! 29: ***** Access ***** ! 30: ! 31: To access shared memory, do the following: ! 32: ! 33: 1. Be sure that /dev/shm is present as a special-character file ! 34: with major number 24, minor number 0, and broad enough permis- ! 35: sions. The command ! 36: ! 37: /etc/mknod /dev/shm c 24 0 ! 38: ! 39: will create /dev/shm if it does not yet exist. ! 40: ! 41: 2. Become the superuser root. Execute the command ! 42: /etc/drvld /drv/shm ! 43: ! 44: to load the driver. ! 45: ! 46: 3. Use the COHERENT system call shmget() to create a shared- ! 47: memory segment and obtain shmid value for it. ! 48: ! 49: 4. Use the COHERENT system call lseek() to position for read or ! 50: write of a shared-memory segment. The first argument to lseek ! 51: is shmfd, which is an external declared in <sys/shm.h>. The ! 52: second argument to lseek is a long whose high word is the seg- ! 53: ment identifier shmid and whose low word is the offset within ! 54: the shared-memory segment. The third argument to lseek is ! 55: zero. ! 56: ! 57: 5. Use the COHERENT system calls read() and write() to access the ! 58: segment. Again, use shmfd as the file descriptor. ! 59: ! 60: 6. When you are finished using shared memory, use the call ! 61: shmctl(shmid, IPC_RMID, 0) ! 62: ! 63: ! 64: COHERENT Lexicon Page 1 ! 65: ! 66: ! 67: ! 68: ! 69: shm Device Driver shm ! 70: ! 71: ! 72: ! 73: ! 74: to remove segments when you are finished. ! 75: ! 76: 7. Finally, use ps -d to obtain the process identifier of the ! 77: shared-memory driver. To unload the driver, become the super- ! 78: user root, and then type the command ! 79: ! 80: kill -9 _x_x_x_x ! 81: ! 82: where xxxx is the process identifier for the shm driver. ! 83: ! 84: Note that this manner of proceding is not entirely in the spirit ! 85: of System V IPC shared memory: COHERENT does not support ! 86: functions shmat() and shmdt(). Unfortunately, true attachment of ! 87: shared segments is not possible in SMALL-model systems. ! 88: ! 89: ***** Notes ***** ! 90: ! 91: If you allocate too many shared memory identifiers, you will ex- ! 92: haust kernel data space, and thus halt the system in its tracks. ! 93: ! 94: Creating many large shared memory segments can exhaust main ! 95: memory, as shared memory segments do not currently support swap- ! 96: ping. ! 97: ! 98: The functions shmat and shmdt are not currently supported. ! 99: ! 100: Private shared memory is not supported. Shared memory segments ! 101: must be removed manually when no longer required. To remove all ! 102: shared memory segments use the following C code: ! 103: ! 104: ! 105: #include <sys/shm.h> ! 106: ! 107: #define NSHMID 16 ! 108: ! 109: shmget( 0, 0, 0 ); /* must do first */ ! 110: ! 111: for ( id=0; id < NSHMID; ++id ) ! 112: shmctl( id, IPC_RMID, 0 ); ! 113: ! 114: ! 115: To load shm into memory, use the command drvld. ! 116: ! 117: ***** Files ***** ! 118: ! 119: /usr/include/sys/ipc.h ! 120: /usr/include/sys/shm.h ! 121: /dev/shm ! 122: /drv/shm ! 123: ! 124: ***** See Also ***** ! 125: ! 126: device drivers, drvld, shmctl(), shmget() ! 127: ! 128: ! 129: ! 130: COHERENT Lexicon Page 2 ! 131: ! 132:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.