PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
dsm.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * dsm.h
4  * manage dynamic shared memory segments
5  *
6  * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
7  * Portions Copyright (c) 1994, Regents of the University of California
8  *
9  * src/include/storage/dsm.h
10  *
11  *-------------------------------------------------------------------------
12  */
13 #ifndef DSM_H
14 #define DSM_H
15 
16 #include "storage/dsm_impl.h"
17 
18 typedef struct dsm_segment dsm_segment;
19 
20 #define DSM_CREATE_NULL_IF_MAXSEGMENTS 0x0001
21 
22 /* A sentinel value for an invalid DSM handle. */
23 #define DSM_HANDLE_INVALID 0
24 
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);
31 
32 #ifdef EXEC_BACKEND
33 extern void dsm_set_control_handle(dsm_handle h);
34 #endif
35 
36 /* Functions that create, update, or remove mappings. */
37 extern dsm_segment *dsm_create(Size size, int flags);
39 extern void *dsm_resize(dsm_segment *seg, Size size);
40 extern void *dsm_remap(dsm_segment *seg);
41 extern void dsm_detach(dsm_segment *seg);
42 
43 /* Resource management functions. */
44 extern void dsm_pin_mapping(dsm_segment *seg);
45 extern void dsm_unpin_mapping(dsm_segment *seg);
46 extern void dsm_pin_segment(dsm_segment *seg);
47 extern void dsm_unpin_segment(dsm_handle h);
49 
50 /* Informational functions. */
51 extern void *dsm_segment_address(dsm_segment *seg);
54 
55 /* Cleanup hooks. */
57 extern void on_dsm_detach(dsm_segment *seg,
58  on_dsm_detach_callback function, Datum arg);
59 extern void cancel_on_dsm_detach(dsm_segment *seg,
60  on_dsm_detach_callback function, Datum arg);
61 extern void reset_on_dsm_detach(void);
62 
63 #endif /* DSM_H */
void dsm_detach_all(void)
Definition: dsm.c:666
void on_dsm_detach(dsm_segment *seg, on_dsm_detach_callback function, Datum arg)
Definition: dsm.c:1037
void dsm_detach(dsm_segment *seg)
Definition: dsm.c:726
void * dsm_remap(dsm_segment *seg)
Definition: dsm.c:708
uint32 dsm_handle
Definition: dsm_impl.h:55
void dsm_pin_segment(dsm_segment *seg)
Definition: dsm.c:867
void * dsm_segment_address(dsm_segment *seg)
Definition: dsm.c:1000
void(* on_dsm_detach_callback)(dsm_segment *, Datum arg)
Definition: dsm.h:56
void cancel_on_dsm_detach(dsm_segment *seg, on_dsm_detach_callback function, Datum arg)
Definition: dsm.c:1052
void dsm_unpin_segment(dsm_handle h)
Definition: dsm.c:899
void dsm_unpin_mapping(dsm_segment *seg)
Definition: dsm.c:846
Size dsm_segment_map_length(dsm_segment *seg)
Definition: dsm.c:1010
dsm_segment * dsm_attach(dsm_handle h)
Definition: dsm.c:561
uintptr_t Datum
Definition: postgres.h:372
dsm_segment * dsm_find_mapping(dsm_handle h)
Definition: dsm.c:981
void reset_on_dsm_detach(void)
Definition: dsm.c:1075
void dsm_pin_mapping(dsm_segment *seg)
Definition: dsm.c:827
void dsm_cleanup_using_control_segment(dsm_handle old_control_handle)
Definition: dsm.c:210
void dsm_postmaster_startup(struct PGShmemHeader *)
Definition: dsm.c:145
void * dsm_resize(dsm_segment *seg, Size size)
Definition: dsm.c:691
size_t Size
Definition: c.h:350
dsm_segment * dsm_create(Size size, int flags)
Definition: dsm.c:465
void * arg
void dsm_backend_shutdown(void)
Definition: dsm.c:648
dsm_handle dsm_segment_handle(dsm_segment *seg)
Definition: dsm.c:1028