blob: 619a248c3d674bc350482e68e40f7fbc1c6f0223 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
/********************************************************************
* Description: shmem.hh
* C++ file for the Communication Management System (CMS).
* Includes member Functions for class SHMEM.
* Notes: The class SHMEM should be used by procedures accessing a
* shared memory buffer on the same processor.
*
* Derived from a work by Fred Proctor & Will Shackleford
*
* Author:
* License: GPL Version 2
* System: Linux
*
* Copyright (c) 2004 All rights reserved.
*
* Last change:
********************************************************************/
#ifndef SHMEM_HH
#define SHMEM_HH
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h> /* NULL */
#include <stddef.h> /* size_t */
#include <sys/types.h> /* key_t */
#ifdef __cplusplus
}
#endif
#include "cms.hh" /* class CMS */
#include "shm.hh" /* class RCS_SHAREDMEM */
#include "memsem.hh" /* struct mem_access_object */
class SHMEM:public CMS {
public:
SHMEM(const char *name, long size, int neutral, key_t key, int m = 0);
SHMEM(const char *bufline, const char *procline, int set_to_server = 0,
int set_to_master = 0);
virtual ~ SHMEM();
CMS_STATUS main_access(void *_local);
private:
/* data buffer stuff */
int fast_mode;
int open(); /* get shared mem and sem */
int close(); /* detach from shared mem and sem */
key_t key; /* key for shared mem and sem */
key_t bsem_key; // key for blocking semaphore
int second_read; // true only if the first read returned no
// new data
RCS_SHAREDMEM *shm; /* shared memory */
RCS_SEMAPHORE *sem; /* semaphore */
int master; /* Is this process responsible for */
/* clearing memory & semaphores? */
double sem_delay; /* Time to wait between polling the
semaphore. */
struct mem_access_object mao; /* passed to mem_get_access() */
enum SHMEM_MUTEX_TYPE {
NO_MUTEX,
MAO_MUTEX,
MAO_MUTEX_W_OS_SEM,
OS_SEM_MUTEX,
NO_INTERRUPTS_MUTEX,
NO_SWITCHING_MUTEX
};
int use_os_sem;
int use_os_sem_only;
SHMEM_MUTEX_TYPE mutex_type;
void *shm_addr_offset;
RCS_SEMAPHORE *bsem; // blocking semaphore
int autokey_table_size;
};
#endif /* !SHMEM_HH */
|