Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

shmem.hh

Go to the documentation of this file.
00001 /*************************************************************************
00002 * File: shmem.hh                                                         *
00003 * Authors: Fred Proctor, Will Shackleford                                *
00004 * Purpose: C++ Header file for the Communication Management System (CMS).*
00005 *          Includes:                                                     *
00006 *                    1. class SHMEM.                                     *
00007 * Notes: The class SHMEM should be used by procedures accessing a shared *
00008 *  memory buffer on the same processor.                                  *
00009 *************************************************************************/
00010 
00011 #ifndef SHMEM_HH
00012 #define SHMEM_HH
00013 
00014 /* Include Files */
00015 #include "rcs_defs.hh"          /* EXTERN_C_STD_HEADERS  */
00016 
00017 #ifdef EXTERN_C_STD_HEADERS
00018 extern "C"
00019 {
00020 #endif
00021 
00022 #ifndef UNDER_CE
00023 #include <stdio.h>              /* NULL */
00024 #include <stddef.h>             /* size_t */
00025 #endif
00026 
00027 #ifndef _WINDOWS
00028 #include <sys/types.h>          /* key_t */
00029 #endif
00030 
00031 #ifdef EXTERN_C_STD_HEADERS
00032 }
00033 #endif
00034 
00035 #ifndef KEY_T_DEFINED
00036 
00037 #ifdef VXWORKS
00038 typedef int key_t;              /* key_t is not defined in VxWorks or  Windows -- do
00039                                    it here, and it should be visible
00040                                    throughout all the shared mem code */
00041 #endif
00042 
00043 #ifdef WIN32
00044 typedef long key_t;
00045 #endif
00046 
00047 #endif
00048 
00049 
00050 #include "cms.hh"               /* class CMS */
00051 #include "shm.hh"               /* class RCS_SHAREDMEM */
00052 #include "memsem.hh"            /* struct mem_access_object */
00053 // #include "sem.hh"            /* class RCS_SEMAPHORE */
00054 
00055 /* Class Definitions */
00056 
00057 class SHMEM:public CMS
00058 {
00059 public:
00060   SHMEM (char *name, long size, int neutral, key_t key, int m = 0);
00061     SHMEM (char *bufline, char *procline, int set_to_server = 0,
00062            int set_to_master = 0);
00063     virtual ~ SHMEM ();
00064 
00065   CMS_STATUS main_access (void *_local);
00066 
00067 private:
00068 
00069   /* data buffer stuff */
00070   int fast_mode;
00071 #ifdef VXWORKS
00072   virtual CMS_STATUS read ();   /* Read from  buffer. */
00073   virtual CMS_STATUS peek ();   /* Read without setting flag. */
00074   virtual CMS_STATUS write (void *user_data);   /* Write to buffer. */
00075   virtual CMS_STATUS write_if_read (void *user_data);   /* Write to buffer. */
00076 #endif
00077   int open ();                  /* get shared mem and sem */
00078   int close ();                 /* detach from shared mem and sem */
00079   key_t key;                    /* key for shared mem and sem */
00080   key_t bsem_key;               // key for blocking semaphore
00081   int second_read;              // true only if the first read returned no new data
00082   RCS_SHAREDMEM *shm;           /* shared memory */
00083   RCS_SEMAPHORE *sem;           /* semaphore */
00084   int master;                   /* Is this process responsible for */
00085   /* clearing memory & semaphores? */
00086   double sem_delay;             /* Time to wait between polling the semaphore. */
00087   struct mem_access_object mao; /* passed to mem_get_access()  */
00088   enum SHMEM_MUTEX_TYPE
00089   {
00090     NO_MUTEX,
00091     MAO_MUTEX,
00092     MAO_MUTEX_W_OS_SEM,
00093     OS_SEM_MUTEX,
00094     NO_INTERRUPTS_MUTEX,
00095     NO_SWITCHING_MUTEX
00096   };
00097 
00098   int use_os_sem;
00099   int use_os_sem_only;
00100 
00101   SHMEM_MUTEX_TYPE mutex_type;
00102   void *shm_addr_offset;
00103 
00104 #ifdef WIN32
00105   HANDLE bsem;
00106 #else
00107   RCS_SEMAPHORE *bsem;          // blocking semaphore
00108 #endif
00109   int autokey_table_size;
00110 
00111 };
00112 
00113 #endif /* !SHMEM_HH */

Generated on Sun Dec 2 15:56:52 2001 for rcslib by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001