•  Back 
  •  MiNT 
  •  Index 
  •  Tree View 
  •  Cross references 
  •  %About 
  •  Show info about hypertext 
  •  View a new file 
Topic       : The ATARI Compendium
Author      : Scott Sanders / JAY Software
Version     : 1.25 (20/6/2003)
Subject     : Documentation
Nodes       : 1117
Index Size  : 32614
HCP-Version : 6
Compiled on : Atari
@charset    : UTF-8
@lang       : en
@default    : 
@help       : %About
@options    : +g -i -t4 +y +z
@width      : 100
View Ref-File
                     MiNT  Interprocess Communication


Pipelines

A pipeline is a special file used for data communication in which the
data being read or written is kept in memory. Pipes are created by
Fcreate()'ing a file in the special directory 'U:\PIPE'. A process which
initially opens a pipe is considered the 'server.' Processes writing to or
reading from the open pipe are called 'clients.' Both servers and clients
may read to and write from the pipe.

Fcreate()'s attr byte takes on a special meaning with pipes as follows:

Name         Bit   Meaning

FA_UNIDIR    0x01  If this bit is set, the pipe will be unidirectional
                   (the server can only write, the client can only read).

FA_SOFTPIPE  0x02  Setting this bit causes reads when no one is writing to
                   return EOF and writes when no one is reading to raise
                   the signal SIGPIPE.

FA_TTY       0x04  Setting this bit will make the pipe a pseudo-TTY, i.e.
                   any characters written by the server will be
                   interpreted (ctrl-c will cause a SIGINT signal to be
                   generated to all clients).

Fpipe() can also be used to create pipes quickly with the MiNT kernel
resolving any name conflicts. A pipe is deleted when all processes that
had obtained a handle to it Fclose() it.

A single process may serve as both the client and the server if it
maintains two handles (one obtained from Fopen() and one from Fcreate() ).
In addition, child processes of the server may inherit the file handle,
and thus the server end of the pipe.

A special system call, Salert(), sends a string to a pipe called
'U:\PIPE\ALERT'. If a handler is present that reads from this pipe, an
alert with the text string will be displayed.

Signals

Signals are messages sent to a process that interrupt normal program flow
in a way that may be defined by the receiving application. Signals are
sent to a process with the function Pkill().  The call is named Pkill()
because the default action for most signals is the termination of the
process. If a process expects to receive signals it should use Psignal(),
Psigsetmask(), Psigblock(), or Psigaction() to modify that behavior by
installing a handler routine, ignoring the signal, or blocking the signal
completely.

Signal handlers should return by executing a 680x0 RTS instruction or by
calling Psigreturn(). Current signals sent and recognized by MiNT processes
are here.


Memory Sharing

With the enforcement of memory protection under MultiTOS, the availability
of shared memory blocks is important for applications wishing to share
blocks of memory. A shared memory block is opened by Fcreate()'ing a file
in the directory 'U:\SHM'. After that, a memory block allocated with
Malloc() or Mxalloc() may be attached to the file with Fcntl(handle,
memptr, SHMSETBLK).

Any process which uses Fopen() and Fcntl() with a parameter of SHMGETBLK
can now read that memory as if it were a disk file. After a process
obtains the address of a shared memory block with SHMGETBLK the memory is
guaranteed to be valid until it calls Mfree() on that block even if it
Fclose()'s the original file handle.

Note that the address returned by Fcntl() may be different in different
processes. Because of this, data in shared memory blocks should not
contain absolute pointers.

When a process is finished with a shared memory block, it should Mfree()
the address returned by the Fcntl() call. A shared memory block is also
deleted by the Fdelete() call if the file is currently unopened by any
other processes.

Other Methods of Communication

Psemaphore() can be used to create named flags which can synchronize the
behavior of multiple applications (if adhered to). Pmsg() is used to send
simple messages between two processes.