1 /*-------------------------------------------------------------------------
4 * manage dynamic shared memory segments
6 * Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
9 * src/include/storage/dsm.h
11 *-------------------------------------------------------------------------
16 #include "storage/dsm_impl.h"
18 typedef struct dsm_segment dsm_segment
;
20 #define DSM_CREATE_NULL_IF_MAXSEGMENTS 0x0001
22 /* A sentinel value for an invalid DSM handle. */
23 #define DSM_HANDLE_INVALID 0
25 /* Startup and shutdown functions. */
26 struct PGShmemHeader
; /* avoid including pg_shmem.h */
27 extern void dsm_cleanup_using_control_segment(dsm_handle old_control_handle
);
28 extern void dsm_postmaster_startup(struct PGShmemHeader
*);
29 extern void dsm_backend_shutdown(void);
30 extern void dsm_detach_all(void);
32 extern size_t dsm_estimate_size(void);
33 extern void dsm_shmem_init(void);
36 extern void dsm_set_control_handle(dsm_handle h
);
39 /* Functions that create or remove mappings. */
40 extern dsm_segment
*dsm_create(Size size
, int flags
);
41 extern dsm_segment
*dsm_attach(dsm_handle h
);
42 extern void dsm_detach(dsm_segment
*seg
);
44 /* Resource management functions. */
45 extern void dsm_pin_mapping(dsm_segment
*seg
);
46 extern void dsm_unpin_mapping(dsm_segment
*seg
);
47 extern void dsm_pin_segment(dsm_segment
*seg
);
48 extern void dsm_unpin_segment(dsm_handle h
);
49 extern dsm_segment
*dsm_find_mapping(dsm_handle h
);
51 /* Informational functions. */
52 extern void *dsm_segment_address(dsm_segment
*seg
);
53 extern Size
dsm_segment_map_length(dsm_segment
*seg
);
54 extern dsm_handle
dsm_segment_handle(dsm_segment
*seg
);
57 typedef void (*on_dsm_detach_callback
) (dsm_segment
*, Datum arg
);
58 extern void on_dsm_detach(dsm_segment
*seg
,
59 on_dsm_detach_callback function
, Datum arg
);
60 extern void cancel_on_dsm_detach(dsm_segment
*seg
,
61 on_dsm_detach_callback function
, Datum arg
);
62 extern void reset_on_dsm_detach(void);