Why use shm_open?

If you open and mmap() a regular file, data will end up in that file. If you just need to share a memory region, without the need to persist the data, which incurs extra I/O overhead, use shm_open(). Such a memory region would also allow you to store other kinds of objects such as mutexes … Read more

wait and notify in C/C++ shared memory

Instead of the Java object that you would use to wait/notify, you need two objects: a mutex and a condition variable. These are initialized with pthread_mutex_init and pthread_cond_init. Where you would have synchronized on the Java object, use pthread_mutex_lock and pthread_mutex_unlock (note that in C you have to pair these yourself manually). If you don’t … Read more

Delete all SYSTEM V shared memory and semaphores on UNIX-like systems

Here, save and try this script (kill_ipcs.sh) on your shell: #!/bin/bash ME=`whoami` IPCS_S=`ipcs -s | egrep “0x[0-9a-f]+ [0-9]+” | grep $ME | cut -f2 -d” “` IPCS_M=`ipcs -m | egrep “0x[0-9a-f]+ [0-9]+” | grep $ME | cut -f2 -d” “` IPCS_Q=`ipcs -q | egrep “0x[0-9a-f]+ [0-9]+” | grep $ME | cut -f2 -d” “` for … Read more

When/why use an MVar over a TVar

MVar can be empty used to implement synchronization patterns between threads allows one-way communication between threads can be faster than TVar in some cases TVar can not be empty atomic transactions “shared memory” between threads; can be used to implement, for example, a lookup cache from which multiple threads can read/write access is linear time … Read more

Use shared GPU memory with TensorFlow?

Shared memory is an area of the main system RAM reserved for graphics. References: https://en.wikipedia.org/wiki/Shared_graphics_memory https://www.makeuseof.com/tag/can-shared-graphics-finally-compete-with-a-dedicated-graphics-card/ This type of memory is what integrated graphics eg Intel HD series typically use. This is not on your NVIDIA GPU, and CUDA can’t use it. Tensorflow can’t use it when running on GPU because CUDA can’t use it, … Read more

Does using .reset() on a std::shared_ptr delete all instances

When you use .reset(), you are eliminating one owner of the pointer, but all of the other owners are still around. Here is an example: #include <memory> #include <cstdio> class Test { public: ~Test() { std::puts(“Test destroyed.”); } }; int main() { std::shared_ptr<Test> p = std::make_shared<Test>(); std::shared_ptr<Test> q = p; std::puts(“p.reset()…”); p.reset(); std::puts(“q.reset()…”); q.reset(); std::puts(“done”); … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)