mutex

android NDK mutex locking

被刻印的时光 ゝ 提交于 2020-01-22 23:07:56
问题 I've been porting a cross platform C++ engine to Android, and noticed that it will inexplicably (and inconsistently) block when calling pthread_mutex_lock . This engine has already been working for many years on several platforms, and the problematic code hasn't changed in years, so I doubt it's a deadlock or otherwise buggy code. It must be my port to Android.. So far there are several places in the code that block on pthread_mutex_lock. It isn't entirely reproducible either. When it hangs,

Start Application only once (Mono)

蓝咒 提交于 2020-01-17 01:43:11
问题 I'm currently developing an mono application in c#, which I would like to start only once. I know, this can be achieved with mutex. But how can I bring the application to front using mono? I tried getting the Process via Process.GetProcessByName("AudioCuesheetEditor") but couldn't access the MainWindowHandle. How can I bring the running application to front? Thanks for you answers. EDIT: Now I have been able to get the MainWindowHandle, but it's a IntPtr. How do I bring this handle to front?

GLSL per-pixel spinlock using imageAtomicCompSwap

£可爱£侵袭症+ 提交于 2020-01-16 16:01:33
问题 OpenGL red book version 9 (OpenGL 4.5) example 11.13 is Simple Per-Pixel Mutex . It uses imageAtomicCompSwap in a do {} while() loop to take a per-pixel lock to prevent simultaneous access to a shared resouce between pixel shader invocations corresponding to the same pixel coordinate. layout (binding = 0, r32ui) uniform volatile coherent uimage2D lock_image; void main(void) { ivec2 pos = ivec2(gl_FragCoord.xy); // spinlock - acquire uint lock_available; do { lock_available =

shared memory mutex with struct pointers

强颜欢笑 提交于 2020-01-16 08:43:33
问题 Im looking for some feedback on if I am doing the following properly. Im working on porting some windows real time code that had heavy use of named mutex's. It took some searching but i came across some stuff saying you can use shared memory as mutexes in linux, using shm open. I cant include all of the code here, but i put together the key areas that i need some feed back on. My questions are if im setting up the shared memory region, and mutex correctly, and also if my pointers will be set

shared memory mutex with struct pointers

社会主义新天地 提交于 2020-01-16 08:43:08
问题 Im looking for some feedback on if I am doing the following properly. Im working on porting some windows real time code that had heavy use of named mutex's. It took some searching but i came across some stuff saying you can use shared memory as mutexes in linux, using shm open. I cant include all of the code here, but i put together the key areas that i need some feed back on. My questions are if im setting up the shared memory region, and mutex correctly, and also if my pointers will be set

Automatically release mutex on crashes in Unix

末鹿安然 提交于 2020-01-15 04:25:07
问题 I have two programs interacting via a shared memory segment. When using the segment for read or write, they hold a lock. Should either of them crash (get killed, typically - possibly with something untrappable) in a critical section, I would like them to release the lock so that the shmem isn't locked out completely. Other questions point the way to the answer in Windows, Java, etc. but how do you do it in Unix (and specifically Linux)? (I'm not attached to the pthreads mutex functions; SysV

Automatically release mutex on crashes in Unix

a 夏天 提交于 2020-01-15 04:24:26
问题 I have two programs interacting via a shared memory segment. When using the segment for read or write, they hold a lock. Should either of them crash (get killed, typically - possibly with something untrappable) in a critical section, I would like them to release the lock so that the shmem isn't locked out completely. Other questions point the way to the answer in Windows, Java, etc. but how do you do it in Unix (and specifically Linux)? (I'm not attached to the pthreads mutex functions; SysV

Attemption to create thread safe std::map

≡放荡痞女 提交于 2020-01-14 03:22:27
问题 Suppose that we have std::map container and we want to make it thread safe in terms of insert, erase, search and edit records. At the same time we want the threads can work with different records in parallel (read and edit records). To do this, I made a separate class for record - edit operation, which protected with mutex. class Data { public: Data(const std::string& data) : _mutex(), _data(data) { } void setData(const std::string& data) { std::lock_guard<std::mutex> locker(_mutex); _data =

Can mutex implementations be interchanged (independently of the thread implementation)

天大地大妈咪最大 提交于 2020-01-13 09:43:33
问题 Do all mutex implementations ultimately call the same basic system/hardware calls - meaning that they can be interchanged? Specifically, if I'm using __gnu_parallel algorithms (that uses openmp ) and I want to make the classes they call threadsafe may I use boost::mutex for the locking? or must I write my own mutex such as the one described here //An openmp mutex. Can this be replaced with boost::mutex? class Mutex { public: Mutex() { omp_init_lock(&_mutex); } ~Mutex() { omp_destroy_lock(&

PHP 5.x syncronized file access (no database)

半腔热情 提交于 2020-01-13 09:43:30
问题 I'm mostly familiar with Java, C and C++ in which there are ways to control that only one thread is accessing a resource at any given time. Now I'm in search for something similar but in PHP 5.x. To formulate my problem with one example: I have an ASCII-file which only stores a number, the value of a page load counter. At application deployment the file will simply hold a 0. For each access the value will be incremented by one. The goal is to keep track of page loads. The problem comes when