• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1//////////////////////////////////////////////////////////////////////////////
2//
3// (C) Copyright Ion Gaztanaga. Distributed under the Boost
4// Software License, Version 1.0. (See accompanying file
5// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6//
7// See http://www.boost.org/libs/interprocess for documentation.
8//
9//////////////////////////////////////////////////////////////////////////////
10
11Remove std::iterator_traits and use pointer_traits
12
13What values should take shared memory allocators:
14
15propagate_on_container_copy_assignment
16propagate_on_container_move_assignment
17propagate_on_container_swap
18
19
20
21//////////////////////////////////////////////////////////////////////////////
22Platform conformance
23//////////////////////////////////////////////////////////////////////////////
24
25//////////
26FreeBSD
27//////////
28
29Tested until FreeBSD 9
30
31Shared memory: FreeBSD < 7 filesystem semantics
32
33   HISTORY
34        The shm_open() and shm_unlink() functions first appeared in FreeBSD 4.3.
35        The functions were reimplemented as system calls using shared memory
36        objects directly rather than files in FreeBSD 7.0.
37
38   BUG: MAP_PRIVATE requires read-write access to shared memory object (mapped files work fine)
39
40Named semaphore: _POSIX_SEMAPHORES not defined. Limited named semaphore support (short names)
41Process shared: _POSIX_THREAD_PROCESS_SHARED not defined
42
43//////////
44Linux 2.6
45//////////
46
47All Fine
48
49
50
51
52
53
54-> add contiguous_elements option to burst allocation
55
56-> Test construct<> with throwing constructors
57
58-> Implement zero_memory flag for allocation_command
59
60-> The general allocation funtion can be improved with some fixed size allocation bins.
61
62-> Adapt error reporting to TR1 system exceptions
63
64-> Improve exception messages
65
66-> Movability of containers should depend on the no-throw guarantee of allocators copy constructor
67
68-> Check self-assignment for vectors
69
70-> Update writing a new memory allocator explaining new functions (like alignment)
71
72-> private node allocators could take the number of nodes as a runtime parameter.
73
74-> Explain how to build intrusive indexes.
75
76-> Add intrusive index types as available indexes.
77
78-> Add maximum alignment allocation limit in PageSize bytes. Otherwise, we can't
79   guarantee alignment for process-shared allocations.
80
81-> Add default algorithm and index types. The user does not need to know how are
82   they implemented.
83
84-> Pass max size check in allocation to node pools
85
86-> Use in-place expansion capabilities to shrink_to_fit and reserve functions
87   from iunordered_index.
88
89-> change unique_ptr to avoid using compressed_pair
90
91-> Improve unique_ptr test to test move assignment and other goodies like assigment from null
92
93-> barrier_test fails on MacOS X on PowerPC.
94
95-> use virtual functions to minimize template explosion in managed classes
96
97-> Insertions with InpIt are not tested in containers
98
99-> Run tests with rvalue reference compilers with no variadic insertions
100
101-> find a way to pass security attributes to shared memory
102
103-> Implement vector with memcpy/memmove for trivially copyable types.
104
105-> flat_xxx constructors are not documented
106
107-> operator >> and similar need moved_value
108
109-> rvalue reference enabled compilers are not optimized with has_move_emulation_enabled and move_iterator
110
111-> Add allocator test template that test all new functions (allocate_many, etc.)
112
113-> MacOS shm_open is non-conformant. Is there a way to know the size of a shared memory object?
114
115-> swap() of multiallocaiton iterator is wrong. Try to reimplement it with slist
116
117-> Could the mapped_file constructor allow a wchar_t filename on Windows?
118 Or some cross-platform way to get Unicode support?
119
120-> map::node_ptr p = m.create_node(my_special_cheap_key_value, mv1, mv2);
121//We would need to unconst-cast...
122const_cast<Key&>(p->first) = modify( p->second );
123m.insert( boost::move(p) );
124
125->  I found some bug in the interprocess library. I use
126 boost::interprocess::managed_mapped_file class and
127 managed_mapped_file::shrink_to_fit() method to decrease the size of file
128 on the disk. It works good but the thread hang up on shrink_to_fit() call
129 if the file exists already and it's size is zero. It makes me check the
130 file existance and it's size before shrink_to_fit() call.
131 Thank you!
132
133-> Ticket URL: <https://svn.boost.org/trac/boost/ticket/3375>
134
135->Robust mutex emulation:
136
137Two new fields:
138 - owner
139 - state
140
141Use intermodule singleton to store the lock file name
142
143LOCK
144  if (broken_id){
145    throw exception;
146  }
147
148  lock_own_unique_file();
149
150  while(1){
151    if (try_lock_mtx){
152      write unique_id
153    }
154    else{
155      sleep();
156      ++tries;
157      if(tries > 100)
158        if(!robust_check()){
159          tries = 0;
160        }
161        else{
162          break;
163        }
164      }
165    }
166  }
167
168
169UNLOCK
170  if (fixing_mode){
171    write_broken_id
172  }
173  else{
174    write invalid_id
175  }
176
177  unlock_mtx
178
179ROBUST_CHECK
180
181  if(check_if_owner_dead_and_take_ownership_atomically()){
182    return false;
183  }
184  write fixing_id
185
186CHECK_IF_OWNER_DEAD_AND_TAKE_OWNERSHIP_ATOMICALLY
187
188   do{
189      old_owner = read_owner_atomically()
190      if(check_owner_unique_resource_is_dead(old_owner){
191         return true;
192      }
193   }while(cas(old_owner, cur_owner) == old_owner);
194   return false;
195
196CHECK_OWNER_UNIQUE_RESOURCE_IS_DEAD(owner)
197
198   file = file_to_owner(owner);
199   if(file_exists(file)){
200      if(try_lock(file)){
201         write_owner_atomically();
202         remove(file);
203         unlock(file)
204         return true;
205      }
206   }
207   return false;
208
209
210LOCK_OWN_UNIQUE_FILE
211class MyRobustMutexLockFile
212{
213   int fd;
214};
215
216MyRobustMutexLockFile()
217{
218   //loop create_and_lock because another process
219   //can lock and erase it
220
221   //better create, lock and rename?
222   fd = create_file(lockfilename);
223   while(1){
224      lock_file(fd);
225      int fd2 = create_exclusive(lockfilename);
226      if(fd2){
227         close(fd);
228         fd = fd2;
229         continue;
230      }
231      else if(already_exist_error){ //must already exist
232         break;
233      }
234      else{
235         close(fd);
236         throw exception;
237      }
238   }
239}
240
241~MyRobustMutexLockFile()
242{
243   close(fd);
244   //No race condition because
245   //if any other thread tries to create the file
246   //the shm has a lock so constructor/destructor is serialized
247   unlink(lockfilename)
248}
249
250ipcdetail::intermodule_singleton<MyRobustMutexLockFile>::get();
251
252Add unsigned overflow checking with shortcut as explained here:
253
254https://github.com/ivmai/bdwgc/commit/83231d0ab5ed60015797c3d1ad9056295ac3b2bb
255
256# define GC_SIZE_MAX (~(size_t)0)
257 #endif
258+#define GC_SQRT_SIZE_MAX ((1U << (WORDSZ / 2)) - 1)
259+
260void * calloc(size_t n, size_t lb)
261{
262-    if (lb && n > GC_SIZE_MAX / lb)
263+    if ((lb | n) > GC_SQRT_SIZE_MAX /* fast initial test */
264+        && lb && n > GC_SIZE_MAX / lb)
265       return NULL;
266