source: trunk/MagicSoft/Cosy/incl/mbx.h@ 959

Last change on this file since 959 was 731, checked in by tbretz, 23 years ago
*** empty log message ***
File size: 2.3 KB
Line 
1/*-----------------------------------------------------------------------------
2mbx.h -- Synchronization of mailbox access
3
4Copyright (c) 1995 JANZ Computer AG
5All Rights Reserved
6
7Created 96/01/23 by Stefan Althoefer
8Version 1.4 of 96/07/26
9
10Two processes -- local and peer -- communicate via mailboxes.
11There are two mailboxes for each direction. Thus there are four
12mailboxes altogether referred to by indexes 0,1,2,3.
13
14To synchronize read-write access to the mailboxes two synchronization
15bytes are used. These bytes are located in shared memory readable by
16both processes. One byte is owned by the local process the other by
17the (remote) peer process. Only the owner of a synchronization byte
18may write it.
19
20There are two functions for the local process to manipulate the
21synchronization bytes: msync_get() and msync_unget().
22With msync_get(1) (resp. msync_get(0)) the local process requests a
23mailbox for writing (resp. reading). The index "index" of the next box
24ready for writing (resp. for reading) is returned. The value -1 is
25returned if there is no such box. After using the box the local process
26calls msync_unget(writing, index) making the box available to the peer.
27
28The functions are declared static. This file is meant to included in
29the file where reading and writing mailboxes is done.
30It is necessary to designate the send (write) direction as either
31up or down by #defining MSYNC_UP in the local process and MSYNC_DOWN
32in the peer process (or vice versa).
33The addresses of the synchronization bytes must be specified
34with MSYNC_LOCL_ADDR or MSYNC_PEER_ADDR.
35
36-----------------------------------------------------------------------------*/
37
38#ifndef mbx_DEFINED
39#define mbx_DEFINED
40
41#define far
42
43/* Function prototypes by default */
44#ifdef __STDC__
45#define _PARAMS(args) args
46#else
47#define _PARAMS(args) ()
48#endif
49
50/* Mailbox access macros */
51#define mbx_get(i) ((unsigned char *)(MBX_BASE+(i+1) * MBX_LENGTH))
52
53/* Values for parameter "writing" in msync_*() */
54#define MBX_WRITING 1
55#define MBX_READING 0
56
57#define MSYNC_SHIFT(w) ((w) ? 4 : 0)
58
59/* Address of local synchronization byte */
60#ifdef MSYNC_LOCL_ADDR
61#define MSYNC_LOCL (MSYNC_LOCL_ADDR)
62#endif
63
64/* Address of peer synchronization byte */
65#ifdef MSYNC_PEER_ADDR
66#define MSYNC_PEER (MSYNC_PEER_ADDR)
67#endif
68
69#endif /* mbx_DEFINED */
Note: See TracBrowser for help on using the repository browser.