Specification of package Tgx.Shared_Memory







 ========================================================================= --
 ===                                                                   === --
 ===                 Top Graph'X CORBA Implementation                  === --
 ===                                                                   === --
 ===                 Copyright (c) 1996, Top Graph'X.                  === --
 ===                                                                   === --
 ===                     --- Copyright Notice ---                      === --
 ===                                                                   === --
 ===    This software is protected as an unpublished work under the    === --
 ===     Copyright Act of 1976.  All rights reserved.  Top Graph'X.    === --
 ===                                                                   === --
 ========================================================================= -- ;

with System ;
with Tgx.System_Ios ;
package Tgx.Shared_Memory is

   ##########################################################################
    A global shared memory segment will contain the description of all the
    client and services (address book) and their associated mailboxes.
    
   ##########################################################################

   Shared_Memory_Error : exception ;

   subtype Server_Name is Standard.String (1 .. 3) ;

   type String_Pointer is access all String ;

    Message Box Types

   type Channel_Id is mod 2 ** 16 ;
   for Channel_Id'Size use 16 ;

   type Message_Index is mod 2 ** 16 ;
   for Message_Index'Size use 16 ;

   type Waiter_Index is mod 2 ** 16 ;
   for Waiter_Index'Size use 16 ;

   Max_Per_Box : constant := 252 ;
   type Message_Array is array
      (Message_Index range 1 .. Max_Per_Box) of Natural ;

   type Process_Id is mod 2 ** 32 ;
   type Signal_Type is mod 2 ** 16 ;
    Description in shared memory
   type Channel_Type is
   record
      Id          : Channel_Id ;
      Num         : Message_Index ;
      First       : Message_Index ;
      Last        : Message_Index ;
      Signal      : Signal_Type ;
      Full        : Boolean ;
      Pid1        : Process_Id ;
      Pid2        : Process_Id ;
      Name        : Standard.String (1 .. 4) ;
      Messages    : Message_Array ;
   end record ;

   for Channel_Type use
   record
      Id          at 0 range   0 ..  15 ;
      Num         at 0 range  16 ..  31 ;
      First       at 0 range  32 ..  47 ;
      Last        at 0 range  48 ..  63 ;
      Signal      at 0 range  64 ..  79 ;
      Full        at 0 range  80 ..  87 ;
      Pid1        at 0 range  96 .. 127 ;
      Pid2        at 0 range 128 .. 159 ;
      Name        at 0 range 160 .. 191 ;
      Messages    at 0 range 192 .. 191 + Max_Per_Box * 32 ;
   end record ;

   Max_Channels : constant := 30 ;
   type Channel_Array_Type is array (Channel_Id range 1 .. Max_Channels) of Channel_Type ;
   type Channel_Array_Ptr is access all Channel_Array_Type ;

    Message data store type
   Max_Message_Area_Size : constant := 5 * 1024 * 1024 ;
   type Message_Area is array (1 .. Max_Message_Area_Size) of Tgx.System_Ios.Byte ;
   type Message_Area_Ptr is access all Message_Area ;

   Max_Message_Size : constant := Max_Message_Area_Size / 8 ;

    Header of the global memory segment
   type Memory_Header is
   record
      Used         : Channel_Id ;  Number of Channel_Ids in use
      Max_Channels : Channel_Id ;  Max number of channels
      Num_Waiters  : Waiter_Index ;  Num of waiters for room in message area
      Max_Data     : Natural ;  Size of message area
      Channels     : Natural ;  Offset in memory
      Low_Mark     : Natural ;  Amount of free memory when to release waiters
      Messages     : Natural ;  Offset in memory
      Next         : Natural ;  Offset in memory of the next message to store
   end record ;
   for Memory_Header use 
   record
      Used         at 0 range   0 ..  15 ;
      Max_Channels at 0 range  16 ..  31 ;
      Num_Waiters  at 0 range  32 ..  47 ;
      Max_Data     at 0 range  64 ..  95 ;
      Channels     at 0 range  96 .. 127 ;
      Low_Mark     at 0 range 128 .. 159 ;
      Messages     at 0 range 160 .. 191 ;
      Next         at 0 range 192 .. 223 ;
   end record ;
   type Memory_Header_Ptr is access all Memory_Header ;


   use type Tgx.System_Ios.Integer_32 ;

   type Semaphore_Set is range - 2 ** 31 .. 2 ** 31 - 1 ;


   type Memory_Id is range - 2 ** 31 .. 2 ** 31 - 1 ;


    Description of the shared memory segment
    The Guard is the set of semaphores for all channels
   type Description_Type is
   record
      Mem         : Memory_Id ;
      Addr        : System.Address := System.Null_Address ;
      Header      : Memory_Header_Ptr ;
      Channels    : Channel_Array_Ptr ;
      Messages    : System.Address ;
      Guard       : Semaphore_Set ;
      Flow        : Semaphore_Set ;
   end record ;

    Shared memory segment description used by clients and servers
   type Description is access all Description_Type ;

    Create a connection server channel
   procedure Create_Server ( Path    : in String ;
                             Name    : in Server_Name ;
                             Area    : out Description ;
                             Server  : out Channel_Id) ;

    Close a connection server channel
   procedure Close_Server ( Area    : in Description ;
                            Server  : in out Channel_Id) ;

    Establish connection with the given server
   procedure Connect ( Path    : in String ;
                       Name    : in Server_Name ;
                       Area    : in out Description ;
                       Server  : in out Channel_Id ;
                       Read    : out Channel_Id ;
                       Write   : out Channel_Id) ;

    Wait for input on the given channel
   procedure Wait ( Area    : in Description ;
                    Channel : in Channel_Id) ;

    Read given amount of input on the given channel
   procedure Read ( Area    : in Description ;
                    Channel : in Channel_Id ;
                    Buffer  : in System.Address ;
                    Number  : in out Natural) ;

    Write given amount of output on the given channel
   procedure Write ( Area    : in Description ;
                     Channel : in Channel_Id ;
                     Buffer  : in System.Address ;
                     Number  : in Natural) ;

   function Readable ( Area    : in Description ;
                       Channel : in Channel_Id ) return Natural ;

    End of communication
   procedure Disconnect (Area    : in Description ;
                         Read    : in out Channel_Id ;
                         Write   : in out Channel_Id) ;

end Tgx.Shared_Memory ;



List of definition uses










This page was generated by PrismTech's ada2html on Friday Mai 12 2006 16:18