![]() |
|
EusLisp supports the shared memory provided by SunOS's mmap, not by System5's shmem. Shared memory is allocated by the map-file function. Map-file maps a file into the EusLisp process memory space and an instance of foreign-string is returned. Data can be written and retrieved using string functions on this foreign-string. Since shared memory is allocated at system-dependent page boundary, you should not specify the map address. Mapping a file with the :share keyparameter set to NIL or :private set to T means the file should be accessed privately (exclusively). Since this is not useful for the purpose of memory sharing, the default value of :share key is T. When a file is shared between two users, the read/write permission must be properly set for both users. Unfortunately, SunOS does not support file sharing through networks between different workstations.
Example programs to share a file of 64 byte length between two euslisp are shown below.
;; Create a file of 64 bytes (with-open-file (f "afile" :direction :output) (princ (make-string 64) f)) ;; Map it (setq shared-string1 (map-file "afile" :direction :io)) ;; ;; In another process (setq shared-string2 (map-file "afile" :direction :io))
Then, data written to shared-string1 immediately appears in shared-string2, and vice versa. Writing to a foreign string can be made by replace or setf in conjunction with aref.
map-file filename &key (direction :input) length (offset 0) (share t) (address 0) [function]