• No se han encontrado resultados

3. SOMALILANDIA: UN OBSTÁCULO PARA LA UNIDAD ÁRABE

3.1. IDENTIDAD SOMALILANDESA VS IDENTIDAD ÁRABE

3.1.1. Deseo de la Liga Árabe de reducir el control extranjero

Access to ARCOM shared memory interfaces is encapsulated into theAShMemInterfaceclass and its subclasses (figure 8.9). AShMemInterface encapsulates all functionality common to both read (AProcShMemInterface) and write (ARecShMemInterface) access to the interface.

AShMemInterfaceis itself a valid class (as opposed to an abstract base class – ABC) and can be instantiated directly if neither read nor write access is desired, e.g. for diagnostic purposes, aka ‘spy mode.’ In this case, only the state transitions on the left side of the diagram in figure 8.10 are possible. As it is being used by an ARCOM component to access an ARCOM shared memory

CHAPTER 8. ADVANCED RIOMETER COMPONENTS: ARCOM 162

Figure 8.9:AShMemInterfaceclass hierarchy including the major class attributes and methods of interest to users of shared memory interfaces.

invalid connected master client connect(name) create(name,size) disconnect() unlink(name) ARecShMemInterface::attach() AProcShMemInterface::attach() AProcShMemInterface::detach() ARecShMemInterface::detach() dump() connect(name) create(name,size) disconnect() unlink(name) ARecShMemInterface::attach() ARecShMemInterface::detach() dump() AProcShMemInterface::attach() AProcShMemInterface::detach()

in figure 8.10.

Internally, each shared memory interface consists of a block of shared memory organised as a ring buffer. A separate control block maintains head and tail positions for each connected master and client. TheAShMemInterfaceclass and its descendants encapsulate access to memory and control block and sequentialise access in order to keep both blocks in a consistent state at all times.

Both clients and masters attach and detach to/from a shared memory interface using the

attach()anddetach()methods. They then request and relinquish permission to access a block of memory within the ring buffer of the shared memory interface by callingopenBuffer()and

closeBuffer(). This is roughly analogous to ‘normal’ file input/output operations. The success or failure ofopenBuffer()also depends on the operating ‘mode’ that has been specified for the interface in question. In ‘blocking’ mode, the call toopenBuffer()blocks until the requested amount of memory becomes available. In ‘gentle’ mode, an AExWouldBlock exception is thrown. For master access, a third mode option exists: in ‘force’ mode, a block of memory is forced open, and any clashing clients are forcibly disconnected. This ensures that high-priority masters (for example an A9812Recordercomponent recording data from an A/D converter) will never have to wait for slow clients further down the pipeline. This mode is invalid for client access, as one cannot ‘force’ data to appear out of thin air.

Figure 8.11 shows some example transactions reading and writing data from/to an example shared memory interface object ‘DemoShMem.’ The individual plots were generated by call- ing theSVGdump()diagnostic function of theAShMemInterfaceinstance for the interface in question, resulting in an SVG (Scalable Vector Graphics) format file depicting graphically the current internal state of the shared memory interface. The example itself was generated using the command line tools intools/shmemplayground/to manually create, read from, write to, spy on, etc. ARCOM shared memory interfaces. These tools are described in section 8.9.4 below.

The following is a description of the individual panels in figure 8.11, representing specific successive moments in time. This description will serve to explain the data flow and internal data structures working ‘behind the scenes’ inside an ARCOMAShMemInterface.

CHAPTER 8. ADVANCED RIOMETER COMPONENTS: ARCOM 164

t=0

t=1 t=4

t=2 t=5

t=3 t=6

Figure 8.11: An ARCOM shared memory interface in use. Tall (green) arrows indicate head pointer position, short (black) arrows indicate tail pointer positions. For further description see section 8.4.

The interface has been created but no clients or masters are yet connected, indicated by the square brackets around all client and master slots. Note that there seems to be one master connected already (master 2). This is the ‘ghost-master’ that is always present and whose role in maintaining a consistent dataset will become clear towards the end of this discussion. Head and tail of the ‘ghost-master’ point at the same location, indicating an empty interface.

t=1

A master has connected to the interface. This master has written a block of five ‘X’ bytes to the interface. Note how head and tail for both the real master (slot 0) and the ‘ghost-master’ (slot 2) are incremented.

t=2

A client has connected but not yet read any data. Newly connected clients automatically start off at the ghost-master’s head position, i.e. they will not see any data that is still in the process of being written by a master at the time they connect.

t=3

A second master (master 1) has connected and opened a block of four bytes for output to the interface. No data has been written yet. The first master (master 0) has then also requested to write a block of 6 bytes by callingopenBuffer(6). Both buffers are still open, indicated by the lagging tail pointers for the masters. Note how all master head pointers point at the next free position in the ring buffer.

t=4

Master 0 has finished writing to its data block and calledcloseBuffer(): head and tail point at the same location. Master 1 is still writing data to its part of the ring buffer. Another client has connected (Client 1) but cannot yet read any data.

t=5

Master 1 has finished writing to its data block. Both masters have disconnected (indicated by the square brackets around the master slots). Note that the ‘ghost-master’ still exists, ensuring

CHAPTER 8. ADVANCED RIOMETER COMPONENTS: ARCOM 166

that client heads and tails are kept in a consistent state and all clients can read all the remaining data, even when no (external) master is connected to the interface. In fact, client 0 is in the process of reading a block of four bytes. Client 1 still cannot read any data because no masters are connected that would be capable of supplying new data.

t=6

Both clients have disconnected. The interface is empty again. Client head and tail pointers show the last status just before the detach(). They will be re-initialised to the ghost-master’s head position when a new client connects.

Documento similar