home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume14 / sharedmem / part04 < prev    next >
Encoding:
Internet Message Format  |  1988-05-17  |  48.2 KB

  1. Subject:  v14i097:  Shared memory emulation for 4.2BSD, Part04/04
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: libes@cme-durer.ARPA (Don Libes)
  7. Posting-number: Volume 14, Issue 97
  8. Archive-name: sharedmem/part04
  9.  
  10. #! /bin/sh
  11. # This is a shell archive.  Remove anything before this line, then unpack
  12. # it by saving it into a file and typing "sh file".  To overwrite existing
  13. # files, type "sh file -c".  You can also feed this as standard input via
  14. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  15. # will see the following message at the end:
  16. #        "End of archive 4 (of 4)."
  17. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  18. if test -f 'doc/usenix/paper.trf' -a "${1}" != "-c" ; then 
  19.   echo shar: Will not clobber existing file \"'doc/usenix/paper.trf'\"
  20. else
  21. echo shar: Extracting \"'doc/usenix/paper.trf'\" \(19292 characters\)
  22. sed "s/^X//" >'doc/usenix/paper.trf' <<'END_OF_FILE'
  23. X.TL
  24. XUser-Level Shared Variables (in a Hierarchical Control Environment)
  25. X.AU
  26. XDon Libes
  27. X.AI
  28. XNational Bureau of Standards
  29. XFactory Automation Systems Division
  30. XGaithersburg, MD  20899
  31. X.AB
  32. X.PP
  33. XWe have implemented a shared variable system for 
  34. X.UX
  35. X4.2BSD [Joy]
  36. Xthat emulates a shared or common memory.  
  37. X.IP \(bu
  38. XThis system is all user level code and requires no kernel
  39. Xmodifications.  It is accessible from a variety of languages.
  40. X.IP \(bu
  41. XThis shared memory system provides its service
  42. Xtransparently to remote hosts across a local-area network.
  43. X.IP \(bu
  44. XThis system is being used in a real application - an automated
  45. Xfactory.  Shared variables are an appropriate communication paradigm
  46. Xin a real-time environment (in comparison to message passing or pipes).
  47. X.AE
  48. X.PP
  49. X.SH
  50. XBackground
  51. X.PP
  52. XThe National Bureau of Standards has been performing research in the
  53. Xarea of robot control [Albus] for over a decade.  Robot control is
  54. Xtypified by tightly-coupled multiprocessor systems often implemented as
  55. Xmultiple single-board computers residing in a common bus.  These
  56. Xsystems require frequent and fast transfer of small amounts of data.
  57. X.PP
  58. XFor example, a robot arm may require new joint angles 100 times a
  59. Xsecond in order to move smoothly.  These joint angles are very small
  60. Xpieces of data and further, the number of joints and joint angles is
  61. Xconstant, hence they can be stored in "well-known" locations.
  62. X.PP
  63. XTo support this type of application, multiported memory is used
  64. Xso that several
  65. Xdifferent computers can access the same locations.
  66. XIn the robot example, the
  67. Xcontrolling computer and the servo computers each need access to the
  68. Xinformation.  
  69. X.PP
  70. XCommon memory has the further advantage that as new processes are added
  71. Xthat need information already present, extant processes do not have to
  72. Xbe modified to deliver that information.  For example, a process was
  73. Xadded that displays the robot's actions on a graphics monitor.  The
  74. Xdisplay process was added without modification to any other part of the
  75. Xsystem, since it uses the joint angles which are stored in well-known
  76. Xcommon memory locations.  Recently a "safety" process was added to
  77. Xguarantee that the robot never departs its working envelope.  The
  78. Xsafety process also obtains its information from common memory.
  79. X.PP
  80. XIn 1981, work [Furlani] began on an automated factory.
  81. XThis is an extension of
  82. Xthe robot control system in many ways.  It is expected that the
  83. Xfactory model will grow over time, and become richer in the number of
  84. Xprocesses used and the amount of information shared between processes.
  85. XA major difference in the automated factory project
  86. Xis that systems which have to communicate are often in
  87. Xseparate backplanes and use different operating systems.  Common
  88. Xmemory is seen as a consistent communications methodology for this
  89. Xdisparate collection of computers.
  90. X.PP
  91. XToday, as computers grow larger and become more complex, more and
  92. Xmore layers of protocol prevent ready access to common memory.  Indeed,
  93. Xwe find that in most of our computer-to-computer interfaces, common
  94. Xmemory is now simply a way of thinking, rather than an underlying
  95. Ximplementation.  Such is the case with
  96. X.UX
  97. X4.2BSD.
  98. X.PP
  99. XThe following section describes an implementation of the common memory
  100. Xparadigm in the
  101. X.UX
  102. X4.2BSD environment.
  103. X.SH
  104. XI.   User View
  105. X.PP
  106. XA server, the Common Memory Manager (CMM), acts on requests to access shared
  107. Xvariables.  Typical requests are read, write, and declare.  Variables are
  108. Xstructured and have attributes such as type, protection, lifetime, and
  109. Xownership.  Variable type checking is performed at runtime startup, since
  110. Xprocesses are loosely connected.
  111. X.PP
  112. XSome of the more interesting attributes of these shared variables are:
  113. X.PP
  114. X.I
  115. Xlifetime and "shelf life".
  116. X.R
  117. XIn a real time environment, the system must
  118. Xsurvive a process dying or getting bogged down temporarily.  When the useful
  119. Xlifetime of a variable's value has expired, other processes are free to
  120. Xmanipulate the variable, for instance, by redeclaring or writing it.  This
  121. Xattribute allows a "god" process to notice unexpected process deaths and
  122. Xrestart processes or transfer control to other processes.   For less
  123. Xcritical variables (such as an infrequently updated sensor value), processes
  124. Xcan note that a value is "stale", and make a projection that will carry them over
  125. Xuntil the variable writer catches up to its duties.
  126. X.PP
  127. X.I
  128. Xwrite count, timestamp, authorstamp.
  129. X.R
  130. XBy marking each variable with how many
  131. Xtimes or when it has been written, handshaking can be performed between
  132. Xprocesses.  The archetypal example from the automation environment has
  133. Xa supervisor sending the command "hit nail with hammer" to a
  134. Xsubordinate.  If the supervisor runs more quickly than
  135. Xthe subordinate, without handshaking, the subordinate may never see the
  136. Xcommand (i.e. nail is not hit).  If the subordinate runs more quickly than
  137. Xthe supervisor, without handshaking, the subordinate may execute the same
  138. Xcommand twice (i.e. nail is hit more than once).
  139. X.PP
  140. XThe same problem exists when the supervisor reads the feedback from the
  141. Xsubordinate.  In particular, because there is no synchrony between
  142. Xprocesses, the supervisor has no way of knowing what command the
  143. Xsubordinate is responding to (without handshaking).  Actual code for
  144. Xsuch a sequence would use higher-level routines to read the shared
  145. Xvariable.  For example:
  146. X.PP
  147. X.DS L
  148. X.B
  149. X    struct shared_variable *command_out, *feedback_in;
  150. X    struct shared_variable_value *expected_feedback;
  151. X    .
  152. X    .
  153. X    if (status_equal(command_out, feedback_in, expected_feedback)) . . .
  154. X.R
  155. X.DE
  156. X.PP
  157. XHere, the command to the subordinate is 
  158. X.B command_out .
  159. XThe actual feedback received is 
  160. X.B feedback_in
  161. Xand we are looking for
  162. X.B expected_feedback .
  163. XThe expected feedback is thus compared to the
  164. Xfeedback actually received with respect to the command which generated
  165. Xit.
  166. X.PP
  167. XThese handshaking and synchronization problems are thoroughly discussed
  168. Xin [Libes].
  169. X.PP
  170. X.I
  171. Xwakeup.
  172. X.R
  173. XVariables can be marked with a list of processes to be notified upon
  174. Xvalue change.  This was originally added for efficiency, so that
  175. Xclients, for example, would not have to loop just waiting for new
  176. Xvalues.  It has turned out to be extremely useful for debugging.
  177. XRather than inserting print statements in existing code and
  178. Xrecompiling, it is possible to create a debug module that simply prints
  179. Xout variables when they change.  It has also been used for a graphics
  180. Xmonitor that continuously displays the state of the entire system.
  181. X.PP
  182. XThe wakeup attribute can be
  183. Xused to force a queuing discipline on a variable.  For
  184. Xexample, a process performing as a resource server may take requests
  185. Xfrom a well-known common memory variable.  As clients write to the
  186. Xvariable, the CMM wakes up the resource server with each new variable
  187. Xvalue.  The resource server typically responds to each variable value in
  188. Xturn; however it can ignore all but the most recent values if it desires.
  189. X.PP
  190. X.I
  191. Xnon-exclusive write.
  192. X.R
  193. XVariables can be declared read or write, exclusively or
  194. Xnonexclusively.  By default, writes are exclusive, meaning that only one
  195. Xprocess can write a variable during its lifetime.  Non-exclusive write has
  196. Xno such restriction, allowing multiple processes to write the same variable.
  197. XOne use of this might be a server listening at a well-known location
  198. X("socket") for a request for service.
  199. XAny client can
  200. Xrequest service by writing the variable associated with the socket.
  201. X.PP
  202. XAnother use is to send information to a log file.  In our
  203. Xapplication, we can ask all processes to log their states a given
  204. Xnumber of
  205. Xclock ticks.  By having them all write their states to one variable,
  206. Xa logging process can record all the states of the system through time.
  207. XThis has proven to be invaluable during system testing.
  208. X.PP
  209. X.SH
  210. XII.   4.2BSD Implementation
  211. X.PP
  212. XThe Shared Variables System (SVS) is written in C and uses the 4.2
  213. Xinterprocess communication system [Leffler].
  214. XAn interface exists for Franz Lisp.
  215. X.PP
  216. XThe SVS consists of three layers.  The lowest level simulates a common
  217. Xmemory facility such as is available in System V.  On top of this are
  218. Xthe procedures that transform common memory into common variables.
  219. XThis level provides users with routines allowing access and control of
  220. Xthe common variables.
  221. X.PP
  222. XSpecific to our use of the SVS is a higher level that customizes it for
  223. Xcommunication in a hierarchical control environment.  This level
  224. Xincludes interprocess handshaking.
  225. X.PP
  226. X.SH
  227. XBuilding a server on 4.2
  228. X.PP
  229. X4.2BSD has no common memory facility.  Our system provides one via a
  230. Xserver that stores variables in its own memory space which is private
  231. Xto it.  (See Figure 1) The server runs as a user-level process which
  232. Xneeds no special privileges and can be run from an unrelated user-id.
  233. X.PP
  234. X.DS L
  235. X
  236. X
  237. X
  238. X
  239. X
  240. X
  241. X
  242. X
  243. X
  244. X            Figure 1 goes here
  245. X
  246. X
  247. X
  248. X
  249. X
  250. X
  251. X
  252. X
  253. X
  254. X.DE
  255. X.PP
  256. XCommunications between the common memory server and clients have
  257. Xproperties of both streams and datagrams.  Communication resembles
  258. Xvirtual circuits in that the server and clients pass many messages
  259. Xbetween them in a conversation (like TCP).  These messages are also
  260. Xrecord-oriented (like UDP).  In implementation, UDP was rejected
  261. Xbecause it would have forced us to handle unreliability and
  262. Xfragmentation (datagrams were
  263. Xlimited to 1K which was smaller than the typical message).
  264. X.PP
  265. XIn this case, we chose TCP as the lesser of two evils.  TCP had
  266. Xthe drawback (for us) of removing record boundaries (i.e. the receiver
  267. Xcould not tell where one write ended and the next began).  To handle
  268. Xthis, new versions of read and write were constructed to do the actual
  269. XI/O to the sockets.  These packetized and depacketized the TCP streams
  270. Xback into records.
  271. X.PP
  272. XSince TCP/IP is capable of communicating across the network, clients
  273. Xmay be distributed (figure 2) while accessing the common memory.  However, the
  274. Xsmall number of concurrent TCP connections (viz. the number of open
  275. Xfiles) is a severe limit.  Another system [Mitchell] glues distributed
  276. Xcommon memories together throughout the factory.  This design allows multiple
  277. Xcommon memories to exist but appear to the user as one.  This gluing
  278. Xprocess bypasses the TCP restriction and allows multiple
  279. Xinstances of the 4.2 (as well as others') common memory service to be
  280. Xrun.
  281. X.PP
  282. X.DS L
  283. X
  284. X
  285. X
  286. X
  287. X
  288. X
  289. X
  290. X
  291. X
  292. X                              Figure 2 goes here
  293. X
  294. X
  295. X
  296. X
  297. X
  298. X
  299. X
  300. X
  301. X.DE
  302. X.PP
  303. X.SH
  304. XSimulating common memory on 4.2
  305. X.PP
  306. XThe server's own private memory serves as common memory.  Access to
  307. Xvariables, therefore, is strictly through the valid requests to the CMM
  308. Xserver.   The server accesses variables as requested and maintains
  309. Xextra information such as variable type, owner, etc.
  310. X.PP
  311. XWhenever a client wants to access common memory, it does so by
  312. Xsending a message to the CMM.  Such messages are sent asynchronously
  313. Xbut received synchronously.  In particular, the server is never
  314. Xinterrupted.  
  315. X.PP
  316. XTypically, the server is waiting for service requests.  When a request
  317. Xis received, service is performed.  This service may or may not cause
  318. Xsending of a message in return to the client.  For example, "read"
  319. Xoperations always cause information to be returned from the server
  320. Xwhile "write" operations don't (unless an error is encountered).
  321. X.PP
  322. XIt is up to the client whether it wishes to wait (even after a "read")
  323. Xfor a response from the common memory server.
  324. X.PP
  325. XClient processes keep their own local version of shared variables of
  326. Xinterest until it is convenient for them to synchronize with
  327. Xthe CMM.  By calling 
  328. X.B cm_sync() ,
  329. Xthe user and the common memory server become synchronized.
  330. XAn argument to
  331. X.B cm_sync() 
  332. Xspecifies whether the client waits for a response or not.
  333. X.PP
  334. XWhether the client is waiting or not, an error can occur at the server
  335. Xend, in which case an error message is returned.  For example, a client
  336. Xmay write a value but the variable may be an incompatible type.  When
  337. Xthis happens, a message is sent back to the client.  The client is not
  338. Xinterrupted, but at the next 
  339. X.B cm_sync() 
  340. Xoperation it is notified of the error.
  341. X.PP
  342. XInterestingly, the problem of being able to provide atomic updates to
  343. Xcommon memory vanishes in this system.  Since the server is never
  344. Xinterrupted, client updates functionally prevent all other clients
  345. Xaccess to common memory while their request is being serviced.  This
  346. Xremoves the classic synchronization problem which exists when multiple
  347. Xprocesses are reading and writing real common memory with no
  348. Xsynchronization.  On the other hand, this can cause relatively long
  349. Xwaits for service.
  350. X.PP
  351. XConstruction of higher-level synchronization such as semaphores is
  352. Xeasy.  Potentially stalling manipulations of semaphores and monitors
  353. Xcan call
  354. X.B cm_sync()
  355. Xand then wait for a response from the server to
  356. Xcontinue.  The server acknowledges the client if and only if the client
  357. Xsemaphore action is satisfied.
  358. X.PP
  359. X.SH
  360. XIII.   An application - manufacturing automation
  361. X.PP
  362. XWhile the SVS is a general tool, it is currently being used at the National
  363. XBureau of Standards in the Automated Manufacturing Research Facility
  364. X(AMRF), a testbed for research in the automation of small batch
  365. Xmanufacturing [Simpson].
  366. XThe project is funded by NBS and the Navy Manufacturing
  367. XTechnology Program and significantly supported by industry through
  368. Xdonations or loans of major components and through cooperative research
  369. Xprograms.  The objective of the project is to identify, implement and exercise
  370. Xpotential standard interfaces between existing and future components of
  371. Xsmall-batch manufacturing systems and to provide a laboratory for the
  372. Xdevelopment of factory-floor metrology in an automated environment,
  373. Xdelivering proven measurement techniques and standard reference
  374. Xmaterials to American industry.  Commercially available products are
  375. Xbeing used to construct the facility wherever possible in order to
  376. Xexpedite transfer of research results into the private sector.
  377. X.PP
  378. XTo provide a real testbed for interface standards, the AMRF is
  379. Xintentionally composed of manufacturing and computer equipment from
  380. Xmany vendors, thereby making its construction a major integration
  381. Xeffort.  The types of systems that must be integrated and communicate
  382. Xwith each other include stationary and
  383. Xmobile robots, machine tools, their controllers, and higher-level cell and factory management systems.  Actual computers and operating systems
  384. Xrun the gamut, from micros to mainframes.
  385. X.PP
  386. XProcesses in the AMRF are
  387. Xorganized in a control hierarchy, much like the organization of a
  388. Xconventional factory.  At each level, tasks are broken down into
  389. Xsimpler tasks that can be performed by subordinate processes.  Control
  390. Xis hierarchical.
  391. X.PP
  392. XTo support such control communication, we imagine that processes in
  393. Xthe system communicate along hierarchical channels.  Each process runs
  394. Xasynchronously, continually "sending" commands to subordinate processes
  395. Xand feedback to superior processes.
  396. X.PP
  397. XLogically however, communication is performed using the common memory model.
  398. XFor example, a process sending commands to a subordinate writes the
  399. Xinformation in a well-known common memory variable.  The subordinate reads
  400. Xthe information out of the common memory variable, noting whether or not it
  401. Xcontains a new value.
  402. X.PP
  403. XIn reality, there are small groups of processes and processors that directly
  404. Xcommunicate with each other, some using physical common memory and some
  405. Xsimulating common memory.  Each cluster representing a piece of common
  406. Xmemory can choose to replicate any other portion of another cluster's common
  407. Xmemory.  An underlying network
  408. X(figure 3) invisibly supplies this service of keeping
  409. Xall the common memories synchronized.  The result is effectively one of a
  410. Xconsolidated common memory, with a very consistent and easy means of
  411. Xcommunication between processes.
  412. X.PP
  413. X.DS L
  414. X
  415. X
  416. X
  417. X
  418. X
  419. X
  420. X
  421. X
  422. X                     Figure 3 goes here
  423. X
  424. X
  425. X
  426. X
  427. X
  428. X
  429. X
  430. X
  431. X.DE
  432. X.PP
  433. X.SH
  434. XSummary
  435. X.PP
  436. XCommon memory is a communications methodology that is easy to use and
  437. Xcan be efficiently implemented.
  438. XIt can use physical common memory or be simulated by other
  439. Xcommunications techniques such as message passing.  In turn, it can be
  440. Xused to implement any other communications techniques.
  441. X.PP
  442. XCommon memory has several important advantages and disadvantages.  The
  443. Xprimary advantage is the ease with which information may be shared.  
  444. XIn our application, we have required this richness of data
  445. Xsharing between processes.
  446. XUsing common memory also has the benefit of being able to add, remove
  447. Xor modify processes without disturbing other processes,
  448. X.I
  449. Xeven if they communicate with each other.
  450. X.R
  451. X.PP
  452. XThe
  453. Xprimary disadvantage is that sharing large amounts of information in
  454. Xthis manner can become hard to keep track of.  Since there is no
  455. Xscoping in the common memory, naming conventions must be
  456. Xfollowed (which in effect, provides scoping).  Common memory is not
  457. Xparticularly apt for all types of communications.  Picking the most
  458. Xappropriate model (pipes, databases, message passing) will invariably
  459. Xlead to a simpler process in the final analysis.  We, of course, use
  460. Xthese other techniques in our application when appropriate.
  461. X.PP
  462. XAt the lowest level of our application, efficient process-to-process
  463. Xcommunication is necessary for real-time behavior.
  464. XThis is
  465. Ximplemented using real common memory with low overhead.  At higher
  466. Xlevels where common memory is simulated and the high-speed demand does
  467. Xnot exist, the methodology extends upwards suitably.
  468. X.PP
  469. XIn the future, we expect to move the ideas of hierarchical control and
  470. Xcommon memory to new applications.  Currently, we are investigating the
  471. Xpotential for control of autonomous aircraft.
  472. X.SH
  473. XReferences
  474. X.XP
  475. XAlbus, J., Barbera, T., Fitzgerald, M.L., "Hierarchical Control for
  476. XSensory Interactive Robots", Proceedings of 31st General Assembly,
  477. XInternational Institution for Production Engineering Research (CIRP),
  478. XToronto, Canada, September, 1981.
  479. X.XP
  480. XFurlani, C., Kent, E., Bloom, H., McLean, C., "The Automated
  481. XManufacturing Research Facility of the National Bureau of Standards",
  482. XProceedings of the Summer Simulation Conference, Vancouver, B.C.,
  483. XCanada, July 1983.
  484. X.XP
  485. XJoy, W., Cooper, E., Fabry, R., Leffler, S., McKusick, K., Mosher, D.,
  486. X"4.2BSD System Interface Overview", Computer Systems Research Group,
  487. XU.C. Berkeley, July, 1983.
  488. X.XP
  489. XLeffler, S., Fabry, R., Joy, W., "4.2BSD Interprocess Communications
  490. XPrimer", Computer Systems Research Group, U.C. Berkeley, July, 1983.
  491. X.XP
  492. XLibes, D., "Handshaking in a Hierarchical Control Environment",
  493. XInternal Memorandum, Center
  494. Xfor Manufacturing Engineering, National Bureau of Standards,
  495. XWashington, DC 20234.
  496. X.XP
  497. XMitchell, M., Barkmeyer, E.,
  498. X"Data Distribution in the NBS Automated Manufacturing Research
  499. XFacility", Center for
  500. XManufacturing Engineering, National Bureau of Standards, Washington, DC
  501. X20234, 1984.
  502. X.XP
  503. XSimpson, J., Hocken, R., Albus, J.,
  504. X"The Automated Manufacturing Research Facility of the National Bureau
  505. Xof Standards", Journal of Manufacturing Systems, Vol. 1, #1.
  506. X.PP
  507. X.SH
  508. XFurther Reading
  509. X.XP
  510. XBloom, H., Furlani, C., Barbera, A., "Emulation as a Design Tool in the
  511. XDevelopment of Real-Time Control Systems", 1984 Winter Simulation
  512. XConference, Dallas, Texas, November 1984.
  513. X.XP
  514. XJohnson, T., Milligan, S., Fortmann, T., Bloom, H., McLean, C.,
  515. XFurlani, C.  "Emulation/Simulation of a Modular Hierarchical Feedback
  516. XSystem", The 21st IEEE Conference on Decision and Control, Orlando, FL,
  517. XDecember 1982.
  518. END_OF_FILE
  519. if test 19292 -ne `wc -c <'doc/usenix/paper.trf'`; then
  520.     echo shar: \"'doc/usenix/paper.trf'\" unpacked with wrong size!
  521. fi
  522. # end of 'doc/usenix/paper.trf'
  523. fi
  524. if test -f 'doc/user.doc' -a "${1}" != "-c" ; then 
  525.   echo shar: Will not clobber existing file \"'doc/user.doc'\"
  526. else
  527. echo shar: Extracting \"'doc/user.doc'\" \(26953 characters\)
  528. sed "s/^X//" >'doc/user.doc' <<'END_OF_FILE'
  529. XThe NBS Common Memory System (CMS)
  530. XSept 25, 1987
  531. X
  532. XDon Libes
  533. XNational Bureau of Standards
  534. XMetrology Building, Room A-127
  535. XGaithersburg, MD  20899
  536. X(301) 975-3535
  537. X
  538. XThis system emulates a shared memory system.  (This system is
  539. Xloosely based on the Hierarchical Control System Emulator (HCSE)
  540. Xbuilt by BBN, which provided a shared memory as one of its
  541. Xfacilities.)  User processes can be distributed as well as shared
  542. Xmemory, itself.  A server, the common memory manager (CMM) handles
  543. Xrequests to manipulate shared variables.  This emulator was
  544. Xdesigned for the purposes of providing communication between
  545. Xhierarchically controlled processes.  There is a small amount of
  546. Xfunctions specifically for the purpose of making such communication
  547. Xof such style easier, but the emulator is certainly not restricted
  548. Xby this and thus it also provides communications between processes
  549. Xwith arbitrary relationships.
  550. X
  551. X
  552. XSuperficially, each process that wishes to use a shared variable,
  553. Xdoes so as if it was not shared.  Typically, one process writes
  554. Xinto a variable, while a number of other processes may read the
  555. Xvariable.  (Other scenerios are possible.)  The common memory
  556. Xmanager (CMM) enforces this and other restrictions and also handles
  557. Xany synchronization that may be necessary.  The fact that a
  558. Xvariable is shared is transparent to the user.
  559. X
  560. XThe common memory is implemented as memory private to the CMM,
  561. Xwhich it reads and writes in response to requests by clients.  The
  562. XBBN HCSE used a distributed form of control, depending on each
  563. Xprocess to pass control to the next.  A defect of this was that the
  564. Xunexpected death of a process would halt the emulation when control
  565. Xwas passed to it the next time around.  By centralizing control,
  566. Xthe unexpected death of any user process will not halt the
  567. Xemulation.  In fact, this can be monitored and a new or existing
  568. Xprocess can take over the responsibilities of a deceased process.
  569. X
  570. X
  571. XProcesses
  572. X
  573. XThere is one special process that must always be running when an
  574. Xemulation is in progress.  It is the Common Memory Manager (CMM).
  575. XThere will probably be other auxiliary processes such as
  576. Xfront-ends, debuggers, and editors that are not necessary but will
  577. Xinvariably always be running during any emulation.  This is not the
  578. Xcase now, however.
  579. X
  580. XThe CM manager handles requests from processes to read/write common
  581. Xmemory variables.  Various other requests are possible such as
  582. Xdynamically changing the size, type or writer of a variable.  This
  583. Xlast possibility is very useful, if, say a process agrees to
  584. Xdirectly take over a resource that can be passed around between
  585. Xprocesses.
  586. X
  587. X
  588. XHow to use the Common Memory System
  589. X
  590. XThis system emulates a shared common memory with specific features
  591. Xfor supporting communication between hierarchically controlled
  592. Xprocesses.
  593. X
  594. XThis document describes how to use the current implementation on
  595. Xthe Sun Workstation (running Sun UNIX 1.x, 2.x and 3.x).  It has
  596. Xalso been ported to the Silicon Graphics Iris.  It may be helpful
  597. Xto read the system description and implementation notes to get a
  598. Xbetter idea of how the system works.
  599. X
  600. XLet us get right to the usage details.
  601. X
  602. XProcesses
  603. X
  604. XBefore any other CMS calls, the process should identify itself to
  605. Xthe system:
  606. X
  607. X    int rc = cm_init("HWS","cmm_host",0);    /* C */
  608. X
  609. X    (cm_init "HWS" "cmm_host" 0)        ; Lisp
  610. X
  611. XHere, we have declared ourselves as "HWS".  This name need not be
  612. Xdistinct, however when debugging, you will find it helpful if you
  613. Xhave chosen different names for your cm users.
  614. X
  615. XThe second parameter to cm_init() is the host on which the
  616. Xcommon memory manager is running which you wish to use.  Note that
  617. Xthere may be a CMM running on the local machine, while you use one
  618. Xon a remote machine.  The local machine may be designated either by
  619. Xits name or by a null string.
  620. X
  621. XThe third parameter to cm_init() is an integer which
  622. Xindicates the debugging level.  0 indicates no debugging.  Larger
  623. Xvalues request more debugging info.  For example, 2 will give you
  624. Xinformation about messages sent and received.  5 will generate
  625. Xinformation about individual common memory values being
  626. Xmanipulated.  With 10, you will get a veritable flood of garbage
  627. X(that you almost certainly don't want) including things like memory
  628. Xallocation, variable copying, etc.
  629. X
  630. Xcm_init() also performs some necessary initialization of CM
  631. Xclient data structures.  cm_init() returns 0 if successful.
  632. XAnything else is an error.  A common error is that the common
  633. Xmemory manager (cmm) is not running.
  634. X
  635. XBefore a second (or any further calls to) cm_init() call,
  636. Xcm_exit() should be called.  cm_exit() tells the CMM that you have
  637. Xgone away.  It also cleans up various data structures internal to
  638. Xthe cm system.
  639. X
  640. XFor example:
  641. X
  642. X    cm_exit();
  643. X
  644. X    (cm_exit)                ; Lisp
  645. X
  646. X
  647. XDeclaring variables for use
  648. X
  649. XAll variables must be declared before use.  cm_declare() is used to
  650. Xdeclare common memory variables.
  651. X
  652. X    cm_variable *date;
  653. X
  654. X    date = cm_declare("date",CM_ROLE_XWRITER);
  655. X
  656. X    (setq date (cm_declare "date" CM_ROLE_WRITER))    ; Lisp
  657. X
  658. Xcm_declare() returns an object that can be used when referring to
  659. Xthis variable in the future.  This object can be stored into a
  660. Xvariable declared as type cm_variable.  If cm_declare() returns
  661. XCM_BAD_OBJECT, the declaration has failed (an error message will be
  662. Xprinted out explaining why).  Declarations can fail for a variety
  663. Xof reasons (bad or conflicting arguments, no space left to store
  664. Xvalues, etc).
  665. X
  666. XOnce cm_declare() has returned an object, this object should be
  667. Xused whenever referring to the variable.  In the case of
  668. Xcm_declare, the first argument is almost always a string, while in
  669. Xall other functions, the variable identifier is almost always a
  670. Xcm_variable.
  671. X
  672. XThe second argument of cm_declare() specifies access rights.  The
  673. Xavailable access rights are:
  674. X
  675. X    CM_ROLE_NONXWRITER    or CM_ROLE_NONEXCLUSIVE_WRITER
  676. X    CM_ROLE_XWRITER        or CM_ROLE_EXCLUSIVE_WRITER
  677. X    CM_ROLE_READER
  678. X    CM_ROLE_WAKEUP
  679. X
  680. XThese access rights can be combined by ORing.  For example, the
  681. Xwakeup right is always combined with at least one of the others.
  682. X"wakeup" causes the CMM to wake the process up whenever the
  683. Xvariable is written by someone else.
  684. X
  685. XObviously conflicting combinations should be avoided.  If one
  686. Xprocess has declared a variable CM_ROLE_XWRITER, other processes
  687. Xare prohibited from any kind of write access to that variable.
  688. XThese are the only restrictions on variable access.
  689. X
  690. XCommon memory values are structured in the following way.
  691. X
  692. XThis structure cm_value is used for this.
  693. X
  694. X    typedef struct {        /* common memory value */
  695. X        char *data;
  696. X        unsigned short msize;    /* size of malloc'd space */
  697. X        unsigned short size;    /* size of used space */
  698. X        char mallocable;    /* 1 if space is malloc() */
  699. X    } cm_value;
  700. X
  701. XIf mallocable is 1, CMS will allocate space using malloc whenever the
  702. XCMS passes a value to the user.  Further, if msize is ever smaller
  703. Xthan the incoming value, the pointer will be realloc'd and msize
  704. Xincreased appropriately.
  705. X
  706. XIf you are not prepared to handle objects larger than a given size,
  707. Xset msize yourself, and set mallocable to 0.  Lisp is an example
  708. Xwhere this must be done, as otherwise the common memory may
  709. Xattempt to free a Lisp object, which would be a serious mistake.
  710. X
  711. XThe address of such a structure may be passed to cm_set_value and
  712. Xit's relatives.
  713. X
  714. XA cm_value is declared in Lisp (via c-declare) along with
  715. Xcorresponding access functions.  For example, to declare and set
  716. Xthe various elements of the structure called "foo":
  717. X
  718. X    (setq foo (make-cm_value))        ; cm_value foo;
  719. X    (setq data (new-vectori-byte 1000))    ; char data[1000];
  720. X    (setf (cm_value->data foo) (ptr data))    ; foo.data = data;
  721. X    (setf (cm_value->size foo) 1000)    ; foo.size = 1000;
  722. X    (setf (cm_value->msize foo) 1000)    ; foo.msize = 1000;
  723. X    (setf (cm_value->mallocable foo) 0)    ; foo.mallocable = FALSE;
  724. X
  725. XUser-Defined Types
  726. X
  727. XThe original common memory design was to support user-defined
  728. Xtypes, but experience with other common memory systems have taught
  729. Xus that this is "a bad thing".  There is no reason why the common
  730. Xmemory should know the type of the data that it is storing.
  731. X
  732. XTo provide user-defined structured values, use ASN.1 (X.409).
  733. XThis provides for structured types which are machine independent.
  734. X
  735. X
  736. XReading and Writing Variables
  737. X
  738. XThere are two levels of access into the common memory.  Only the
  739. Xhigher-level will be covered here.  This higher-level incorporates
  740. Xfunctions that are tailored towards communications between
  741. Xprocesses in a hierarchically-controlled manner.
  742. X
  743. XVariables may be read and written with the following calls:
  744. X
  745. X    cm_value *value = {NULL,0,0,1};
  746. X    cm_get_value(variable,value);
  747. X    cm_set_value(variable,value);
  748. X
  749. X    (setq value (make-cm_value))
  750. X    (setf (value->data) 0)
  751. X    (setf (value->msize) 0)
  752. X    (setf (value->size) 0)
  753. X    (setf (value->mallocable) 1)
  754. X    (cm_get_value variable value)
  755. X    (cm_set_value variable value)
  756. X
  757. X
  758. XSeveral additional functions exist for handling handshaking
  759. Xbetween superior and subordinate processes in a control hierarchy.
  760. XSpecifically, variables can be used for command or status.  Status
  761. Xvariables are identified by the system with command value they are
  762. Xassociated with.  For more information, see the technical
  763. Xmemorandum, "Implementing Command-Feedback Variables in a
  764. XHierarchical Environment".
  765. X
  766. XVariables which are command variables should be read and written
  767. Xwith the following routines:
  768. X
  769. X    cm_set_new_command_value(variable,value);
  770. X    cm_get_new_command_value(variable,value);
  771. X
  772. X    (cm_set_new_command_value variable value)
  773. X    (cm_get_new_command_value variable value)
  774. X    
  775. XOne utility routine is available for determining whether a new
  776. Xcommand has been received.  cm_new_command_pending() returns TRUE
  777. Xor FALSE depending on whether a new command has been received.
  778. X
  779. X    maybe = cm_new_command_pending(command_variable);
  780. X
  781. X    (setq maybe (cm_new_command_pending command_variable))
  782. X
  783. XWhen a new command has been received, cm_new_command_pending will
  784. Xreturn TRUE until cm_get_new_command_value() has been called, after
  785. Xwhich it will return FALSE.  cm_get_new_command_value() also
  786. Xreturns TRUE or FALSE, depending upon whether it has detected a new
  787. Xcommand.  (Lisp users can expect t/nil instead of TRUE/FALSE.)
  788. X
  789. X
  790. XStatus variables must be written with the routine,
  791. Xcm_set_status_value().
  792. X
  793. X    cm_set_status_value(command,variable,value);
  794. X
  795. X    (cm_set_status_value command variable value)
  796. X
  797. XStatus (and any other) variables may be read with the routine
  798. Xcm_get_value().
  799. X
  800. XTwo predicates are available that are of use to the superior
  801. Xprocess in determining which command a subordinate process' status
  802. Xis in response to.
  803. X
  804. X    maybe = cm_status_equal(cmd_var,stat_var,s_value);
  805. X    maybe = cm_status_synchronized(cmd_var,stat_var);
  806. X
  807. X    (setq maybe (cm_status_equal cmd_var stat_var s_value))
  808. X    (setq maybe (cm_status_synchronized cmd_var stat_var))
  809. X
  810. Xcm_status_equal() returns TRUE or FALSE, depending on whether or
  811. Xnot the status variable, stat_var, has the value, s_value, and is
  812. Xin response to the command specified by cmd_var.
  813. X
  814. Xcm_status_synchronized() returns TRUE or FALSE, depending on
  815. Xwhether or not the status variable, stat_var, is in response to the
  816. Xcommand specified by cmd_var.  This is very helpful to the superior
  817. Xprocess in finding out whether the subordinate process is
  818. Xresponding the command.
  819. X
  820. XSynchronization
  821. X
  822. XSince the common memory and user processes are actually
  823. Xunsynchronized processes, it is necessary to synchronize them
  824. Xoccasionally.  The idea of calling cm_sync(), is to force all
  825. Xvariables in common to the user and CMM processes to have the same
  826. Xvalue.
  827. X
  828. X    cm_sync(behavior);
  829. X
  830. X    (cm_sync behavior)
  831. X
  832. Xcm_sync() takes one argument that allows several behaviors by the
  833. XCMM.  There are three sets of options.
  834. X
  835. XThe first specifies whether cm_sync() should wait for at least one
  836. Xset of variable updates (or any response from the CMM).  The
  837. Xdefault is CM_WAIT.  To poll and return immediately, use
  838. XCM_NO_WAIT.
  839. X
  840. XThe second option allows one the ability to examine the one set of
  841. Xvariable updates before it has (possibly) been overwritten by an
  842. Ximmediately following set of updates.  This is very useful if you
  843. Xhave a variable from which you expect to be written by multiple
  844. Xprocesses.
  845. X
  846. XSelecting CM_WAIT_AT_MOST_ONCE allows you to read a variables value
  847. Xbefore it is overwritten by yet another value from the CMM.  This
  848. Xis useful, for server processes, which takes requests off a queue.
  849. Xdefault is CM_WAIT_FOR_ALL which simply returns the most recently
  850. Xwritten value.
  851. X
  852. XThe third set of options controls whether the user desires an
  853. Ximmediate reply from the common memory.
  854. X
  855. X    cm_sync(CM_WAIT_READ);
  856. X
  857. XCM_WAIT_READ forces the common memory to respond with the current
  858. Xset of variable values (whether or not they have wakeup flags set
  859. Xon them).  If you expect to poll intermittently, a variable that is
  860. Xbeing regularly set, this is the desirable behavior.
  861. X
  862. XIf the CMS has already sent variable updates to you, CM_WAIT_READ
  863. Xwill get whichever ones are appropriate depending upon the other
  864. Xoptions you have supplied in cm_sync().  For example, specifying
  865. Xboth CM_WAIT_READ and CM_WAIT_FOR_ALL gives an exact simulation of
  866. Xa true common memory.  Note that using CM_WAIT_READ may be slower
  867. Xthan other forms of cm_sync() since you may have to wait for a
  868. Xreply message from the common memory.
  869. X
  870. XTo combine options, bitwise-OR them together.  For example, to poll
  871. Xfor at most one new set of variable values:
  872. X
  873. X    cm_sync(CM_NO_WAIT|CM_WAIT_AT_MOST_ONCE);
  874. X
  875. XHowever, it is expected that most clients will simply want to use:
  876. X
  877. X    cm_sync(CM_WAIT);
  878. X
  879. Xcm_sync returns either 0 (normal completion) or negative numbers
  880. Xdenoting an error (see the cm.h).
  881. X
  882. X
  883. XOther variable information
  884. X--------------------------
  885. X
  886. XVariables are more structured than in the BBN HCSE.  This allows easier
  887. Xcontrol of variables.  For example, handshaking between two levels of the
  888. Xhierarchy is automatically handled by command associations embedded in the
  889. Xvariable structures.  Variables are also tagged with their length,
  890. Xetc...
  891. X
  892. XCommon memory variables have the following attributes:
  893. X
  894. X    /* handshake.h */
  895. X
  896. X    char name[MAXVARIABLENAMELENGTH];
  897. X    unsigned long count;    /* nth definition of this value */
  898. X    unsigned long old_count;/* " " " " " " " " " " " " "when last read */
  899. X    unsigned short size;    /* size in bytes of the uninterpreted data */
  900. X    struct timeval *time_stamp;    /* when last written */
  901. X    command_association command_association; /* command that this variable
  902. X                            is associated with */
  903. X    command_association old_command_association; /* " " when last read */
  904. X    cm_value data;        /* uninterpreted data */
  905. X
  906. XVariables also have the following attributes (which are strictly
  907. Xinternal to the CMM).
  908. X
  909. X    char xwriter[PROCESSNAMELENGTH];    /* exclusive writer */
  910. X    struct {
  911. X        unsigned reader : 1;
  912. X        unsigned writer : 1;
  913. X        unsigned wakeup : 1;
  914. X        unsigned new : 1;        /* written since read */
  915. X    } role[PROCESSES];
  916. X
  917. X
  918. XCompiling (or interpreting) CM code
  919. X-------------------------------
  920. X
  921. XTwo libraries are necessary for using common memory.  cmlib.a is
  922. Xthe common memory client code.  This uses a lower-level library,
  923. Xlibstream.a, which provides connection and packet service on top of
  924. XTCP.  Both libraries normally live in /usr/local/lib.
  925. X
  926. XThus, to link common memory programs:
  927. X
  928. X    cc foo.c -lcm -lstream
  929. X
  930. XInclude files live in /usr/local/include/cm.  Normally, it is
  931. Xnecessary only to include /usr/include/sys/time.h and
  932. X/usr/local/include/cm/cm_user.h as follows:
  933. X
  934. X    #include <sys/time.h>
  935. X    #include <cm/cm.h>
  936. X
  937. X.lisp files are in /usr/local/lisp.  There is one file provided to
  938. Xinitialize common memory from lisp, cm_user.lisp.  Thus to use
  939. Xcommon memory, you should execute the following:
  940. X
  941. X    (load 'cm/cm_user.lisp)
  942. X
  943. XThe common memory manager itself, cmm, lives in /usr/local/bin.
  944. X
  945. XBefore any processes are started the CMM should be started up.
  946. XAnyone can do this (i.e.  you do not have to be root or have the
  947. Xsame uid as any other users of the CMM).  Just type:
  948. X
  949. X        /usr/local/bin/cmm
  950. XNormally, nothing else is required, however the cmm can take some
  951. Xarguments to modify the default behavior.
  952. X
  953. X    -d [0-9]
  954. X
  955. XThe argument will cause the cmm to print out debugging information.
  956. XHigher numbers evoke greater amounts of output.  0 means no
  957. Xdebugging.  3 refers to message handling.  6 refers to slot
  958. X(message contents) handling.  9 refers to most buffer/byte/string
  959. Xcoping.
  960. X
  961. X    -t seconds
  962. X
  963. Xblock waiting for up to this time period, if the a client's kernel
  964. Xqueue is full while the cmm is trying to send a message to the
  965. Xclient.  After the timeout expires, the cmm goes on and will retry
  966. Xlater.  This typically implies that the client is hung, but is not
  967. Xalways the case.  The default timeout period is 5 seconds.
  968. X
  969. X    -p port_number
  970. X
  971. XThe initial connection port that the common memory uses may be
  972. Xchanged by specifying the port number.  The default is 1525.  This
  973. Xis useful if you want to have multiple separate common memorys on a
  974. Xsingle computer.
  975. X
  976. X
  977. XThe cmm does not require a controlling terminal to run.  Note, that
  978. Xif the cmm is killed, all the processes using it will terminate if
  979. Xthey are writing at the moment that the cmm is killed.  This is due
  980. Xto a SIGPIPE being sent to each of the clients.  If you do not want
  981. Xthis behavior, you should probably surround your calls to cm_sync
  982. Xwith a setjmp/longjmp alarm, just the way one normally does with
  983. Xblocking writes.  (The common memory manager does this internally
  984. Xto protect itself from the clients dying.  You can look at it in
  985. Xman.c.)  In typical use, however, people do not do this, since the
  986. Xcommon memory never dies of its own accord.
  987. X
  988. XOnce the cmm is running, you can start the user processes.
  989. X(Specifically, the cmm process should be started before the first
  990. Xcm_process_name() is executed.)
  991. X
  992. X
  993. XAdditional Lisp notes
  994. X---------------------
  995. X
  996. XIn Lisp, all functions are identical to their C counterparts.
  997. XCommonsense dictates usage differences.  A small Rosetta stone will
  998. Xbe presented:
  999. X
  1000. X    date = cm_declare(......);
  1001. X    foo = cm_declare(.....,CM_ROLE_READER);
  1002. X    cm_sync(WAIT);
  1003. X    cm_set_value(date,"12 Dec...");
  1004. X    cm_get_value(foo,foolist);
  1005. X
  1006. X
  1007. X    (setq date (cm_declare 'date CM_ROLE_XWRITER))
  1008. X    (setq foo (cm_declare 'foo CM_ROLE_READER))
  1009. X
  1010. X    (cm_sync WAIT)
  1011. X    (cm_set_value date "12 Dec...")
  1012. X    (setq foo (cm_get_value foolist))
  1013. X
  1014. X
  1015. XNote that uppercase values denote constants that should be
  1016. Xevaluated before use (i.e.  unquoted).  For example, to check if
  1017. Xcm_declare() returns without failure the code would look like:
  1018. X
  1019. X    (cond ((eq CM_BAD_OBJECT (cm_declare ....)) nil)
  1020. X          (t t))
  1021. X
  1022. X
  1023. XPorting code over to the VAX (HCSE)
  1024. X
  1025. XThe following section is only appropriate to people using the BBN's
  1026. XHCSE code on the VAX running VMS.
  1027. X
  1028. XIt is possible to run the same code on the Sun (Sun CM) and the VAX
  1029. X(BBN HCSE) if certain steps are taken.
  1030. X
  1031. XAn interface library is supported that effectively replaces the
  1032. XSun CM user calls with calls into the HCSE library.  This library
  1033. Xis currently available in ~libes/cm/src.7v.
  1034. X
  1035. XCode using the the UNIX CM library with HCSE should add the
  1036. Xfollowing parameters to the link command (in a .opt file)
  1037. X
  1038. X    user1:[libes.cm.src$5n7v]suncmlib/lib,
  1039. X    cm_library:cmlib/lib,
  1040. X    psect=cm_shrmem,page
  1041. X
  1042. XVersions of the code compiled for debugging are available by
  1043. Xspecifying:
  1044. X
  1045. X    user1:[libes.cm.src$5n7v]suncmlib_debug/lib,
  1046. X    cm_library:cmlib_debug/lib,
  1047. X    psect=cm_shrmem,page
  1048. X
  1049. X
  1050. XThere are three restrictions upon use of the HCSE with Sun CM code.
  1051. X
  1052. XTypes
  1053. X
  1054. XThe type systems in both the Sun system and the HCSE system are
  1055. Xquite different.  The HCSE types are based on Praxis.  Primarily
  1056. Xthis means that they have user-definable types.  Secondly, there
  1057. Xare no arbitrarily-sized data objects.
  1058. X
  1059. XTwo extra parameters on the cm_declare statement exist in the HCSE
  1060. Xversion of Sun CM to get around this.
  1061. X
  1062. XThe first is a maximum size.  The second is a pointer to a type
  1063. Xstructure.  If the type structure pointer is zero, the size is used
  1064. Xto automatically select a type structure.  For more information
  1065. Xabout creating type structures, see the HCSE Programmers Manual.
  1066. X
  1067. XA typical call that would be portable to both the Sun and VAX
  1068. Xsystems looks like the following:
  1069. X
  1070. X    if (!(date = cm_declare("data",CM_ROLE_XWRITER
  1071. X#ifdef VAX11C
  1072. X        ,1000,0
  1073. X#endif
  1074. X                 ))) {
  1075. X        printf("declare of var failed\n");
  1076. X        exit(-1);
  1077. X     }
  1078. X
  1079. XWhen compiled by the DEC C compiler, the additional two parameters
  1080. Xwill be included.
  1081. X
  1082. X
  1083. XThe second difference in the UNIX CM system and the HCSE is that
  1084. Xthe HCSE does not support queuing of variable updates.  This means
  1085. Xthat if one process goes to sleep while a second process writes a
  1086. Xvariable several times, if the first process then wakes up, it will
  1087. Xsee only the last values written by the second process, not all the
  1088. Xintermediate ones.
  1089. X
  1090. XA different explanation of this phenomena is that there is no
  1091. Xdifference between specifying CM_WAIT_AT_MOST_ONCE and
  1092. XCM_WAIT_FOR_ALL in cm_sync().
  1093. X
  1094. X
  1095. XThe third difference is that the HCSE does not store command
  1096. Xassociations with variables in the cmm itself.  (In fact, they are
  1097. Xjust dropped on the floor).  Therefore, routines like
  1098. Xcm_status_equal() don't work.
  1099. X
  1100. XIf you need command associations or their effect (and most people
  1101. Xdo), you must do what other HCSE users do.  That is, to stuff in a
  1102. Xnumber in front of every variable indicating who many times this
  1103. Xvariable has been written.  Then create a new variable, that holds
  1104. Xthe old value of the number which you can use to compare it against.
  1105. X
  1106. XFor more information on this, read:
  1107. X
  1108. XAMRF Architectural Decision Document: Mailbox Format (2/20/85)
  1109. XAMRF Notice 85-1: Command-Status Message Structure (1/8/85)
  1110. X
  1111. XA package that implements this along with current mailbox types in
  1112. Xuse in the AMRF lives in k:~network/mailbox.  An example using
  1113. Xthese functions is in the cm source directory in vws.c.  vws.lisp
  1114. Xis a lisp version of the same thing.
  1115. X
  1116. X
  1117. XBasic limits of the CM system.
  1118. X
  1119. XCertain limitations exist in the CMM.  It is possible to change
  1120. Xany of these and recompile.  Changable limitations (and their
  1121. Xdefaults as the system is distributed are):
  1122. X
  1123. XCM_MSGSIZE    100000        /* Maximum size of any single set of variable
  1124. X                updates between the cmm and a user */
  1125. XCM_SLOTSIZE     20000        /* Maximum size of any single variable */
  1126. XCM_PROCESSNAMELENGTH   20    /* Maximum length of the process name */
  1127. XCM_VARIABLENAMELENGTH  20    /* Maximum length of any variable name */
  1128. XCM_MAXVARIABLES        50    /* Maximum number of variables local to the cmm */
  1129. XCM_MAXPROCESSES        20    /* Maximum number of processes that can talk to
  1130. X                the cmm simultaneously.  Absolute
  1131. X                maximum of 32 (or number of user
  1132. X                file descriptors) under 4.2BSD. */
  1133. XCM_MAXUSERVARIABLES 100 /* Max number of variables local to a user */
  1134. X
  1135. X
  1136. XErrors
  1137. X
  1138. XMost types of errors are reported at the user program.  Some
  1139. Xmessages cannot be reported back to the user, and are reported at
  1140. Xthe cmm itself.  Some errors are serious enough that they are
  1141. Xreported at both the user and cmm.
  1142. X
  1143. XUser errors
  1144. X
  1145. XMost user errors can be fixed when identified.  For example,
  1146. Xwriting into a variable declared to be read-only would be a
  1147. Xuser-error.
  1148. X
  1149. XSince user errors indicate a user-programming error, the CMS
  1150. Xusually prints out a message indicating the problem.  It also
  1151. Xreturns an error code if possible.  It is sometimes not possible to
  1152. Xdo this.  For instance, the above example would not be detected
  1153. Xuntil after cm_set_value returned.
  1154. X
  1155. XThe actual message would be printed by cm_sync when it is
  1156. Xprocessing incoming messages from the cmm.  Most types of errors
  1157. Xare detected by cm_sync.
  1158. X
  1159. XSystem errors
  1160. X
  1161. XSystem errors are caused by limitations in the CMS itself, the
  1162. Xenvironment it is running in and the user demands upon the system.
  1163. XOften, these cannot be avoided.  For example, if the user attempts
  1164. Xto send to much data to the common memory at once, the maximum
  1165. Xmessage size can be exceeded.
  1166. X
  1167. XListing of Error Messages
  1168. X
  1169. Xcm_init:
  1170. X    returns E_CM_INIT_FAILED
  1171. X    initport(client): Connection refused
  1172. X        Problem: cmm is not running.
  1173. X
  1174. Xcm_sync:
  1175. X    failed to send msg to cmm.  cmm disappeared?
  1176. X        Problem: cmm died.  Detected while writing to it.
  1177. X    cm library (version #) is older/newer than cmm (version #)
  1178. X        Problem: cmm is a different version than the
  1179. X        libraries your code is compiled with.  This can
  1180. X        also be caused by a corrupted message.  The is
  1181. X        usually identifiable by wildly different version #s.
  1182. X    bad slot encountered...aborting msg
  1183. X    user_decode_slot: unknown slot type (#)...msg aborted
  1184. X        Problem: corrupted message or internal error in CMS.
  1185. X    CMM: error processing variable <name> - error message
  1186. X        Problem: cmm detected error "error message" in
  1187. X        processing "name".  See below.
  1188. X    get_slot_read_response: <name> unknown (sent from cmm)
  1189. X        Problem: corrupted message or internal error in CMS
  1190. X    too much data for msg!!
  1191. X    output msg size = #  slotsize = #
  1192. X        Problem: User value is too large for CMS
  1193. X        configuration.  Either user error, or message size
  1194. X        limit should be increased.
  1195. X    cm_sd_free() called on nonmallocable object?
  1196. X        Problem: internal error in CMS
  1197. X
  1198. X*:
  1199. X    error: bcopy src/dest is null ptr
  1200. X        Problem: internal error or user error.  If user
  1201. X        error, check elements of cm_value structures to see
  1202. X        that they are consistent.
  1203. X
  1204. Xcmm:
  1205. X    bind() failed
  1206. X    initport(server): Address already in use
  1207. X    failed to initialize connection socket
  1208. X        Problem: another cmm is running, or a process
  1209. X        already has the CMM connection socket open.
  1210. X    get_variables(name) failed
  1211. X        Problem: too many variables in cmm.
  1212. X    process <name> is being antisocial on fd #
  1213. X        Problem: process has requested wakeup service but
  1214. X        is not listening to cmm updates.
  1215. X    slot bad
  1216. X        Problem: corrupted message or internal error in CMS
  1217. X    slot error in <name>  type # - error message
  1218. X        Problem: corrupted message or internal error in CMS
  1219. X        or user error.  See error message.  This message is
  1220. X        sent back to the user.  See below.
  1221. X
  1222. XError messages generated by the CMM and sent back to the user.
  1223. X    version
  1224. X        Problem: version mismatch.  See above.
  1225. X    bad slot type
  1226. X        Problem: corrupted message or internal CMS error.
  1227. X    not enough common memory to declare variable
  1228. X        Problem: too many variables stored at cmm.
  1229. X    cannot get nonexclusive write access
  1230. X        Problem: a process has already received exclusive
  1231. X        write access to this variable.
  1232. X    undeclare of undeclared variable
  1233. X        Problem: a nonexistent variable is being undeclared.
  1234. X    variable has not been declared
  1235. X        Problem: attempt to read/write variable not yet
  1236. X        declared.
  1237. X    not declared as writer
  1238. X        Problem: attempt to write variable declared as
  1239. X        read-only.
  1240. X    get_slot_write: cm_flat_to_sd() failed!  no space?
  1241. X        Problem: cmm ran out of memory trying to read user
  1242. X        message.  Indicates lack of system resources or
  1243. X        user sent value that was too large.
  1244. X    not declared as reader:
  1245. X        problem: attempt to read variable declared as
  1246. X        write-only.
  1247. X
  1248. XThere are several places in the CMS where memory is dynamically
  1249. Xallocated.  These may fail with an error such as
  1250. X
  1251. X    func: failed malloc(object,size)
  1252. X
  1253. Xor
  1254. X
  1255. X    resized failed! - out of space
  1256. X
  1257. Xwhere "func" is the CMS function calling malloc, "object" is the
  1258. Xobject being malloc'd and size is the size of the object.  
  1259. XThese errors typically indicate that either:
  1260. X
  1261. X1) the user is storing or receiving incredibly lengthy values
  1262. X(probably by mistake), or
  1263. X
  1264. X2) the system is running out of internal space
  1265. X
  1266. END_OF_FILE
  1267. if test 26953 -ne `wc -c <'doc/user.doc'`; then
  1268.     echo shar: \"'doc/user.doc'\" unpacked with wrong size!
  1269. fi
  1270. # end of 'doc/user.doc'
  1271. fi
  1272. echo shar: End of archive 4 \(of 4\).
  1273. cp /dev/null ark4isdone
  1274. MISSING=""
  1275. for I in 1 2 3 4 ; do
  1276.     if test ! -f ark${I}isdone ; then
  1277.     MISSING="${MISSING} ${I}"
  1278.     fi
  1279. done
  1280. if test "${MISSING}" = "" ; then
  1281.     echo You have unpacked all 4 archives.
  1282.     rm -f ark[1-9]isdone
  1283. else
  1284.     echo You still need to unpack the following archives:
  1285.     echo "        " ${MISSING}
  1286. fi
  1287. ##  End of shell archive.
  1288. exit 0
  1289.  
  1290.