ipc.xml 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020
  1. <?xml version="1.0" encoding="ISO8859-1"?>
  2. <fpdoc-descriptions>
  3. <!--
  4. $Id$
  5. This file is part of the FPC documentation.
  6. Copyright (C) 1997, by Michael Van Canneyt
  7. The FPC documentation is free text; you can redistribute it and/or
  8. modify it under the terms of the GNU Library General Public License as
  9. published by the Free Software Foundation; either version 2 of the
  10. License, or (at your option) any later version.
  11. The FPC Documentation is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. Library General Public License for more details.
  15. You should have received a copy of the GNU Library General Public
  16. License along with the FPC documentation; see the file COPYING.LIB. If not,
  17. write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  18. Boston, MA 02111-1307, USA.
  19. -->
  20. <package name="rtl">
  21. <module name="ipc">
  22. <short>Unix Inter Process Communication functionality.</short>
  23. <!-- \FPCexampledir{ipcex} -->
  24. <descr>
  25. <p>
  26. This document describes the IPC unit for Free Pascal. It was written for
  27. linux by Michael Van Canneyt. It gives all the functionality of system V
  28. Inter-Process Communication: shared memory, semaphores and messages.
  29. It works only on the linux operating system.
  30. </p>
  31. <p>
  32. Many constants here are provided for completeness only, and should under
  33. normal circumstances not be used by the programmer.
  34. </p>
  35. </descr>
  36. <element name="IPCerror">
  37. <short>Last IPC error code</short>
  38. <descr>
  39. The <var>IPCerror</var> variable is used to report errors, by all calls.
  40. </descr>
  41. </element>
  42. <element name="IPC_CREAT">
  43. <short>Create if key is nonexistent</short>
  44. </element>
  45. <element name="IPC_EXCL">
  46. <short>fail if key exists</short>
  47. </element>
  48. <element name="IPC_NOWAIT">
  49. <short>return error on wait</short>
  50. </element>
  51. <element name="IPC_RMID">
  52. <short>Remove resource</short>
  53. </element>
  54. <element name="IPC_SET">
  55. <short>set ipc_perm options</short>
  56. </element>
  57. <element name="IPC_STAT">
  58. <short>get ipc_perm options</short>
  59. </element>
  60. <element name="IPC_INFO">
  61. <short>For ipcs call</short>
  62. </element>
  63. <element name="MSG_NOERROR">
  64. <short>Internal Message control code. Do not use</short>
  65. </element>
  66. <element name="MSG_EXCEPT">
  67. <short>Internal Message control code. Do not use</short>
  68. </element>
  69. <element name="MSGMNI">
  70. <short>Internal Message control code. Do not use</short>
  71. </element>
  72. <element name="MSGMAX">
  73. <short>Internal Message control code. Do not use</short>
  74. </element>
  75. <element name="MSGMNB">
  76. <short>Internal Message control code. Do not use</short>
  77. </element>
  78. <element name="SEM_UNDO">
  79. <short>Constant for use in <link id="semop"/></short>
  80. </element>
  81. <element name="GETPID">
  82. <short>Constant for use in <link id="semop"/></short>
  83. </element>
  84. <element name="GETVAL">
  85. <short>Constant for use in <link id="semop"/></short>
  86. </element>
  87. <element name="GETALL">
  88. <short>Constant for use in <link id="semop"/></short>
  89. </element>
  90. <element name="GETNCNT">
  91. <short>Constant for use in <link id="semop"/></short>
  92. </element>
  93. <element name="GETZCNT">
  94. <short>Constant for use in <link id="semop"/></short>
  95. </element>
  96. <element name="SETVAL">
  97. <short>Constant for use in <link id="semop"/></short>
  98. </element>
  99. <element name="SETALL">
  100. <short>Constant for use in <link id="semop"/></short>
  101. </element>
  102. <element name="SEMMNI">
  103. <short>Internal semaphore system constant. Do not use.</short>
  104. </element>
  105. <element name="SEMMSL">
  106. <short>Internal semaphore system constant. Do not use.</short>
  107. </element>
  108. <element name="SEMMNS">
  109. <short>Internal semaphore system constant. Do not use.</short>
  110. </element>
  111. <element name="SEMOPM">
  112. <short>Internal semaphore system constant. Do not use.</short>
  113. </element>
  114. <element name="SEMVMX">
  115. <short>Internal semaphore system constant. Do not use.</short>
  116. </element>
  117. <element name="SHM_R">
  118. <short>This constant is used in the <link id="shmctl"/> call.</short>
  119. </element>
  120. <element name="SHM_W">
  121. <short>This constant is used in the <link id="shmctl"/> call.</short>
  122. </element>
  123. <element name="SHM_RDONLY">
  124. <short>This constant is used in the <link id="shmctl"/> call.</short>
  125. </element>
  126. <element name="SHM_RND">
  127. <short>This constant is used in the <link id="shmctl"/> call.</short>
  128. </element>
  129. <element name="SHM_REMAP">
  130. <short>This constant is used in the <link id="shmctl"/> call.</short>
  131. </element>
  132. <element name="SHM_LOCK">
  133. <short>This constant is used in the <link id="shmctl"/> call.</short>
  134. </element>
  135. <element name="SHM_UNLOCK">
  136. <short>This constant is used in the <link id="shmctl"/> call.</short>
  137. </element>
  138. <element name="BaseUnix">
  139. <short>Some base types</short>
  140. </element>
  141. <element name="key_t">
  142. <short>Alias for <link id="TKey"/> type</short>
  143. </element>
  144. <element name="TIPC_Perm.mode">
  145. <short>Creation Mode</short>
  146. </element>
  147. <element name="TSHMinfo.shmmni">
  148. <short>?</short>
  149. </element>
  150. <element name="msglen_t">
  151. <short>Message length type</short>
  152. </element>
  153. <element name="msgqnum_t">
  154. <short>Message queue number type</short>
  155. </element>
  156. <element name="PMSG">
  157. <short>Pointer to <link id="TMSG"/> record</short>
  158. </element>
  159. <element name="PMSQid_ds">
  160. <short>Pointer to <link id="TMSQid_ds"/></short>
  161. </element>
  162. <element name="PMSGbuf">
  163. <short>Pointer to <link id="TMsgBuf"/> rcord</short>
  164. </element>
  165. <element name="SEM_GETPID">
  166. <short>Semaphore operation: Get process ID of last operation.</short>
  167. </element>
  168. <element name="SEM_GETVAL">
  169. <short>Semaphore operation: Get current value of semaphore</short>
  170. </element>
  171. <element name="SEM_GETALL">
  172. <short>Semaphore operation: Get all semaphore values</short>
  173. </element>
  174. <element name="SEM_GETNCNT">
  175. <short>Semaphore operation: Get number of processes waiting for resource.</short>
  176. </element>
  177. <element name="SEM_GETZCNT">
  178. <short>Semaphore operation: Get number of processes waiting for semaphores to reach zero </short>
  179. </element>
  180. <element name="SEM_SETVAL">
  181. <short>Semaphore operation: Set semaphore value</short>
  182. </element>
  183. <element name="SEM_SETALL">
  184. <short>Semaphore operation: Set all semaphore values</short>
  185. </element>
  186. <element name="SEM_SEMMNI">
  187. <short>Semaphore operation: ?</short>
  188. </element>
  189. <element name="SEM_SEMMSL">
  190. <short>Semaphore operation: ?</short>
  191. </element>
  192. <element name="SEM_SEMMNS">
  193. <short>Semaphore operation: ?</short>
  194. </element>
  195. <element name="SEM_SEMOPM">
  196. <short>Semaphore operation: ?</short>
  197. </element>
  198. <element name="SEM_SEMVMX">
  199. <short>Semaphore operation: ?</short>
  200. </element>
  201. <element name="TSEMid_ds.sem_nsems">
  202. <short>Number of semaphores</short>
  203. </element>
  204. <element name="PULong">
  205. <short>Pointer to cardinal type.</short>
  206. </element>
  207. <element name="PWord">
  208. <short>Pointer to word type.</short>
  209. </element>
  210. <element name="TKey">
  211. <short>Type returned by the <link id="ftok"/> key generating
  212. function.</short>
  213. </element>
  214. <element name="TIPC_Perm">
  215. <short>Record used in all IPC systems to specify the permissions.</short>
  216. <descr>
  217. <var>TIPC_Perm</var> is used in all IPC systems to specify the permissions.
  218. It should never be used directly.
  219. </descr>
  220. </element>
  221. <element name="TIPC_Perm.Key">
  222. <short>key used to create resource</short>
  223. </element>
  224. <element name="TIPC_Perm.uid">
  225. <short>Owner user ID</short>
  226. </element>
  227. <element name="TIPC_Perm.gid">
  228. <short>Owner group id</short>
  229. </element>
  230. <element name="TIPC_Perm.cuid">
  231. <short>Creator user ID</short>
  232. </element>
  233. <element name="TIPC_Perm.cgid">
  234. <short>Creator group ID</short>
  235. </element>
  236. <element name="TIPC_Perm.seq">
  237. <short>?</short>
  238. </element>
  239. <element name="PIPC_Perm">
  240. <short>Pointer to <link id="TIPC_Perm"/> record.</short>
  241. </element>
  242. <element name="TSHMid_ds">
  243. <short>Record used in the <link id="shmctl"/> call to set or retrieve settings for shared memory.</short>
  244. </element>
  245. <element name="PSHMid_DS">
  246. <short>Pointer to <link id="TSHMid_ds"/> record.</short>
  247. </element>
  248. <element name="TSHMid_ds.shm_perm">
  249. <short>Permissions</short>
  250. </element>
  251. <element name="TSHMid_ds.shm_segsz">
  252. <short>Segment size</short>
  253. </element>
  254. <element name="TSHMid_ds.shm_atime">
  255. <short>Last access time</short>
  256. </element>
  257. <element name="TSHMid_ds.shm_dtime">
  258. <short>Last detach time</short>
  259. </element>
  260. <element name="TSHMid_ds.shm_ctime">
  261. <short>Create time</short>
  262. </element>
  263. <element name="TSHMid_ds.shm_cpid">
  264. <short>Creator PID</short>
  265. </element>
  266. <element name="TSHMid_ds.shm_lpid">
  267. <short>Last operation PID</short>
  268. </element>
  269. <element name="TSHMid_ds.shm_nattch">
  270. <short>Number of attachments</short>
  271. </element>
  272. <element name="TSHMid_ds.shm_npages">
  273. <short>Number of pages</short>
  274. </element>
  275. <element name="TSHMid_ds.shm_pages">
  276. <short>?</short>
  277. </element>
  278. <element name="TSHMid_ds.attaches">
  279. <short>?</short>
  280. </element>
  281. <element name="TSHMinfo">
  282. <short>Record used by the shared memory system, Do not use directly.</short>
  283. </element>
  284. <element name="TSHMinfo.shmmax" skip="1"/>
  285. <element name="TSHMinfo.shmmin" skip="1"/>
  286. <element name="TSHMinfo.smmni" skip="1"/>
  287. <element name="TSHMinfo.shmseg" skip="1"/>
  288. <element name="TSHMinfo.shmall" skip="1"/>
  289. <element name="PSHMinfo" skip="1"/>
  290. <element name="TMSG">
  291. <short>Record used in the handling of message queues. Do not use directly.</short>
  292. </element>
  293. <element name="TMSG.msg_next" skip="1"/>
  294. <element name="TMSG.msg_type" skip="1"/>
  295. <element name="TMSG.msg_spot" skip="1"/>
  296. <element name="TMSG.msg_stime" skip="1"/>
  297. <element name="TMSG.msg_ts" skip="1"/>
  298. <element name="TMSQid_ds">
  299. <short>Record returned by the <link id="msgctl"/> call, contains all data about a message queue.</short>
  300. <descr>
  301. This record should never be used directly, it is an internal kernel record.
  302. It's fields may change at any time.
  303. </descr>
  304. </element>
  305. <element name="TMSQid_ds.msg_perm">
  306. <short>Queue permissions</short>
  307. </element>
  308. <element name="TMSQid_ds.msg_first">
  309. <short>Pointer to first message</short>
  310. </element>
  311. <element name="TMSQid_ds.msg_last">
  312. <short>Pointer to last message</short>
  313. </element>
  314. <element name="TMSQid_ds.msg_stime">
  315. <short>Last send time</short>
  316. </element>
  317. <element name="TMSQid_ds.msg_rtime">
  318. <short>Last receive time</short>
  319. </element>
  320. <element name="TMSQid_ds.msg_ctime">
  321. <short>Last control time</short>
  322. </element>
  323. <element name="TMSQid_ds.wwait">
  324. <short></short>
  325. </element>
  326. <element name="TMSQid_ds.rwait">
  327. <short></short>
  328. </element>
  329. <element name="TMSQid_ds.msg_cbytes">
  330. <short></short>
  331. </element>
  332. <element name="TMSQid_ds.msg_qnum">
  333. <short></short>
  334. </element>
  335. <element name="TMSQid_ds.msg_qbytes">
  336. <short></short>
  337. </element>
  338. <element name="TMSQid_ds.msg_lspid">
  339. <short></short>
  340. </element>
  341. <element name="TMSQid_ds.msg_lrpid">
  342. <short></short>
  343. </element>
  344. <element name="TMSGbuf">
  345. <short>Generic message data record</short>
  346. <descr>
  347. The <var>TMSGbuf</var> record is a record containing the data of a record. you
  348. should never use this record directly, instead you should make your own
  349. record that follows the structure of the <var>TMSGbuf</var> record, but that has
  350. a size that is big enough to accomodate your messages. The <var>mtype</var> field
  351. should always be present, and should always be filled.
  352. </descr>
  353. </element>
  354. <element name="TMSGbuf.mtype">
  355. <short>Message type</short>
  356. </element>
  357. <element name="TMSGbuf.mtext">
  358. <short>Message data</short>
  359. </element>
  360. <element name="TMSGinfo" skip="1">
  361. <short>Internal message system record. Do not use directly.</short>
  362. </element>
  363. <element name="TMSGinfo.msgpool" skip="1"/>
  364. <element name="TMSGinfo.msgmap" skip="1"/>
  365. <element name="TMSGinfo.msgmax" skip="1"/>
  366. <element name="TMSGinfo.msgmax" skip="1"/>
  367. <element name="TMSGinfo.msgmnb" skip="1"/>
  368. <element name="TMSGinfo.msgmni" skip="1"/>
  369. <element name="TMSGinfo.msgssz" skip="1"/>
  370. <element name="TMSGinfo.msgtql" skip="1"/>
  371. <element name="TMSGinfo.msgseg" skip="1"/>
  372. <element name="PMSGinfo" skip="1">
  373. <short>Pointer to <link id="TMSGinfo"/> record</short>
  374. </element>
  375. <element name="TSEMid_ds">
  376. <short>Structure returned by the <link id="semctl"/> call, contains all data of a semahore</short>
  377. </element>
  378. <element name="PSEMid_ds">
  379. <short>Pointer to <link id="TSEMid_ds"/> record.</short>
  380. </element>
  381. <element name="TSEMid_ds.sem_perm">
  382. <short>IPC permissions</short>
  383. </element>
  384. <element name="TSEMid_ds.sem_otime">
  385. <short>Last operation time</short>
  386. </element>
  387. <element name="TSEMid_ds.sem_ctime">
  388. <short>Create time</short>
  389. </element>
  390. <element name="TSEMid_ds.sem_base">
  391. <short>Internal data. Do not use</short>
  392. </element>
  393. <element name="TSEMid_ds.sem_pending">
  394. <short>Internal data. Do not use</short>
  395. </element>
  396. <element name="TSEMid_ds.sem_pending_last">
  397. <short>Internal data. Do not use</short>
  398. </element>
  399. <element name="TSEMid_ds.undo">
  400. <short>Internal data. Do not use</short>
  401. </element>
  402. <element name="TSEMid_ds.nsems">
  403. <short>Internal data. Do not use</short>
  404. </element>
  405. <element name="TSEMbuf">
  406. <short>Record used in <link id="semop"/> call.</short>
  407. <descr>
  408. The <var>TSEMbuf</var> record is used in the <link id="semop"/> call, and is
  409. used to specify which operations you want to do.
  410. </descr>
  411. </element>
  412. <element name="PSEMbuf">
  413. <short>Pointer to <link id="TSembuf"/> record.</short>
  414. </element>
  415. <element name="TSEMbuf.sem_num">
  416. <short>Number of the semaphore to perform operation on.</short>
  417. </element>
  418. <element name="TSEMbuf.sem_op">
  419. <short>Operation to perform on semaphore</short>
  420. </element>
  421. <element name="TSEMbuf.sem_flg">
  422. <short>Flags for operation.</short>
  423. </element>
  424. <element name="TSEMinfo" skip="1">
  425. <short>Internal semaphore system record. Do not use.</short>
  426. </element>
  427. <element name="TSEMinfo.semmap" skip="1"/>
  428. <element name="TSEMinfo.semmni" skip="1"/>
  429. <element name="TSEMinfo.semmns" skip="1"/>
  430. <element name="TSEMinfo.semmnu" skip="1"/>
  431. <element name="TSEMinfo.semmsl" skip="1"/>
  432. <element name="TSEMinfo.semopm" skip="1"/>
  433. <element name="TSEMinfo.semume" skip="1"/>
  434. <element name="TSEMinfo.semusz" skip="1"/>
  435. <element name="TSEMinfo.semvmx" skip="1"/>
  436. <element name="TSEMinfo.semaem" skip="1"/>
  437. <element name="PSEMinfo">
  438. <short>Pointer to <link id="TSEMinfo"/> record.</short>
  439. </element>
  440. <element name="TSEMun">
  441. <short>Record used in <link id="semctl"/> call.</short>
  442. </element>
  443. <element name="PSEMun">
  444. <short>Pointer to <link id="TSEMun"/> record</short>
  445. </element>
  446. <element name="ftok">
  447. <short>Create token from filename</short>
  448. <descr>
  449. <p>
  450. <var>ftok</var> returns a key that can be used in a <link id="semget"/>
  451. <link id="shmget"/>
  452. or <link id="msgget"/> call to access a new or existing IPC resource.
  453. </p>
  454. <p>
  455. <var>Path</var> is the name of a file in the file system, <var>ID</var> is a
  456. character of your choice. The ftok call does the same as it's C couterpart,
  457. so a pascal program and a C program will access the same resource if
  458. they use the same <var>Path</var> and <var>ID</var>
  459. </p>
  460. <p>
  461. For an example, see <link id="msgctl"/>, <link id="semctl"/> or <link id="shmctl"/>.
  462. </p>
  463. </descr>
  464. <errors>
  465. <var>ftok</var> returns -1 if the file in <var>Path</var> doesn't exist.
  466. </errors>
  467. <seealso>
  468. <link id="semget"/>
  469. <link id="shmget"/>
  470. <link id="msgget"/>
  471. </seealso>
  472. </element>
  473. <element name="msgget">
  474. <short>Return message queue ID, possibly creating the queue</short>
  475. <descr>
  476. <p>
  477. <var>msgget</var> returns the ID of the message queue described by <var>key</var>.
  478. Depending on the flags in <var>msgflg</var>, a new queue is created.
  479. </p>
  480. <p>
  481. <var>msgflg</var> can have one or more of the following values (combined by ORs):
  482. </p>
  483. <dl>
  484. <dt>IPC_CREAT</dt><dd> The queue is created if it doesn't already exist.</dd>
  485. <dt>IPC_EXCL</dt><dd> If used in combination with <var>IPC_CREAT</var>, causes the
  486. call to fail if the queue already exists. It cannot be used by itself.
  487. </dd>
  488. </dl>
  489. <p>
  490. Optionally, the flags can be <var>OR</var>ed with a permission mode, which is the
  491. same mode that can be used in the file system.
  492. </p>
  493. <p>
  494. For an example, see <link id="msgctl"/>.
  495. </p>
  496. </descr>
  497. <errors>
  498. On error, -1 is returned, and <var>IPCError</var> is set.
  499. </errors>
  500. <seealso>
  501. <link id="ftok"/>
  502. <link id="msgsnd"/>
  503. <link id="msgrcv"/>
  504. <link id="msgctl"/>
  505. </seealso>
  506. </element>
  507. <element name="msgsnd">
  508. <short>Send a message to the messague queue</short>
  509. <descr>
  510. <p>
  511. <var>msgsend</var> sends a message to a message queue with ID <var>msqid</var>.
  512. <var>msgp</var> is a pointer to a message buffer, that should be based on the
  513. <var>TMsgBuf</var> type. <var>msgsiz</var> is the size of the message (NOT of the
  514. message buffer record !)
  515. </p>
  516. <p>
  517. The <var>msgflg</var> can have a combination of the following values (ORed
  518. together):
  519. </p>
  520. <dl>
  521. <dt>0</dt><dd>No special meaning. The message will be written to the queue.
  522. If the queue is full, then the process is blocked.</dd>
  523. <dt>IPC_NOWAIT</dt><dd> If the queue is full, then no message is written,
  524. and the call returns immediatly.
  525. </dd>
  526. </dl>
  527. <p>
  528. The function returns <var>True</var> if the message was sent successfully,
  529. <var>False</var> otherwise.
  530. </p>
  531. <p>
  532. For an example, see <link id="msgctl"/>.
  533. </p>
  534. </descr>
  535. <errors>
  536. In case of error, the call returns <var>False</var>, and <var>IPCerror</var> is set.
  537. </errors>
  538. <seealso>
  539. <link id="msgget"/>
  540. <link id="msgrcv"/>
  541. <link id="msgctl"/>
  542. </seealso>
  543. </element>
  544. <element name="msgrcv">
  545. <short>Retrieve a message from the queue</short>
  546. <descr>
  547. <p>
  548. <var>msgrcv</var> retrieves a message of type <var>msgtyp</var> from the message
  549. queue with ID <var>msqid</var>. <var>msgtyp</var> corresponds to the <var>mtype</var>
  550. field of the <var>TMSGbuf</var> record. The message is stored in the <var>MSGbuf</var>
  551. structure pointed to by <var>msgp</var>.
  552. </p>
  553. <p>
  554. The <var>msgflg</var> parameter can be used to control the behaviour of the
  555. <var>msgrcv</var> call. It consists of an ORed combination of the following
  556. flags:
  557. </p>
  558. <dl>
  559. <dt>0</dt><dd> No special meaning.</dd>
  560. <dt>IPC_NOWAIT</dt><dd>if no messages are available, then the call returns
  561. immediatly, with the <var>ENOMSG</var> error.</dd>
  562. <dt>MSG_NOERROR</dt><dd> If the message size is wrong (too large),
  563. no error is generated, instead the message is truncated.
  564. Normally, in such cases, the call returns an error (E2BIG)
  565. </dd>
  566. </dl>
  567. <p>
  568. The function returns <var>True</var> if the message was received correctly,
  569. <var>False</var> otherwise.
  570. </p>
  571. <p>
  572. For an example, see <link id="msgctl"/>.
  573. </p>
  574. </descr>
  575. <errors>
  576. In case of error, <var>False</var> is returned, and <var>IPCerror</var> is set.
  577. </errors>
  578. <seealso>
  579. <link id="msgget"/>
  580. <link id="msgsnd"/>
  581. <link id="msgctl"/>
  582. </seealso>
  583. </element>
  584. <element name="msgctl">
  585. <short>Perform various operations on a message queue</short>
  586. <descr>
  587. <p>
  588. <var>msgctl</var> performs various operations on the message queue with id
  589. <var>ID</var>. Which operation is performed, depends on the <var>cmd</var>
  590. parameter, which can have one of the following values:
  591. </p>
  592. <dl>
  593. <dt>IPC_STAT</dt><dd> In this case, the <var>msgctl</var> call fills the
  594. <var>TMSQid_ds</var> structure with information about the message queue.
  595. </dd>
  596. <dt>IPC_SET</dt><dd> in this case, the <var>msgctl</var> call sets the permissions
  597. of the queue as specified in the <var>ipc_perm</var> record inside <var>buf</var>.
  598. </dd><dt>IPC_RMID</dt><dd> If this is specified, the message queue will be removed
  599. from the system.
  600. </dd>
  601. </dl>
  602. <p>
  603. <var>buf</var> contains the data that are needed by the call. It can be
  604. <var>Nil</var> in case the message queue should be removed.
  605. </p>
  606. <p>
  607. The function returns <var>True</var> if successfull, <var>False</var> otherwise.
  608. </p>
  609. </descr>
  610. <errors>
  611. On error, <var>False</var> is returned, and <var>IPCerror</var> is set accordingly.
  612. </errors>
  613. <seealso>
  614. <link id="msgget"/>
  615. <link id="msgsnd"/>
  616. <link id="msgrcv"/>
  617. </seealso>
  618. <example file="ipcex/msgtool"/>
  619. </element>
  620. <element name="semget">
  621. <short>Return the ID of a semaphore set, possibly creating the set</short>
  622. <descr>
  623. <p>
  624. <var>msgget</var> returns the ID of the semaphore set described by <var>key</var>.
  625. Depending on the flags in <var>semflg</var>, a new queue is created.
  626. </p>
  627. <p>
  628. <var>semflg</var> can have one or more of the following values (combined by ORs):
  629. </p>
  630. <dl>
  631. <dt>IPC_CREAT</dt><dd> The queue is created if it doesn't already exist.</dd>
  632. <dt>IPC_EXCL</dt><dd> If used in combination with <var>IPC_CREAT</var>, causes the
  633. call to fail if the set already exists. It cannot be used by itself.</dd>
  634. </dl>
  635. <p>
  636. Optionally, the flags can be <var>OR</var>ed with a permission mode, which is the
  637. same mode that can be used in the file system.
  638. </p>
  639. <p>
  640. if a new set of semaphores is created, then there will be <var>nsems</var>
  641. semaphores in it.
  642. </p>
  643. </descr>
  644. <errors>
  645. On error, -1 is returned, and <var>IPCError</var> is set.
  646. </errors>
  647. <seealso>
  648. <link id="ftok"/>
  649. <link id="semop"/>
  650. <link id="semctl"/>
  651. </seealso>
  652. </element>
  653. <element name="semop">
  654. <short>Perform semaphore operation.</short>
  655. <descr>
  656. <p>
  657. <var>semop</var> performs a set of operations on a message queue.
  658. <var>sops</var> points to an array of type <var>TSEMbuf</var>. The array should
  659. contain <var>nsops</var> elements.
  660. </p>
  661. <p>
  662. The fields of the <link id="TSEMbuf"/> structure
  663. </p>
  664. <code>
  665. TSEMbuf = record
  666. sem_num : word;
  667. sem_op : integer;
  668. sem_flg : integer;
  669. </code>
  670. <p>
  671. should be filled as follows:
  672. </p>
  673. <dl>
  674. <dt>sem_num</dt><dd> The number of the semaphore in the set on which the
  675. operation must be performed.</dd>
  676. <dt>sem_op</dt><dd>
  677. The operation to be performed. The operation depends on the
  678. sign of <var>sem_op</var>:
  679. A positive number is simply added to the current value of the
  680. semaphore. If 0 (zero) is specified, then the process is suspended until the
  681. specified semaphore reaches zero. If a negative number is specified, it is substracted from the
  682. current value of the semaphore. If the value would become negative
  683. then the process is suspended until the value becomes big enough, unless
  684. <var>IPC_NOWAIT</var> is specified in the <var>sem_flg</var>.
  685. </dd>
  686. <dt>sem_flg</dt>
  687. <dd> Optional flags: if <var>IPC_NOWAIT</var> is specified, then the
  688. calling process will never be suspended.
  689. </dd>
  690. </dl>
  691. <p>
  692. The function returns <var>True</var> if the operations were successful,
  693. <var>False</var> otherwise.
  694. </p>
  695. </descr>
  696. <errors>
  697. In case of error, <var>False</var> is returned, and <var>IPCerror</var> is set.
  698. </errors>
  699. <seealso>
  700. <link id="semget"/>
  701. <link id="semctl"/>
  702. </seealso>
  703. </element>
  704. <element name="semctl">
  705. <short>Perform various control operations on a semaphore set</short>
  706. <descr>
  707. <p>
  708. <var>semctl</var> performs various operations on the semaphore <var>semnum</var> w
  709. ith semaphore set id <var>ID</var>.
  710. </p>
  711. <p>
  712. The <var>arg</var> parameter supplies the data needed for each call. This is
  713. a variant record that should be filled differently, according to the
  714. command:
  715. </p>
  716. <code>
  717. Type
  718. TSEMun = record
  719. case longint of
  720. 0 : ( val : longint );
  721. 1 : ( buf : PSEMid_ds );
  722. 2 : ( arr : PWord );
  723. 3 : ( padbuf : PSeminfo );
  724. 4 : ( padpad : pointer );
  725. end;
  726. </code>
  727. <p>
  728. Which operation is performed, depends on the <var>cmd</var>
  729. parameter, which can have one of the following values:
  730. </p>
  731. <dl>
  732. <dt>IPC_STAT</dt>
  733. <dd> In this case, the arg record should have it's <var>buf</var>
  734. field set to the address of a <var>TSEMid_ds</var> record.
  735. The <var>semctl</var> call fills this <var>TSEMid_ds</var> structure with information
  736. about the semaphore set.
  737. </dd>
  738. <dt>IPC_SET</dt>
  739. <dd> In this case, the <var>arg</var> record should have it's <var>buf</var>
  740. field set to the address of a <var>TSEMid_ds</var> record.
  741. The <var>semctl</var> call sets the permissions of the queue as specified in
  742. the <var>ipc_perm</var> record.
  743. </dd>
  744. <dt>IPC_RMID</dt>
  745. <dd> If this is specified, the semaphore set is removed from
  746. from the system.
  747. </dd>
  748. <dt>GETALL</dt>
  749. <dd> In this case, the <var>arr</var> field of <var>arg</var> should point
  750. to a memory area where the values of the semaphores will be stored.
  751. The size of this memory area is \var{SizeOf(Word)* Number of semaphores
  752. in the set}.
  753. This call will then fill the memory array with all the values of the
  754. semaphores.
  755. </dd>
  756. <dt>GETNCNT</dt>
  757. <dd> This will fill the <var>val</var> field of the <var>arg</var> union
  758. with the number of processes waiting for resources.
  759. </dd>
  760. <dt>GETPID</dt>
  761. <dd> <var>semctl</var> returns the process ID of the process that
  762. performed the last <link id="semop"/> call.
  763. </dd>
  764. <dt>GETVAL</dt>
  765. <dd> <var>semctl</var> returns the value of the semaphore with number
  766. <var>semnum</var>.
  767. </dd>
  768. <dt>GETZCNT</dt>
  769. <dd> <var>semctl</var> returns the number of processes waiting for
  770. semaphores that reach value zero.
  771. </dd>
  772. <dt>SETALL</dt>
  773. <dd> In this case, the <var>arr</var> field of <var>arg</var> should point
  774. to a memory area where the values of the semaphores will be retrieved from.
  775. The size of this memory area is \var{SizeOf(Word)* Number of semaphores
  776. in the set}.
  777. This call will then set the values of the semaphores from the memory array.
  778. </dd>
  779. <dt>SETVAL</dt>
  780. <dd> This will set the value of semaphore <var>semnum</var> to the value
  781. in the <var>val</var> field of the <var>arg</var> parameter.
  782. </dd>
  783. </dl>
  784. <p>
  785. The function returns -1 on error.
  786. </p>
  787. </descr>
  788. <errors>
  789. The function returns -1 on error, and <var>IPCerror</var> is set accordingly.
  790. </errors>
  791. <seealso>
  792. <link id="semget"/>
  793. <link id="semop"/>
  794. </seealso>
  795. <example file="ipcex/semtool"/>
  796. </element>
  797. <element name="shmget">
  798. <short>Return the ID of a shared memory block, possibly creating it</short>
  799. <descr>
  800. <p>
  801. <var>shmget</var> returns the ID of a shared memory block, described by <var>key</var>.
  802. Depending on the flags in <var>flag</var>, a new memory block is created.
  803. </p>
  804. <p>
  805. <var>flag</var> can have one or more of the following values (combined by ORs):
  806. </p>
  807. <dl>
  808. <dt>IPC_CREAT</dt>
  809. <dd> The queue is created if it doesn't already exist.
  810. </dd>
  811. <dt>IPC_EXCL</dt>
  812. <dd> If used in combination with <var>IPC_CREAT</var>, causes the
  813. call to fail if the queue already exists. It cannot be used by itself.
  814. </dd>
  815. </dl>
  816. <p>
  817. Optionally, the flags can be <var>OR</var>ed with a permission mode, which is the
  818. same mode that can be used in the file system.
  819. </p>
  820. <p>
  821. if a new memory block is created, then it will have size <var>Size</var>
  822. bytes in it.
  823. </p>
  824. </descr>
  825. <errors>
  826. On error, -1 is returned, and <var>IPCError</var> is set.
  827. </errors>
  828. <seealso>
  829. </seealso>
  830. </element>
  831. <element name="shmat">
  832. <short>Attach a shared memory block.</short>
  833. <descr>
  834. <p>
  835. <var>shmat</var> attaches a shared memory block with identified <var>shmid</var>
  836. to the current process. The function returns a pointer to the shared memory
  837. block.
  838. </p>
  839. <p>
  840. If <var>shmaddr</var> is <var>Nil</var>, then the system chooses a free unmapped
  841. memory region, as high up in memory space as possible.
  842. </p>
  843. <p>
  844. If <var>shmaddr</var> is non-nil, and <var>SHM_RND</var> is in <var>shmflg</var>, then
  845. the returned address is <var>shmaddr</var>, rounded down to <var>SHMLBA</var>.
  846. If <var>SHM_RND</var> is not specified, then <var>shmaddr</var> must be a
  847. page-aligned address.
  848. </p>
  849. <p>
  850. The parameter <var>shmflg</var> can be used to control the behaviour of the
  851. <var>shmat</var> call. It consists of a ORed combination of the following
  852. constants:
  853. </p>
  854. <dl>
  855. <dt>SHM_RND</dt> <dd> The suggested address in <var>shmaddr</var> is rounded down to
  856. <var>SHMLBA</var>.
  857. </dd>
  858. <dt>SHM_RDONLY</dt> <dd> the shared memory is attached for read access only.
  859. Otherwise the memory is attached for read-write. The process then needs
  860. read-write permissions to access the shared memory.
  861. </dd>
  862. </dl>
  863. <p>
  864. For an example, see <link id="shmctl"/>.
  865. </p>
  866. </descr>
  867. <errors>
  868. If an error occurs, -1 is returned, and <var>IPCerror</var> is set.
  869. </errors>
  870. <seealso>
  871. <link id="shmget"/>
  872. <link id="shmdt"/>
  873. <link id="shmctl"/>
  874. </seealso>
  875. </element>
  876. <element name="shmdt">
  877. <short>Detach shared memory block.</short>
  878. <descr>
  879. <p>
  880. <var>shmdt</var> detaches the shared memory at address <var>shmaddr</var>. This shared
  881. memory block is unavailable to the current process, until it is attached
  882. again by a call to <link id="shmat"/>.
  883. </p>
  884. <p>
  885. The function returns <var>True</var> if the memory block was detached
  886. successfully, <var>False</var> otherwise.
  887. </p>
  888. </descr>
  889. <errors>
  890. On error, False is returned, and IPCerror is set.
  891. </errors>
  892. <seealso>
  893. <link id="shmget"/>
  894. <link id="shmat"/>
  895. <link id="shmctl"/>
  896. </seealso>
  897. </element>
  898. <element name="shmctl">
  899. <short>Perform control operations on a shared memory block.</short>
  900. <descr>
  901. <p>
  902. <var>shmctl</var> performs various operations on the shared memory block
  903. identified by identifier <var>shmid</var>.
  904. </p>
  905. <p>
  906. The <var>buf</var> parameter points to a <var>TSHMid_ds</var> record. The
  907. <var>cmd</var> parameter is used to pass which operation is to be performed.
  908. It can have one of the following values :
  909. </p>
  910. <dl>
  911. <dt>IPC_STAT</dt><dd> <var>shmctl</var> fills the <var>TSHMid_ds</var> record that
  912. <var>buf</var> points to with the available information about the shared memory
  913. block.</dd>
  914. <dt>IPC_SET</dt><dd> applies the values in the <var>ipc_perm</var> record that
  915. <var>buf</var> points to, to the shared memory block.</dd>
  916. <dt>IPC_RMID</dt><dd> the shared memory block is destroyed (after all processes
  917. to which the block is attached, have detached from it).</dd>
  918. </dl>
  919. <p>
  920. If successful, the function returns <var>True</var>, <var>False</var> otherwise.
  921. </p>
  922. </descr>
  923. <errors>
  924. If an error occurs, the function returns <var>False</var>, and <var>IPCerror</var>
  925. is set.
  926. </errors>
  927. <seealso>
  928. <link id="shmget"/>
  929. <link id="shmat"/>
  930. <link id="shmdt"/>
  931. </seealso>
  932. <example file="ipcex/shmtool"/>
  933. </element>
  934. </module>
  935. </package>
  936. </fpdoc-descriptions>