00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef SHMEM_HH
00012 #define SHMEM_HH
00013
00014
00015 #include "rcs_defs.hh"
00016
00017 #ifdef EXTERN_C_STD_HEADERS
00018 extern "C"
00019 {
00020 #endif
00021
00022 #ifndef UNDER_CE
00023 #include <stdio.h>
00024 #include <stddef.h>
00025 #endif
00026
00027 #ifndef _WINDOWS
00028 #include <sys/types.h>
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;
00039
00040
00041 #endif
00042
00043 #ifdef WIN32
00044 typedef long key_t;
00045 #endif
00046
00047 #endif
00048
00049
00050 #include "cms.hh"
00051 #include "shm.hh"
00052 #include "memsem.hh"
00053
00054
00055
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
00070 int fast_mode;
00071 #ifdef VXWORKS
00072 virtual CMS_STATUS read ();
00073 virtual CMS_STATUS peek ();
00074 virtual CMS_STATUS write (void *user_data);
00075 virtual CMS_STATUS write_if_read (void *user_data);
00076 #endif
00077 int open ();
00078 int close ();
00079 key_t key;
00080 key_t bsem_key;
00081 int second_read;
00082 RCS_SHAREDMEM *shm;
00083 RCS_SEMAPHORE *sem;
00084 int master;
00085
00086 double sem_delay;
00087 struct mem_access_object mao;
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;
00108 #endif
00109 int autokey_table_size;
00110
00111 };
00112
00113 #endif