Concurrencydurable_goods, long_term_debts); ## MUTEXES MUTual EXclusion Most basic form of synchronization Only one thread at a time can lock or acquire the mutex ## MUTEXES Example ## An airplane lavatory Anyone 82a353daf32da869eac18c1daaa4f97e/p75_1.jpg) Kristoferb CC BY-SA 3.0, via Wikimedia Commons ## MUTEXES Example ## An airplane lavatory Anyone can go in and lock the door Has exclusive use of lavatory 82a353daf32da869eac18c1daaa4f97e/p76_1.jpg) Kristoferb CC BY-SA 3.0, via Wikimedia Commons ## MUTEXES Example A talking stick in a group discussion Only the person holding the stick is supposed to0 码力 | 160 页 | 2.91 MB | 1 年前3
cppcon 2021 safety guidelines for C parallel and concurrencyUse std::lock(), std::try_lock() or s 0.4.4 [12] Do not destroy objects of the follc 0.4.5 [13] Mutexes locked with std::lock or s 0.4.6 [14] Do not call virtual functions and c 0.4.7 [15] Avoid deadlock st|mandatory|complex|yes, on system level|accept for initial revision|clear UB related| |12|0.4.5 \[13] Mutexes locked with std::lock or std::try\_lock shall be wrapped with std::loci|required|easy|yes, on local Safety rules 3. Automotive Safety case ## For humans and tools -> C++CG and MISRA - Rule 13 Mutexes locked with std::lock or std::try_lock shall be wrapped with std::lock_guard, std::unique_lock or0 码力 | 52 页 | 3.14 MB | 1 年前3
A Relaxed Guide to memory_order_relaxedper-thread statistical counters. But “unidirectional” can be a slippery concept: See upcoming reentrant mutexes. ## What makes an idiom potentially unsafe? Loading an atomic value with a relaxed load, and relying // r2 is now trusted. if (r2 is bad) b[rand()] = rand(); ## Unsafe in strict C++20: reentrant mutexes class my_reentrant_mutex { std::mutex m; // Writes of owner are protected by m. // Only int count; // Held count-1 times by owner } ## Unsafe in strict C++20: reentrant mutexes(2) void my_reentrant_mutex::lock() { std::thread::id me = std::this_thread::get_id(); //0 码力 | 32 页 | 278.53 KB | 1 年前3
From Eager Futures/Promises to Lazy Continuations: Evolving an Actor Library Based on Lessons Learned from Large-Scale Deploymentssolutions 1963: mutexes, semaphores 1973: actors 1974: monitors 1978: communicating sequential processes (CSP) 1987: statecharts ## possible solutions with threads 1963: mutexes, semaphores 1973: communicating sequential processes (CSP) 1987: statecharts ## possible solutions without threads 1963: mutexes, semaphores 1973: actors 1974: monitors 1978: communicating sequential processes (CSP) 1987: with libprocess) • over a half million lines of code • hundreds of contributors - about a dozen mutexes! (mostly for interfacing with code not written w/libprocess) • massive scale (clusters of ~80k physical0 码力 | 264 页 | 588.96 KB | 1 年前3
Coroutine Patterns and How to Use Them: Problems and Solutions Using Coroutines in a Modern CodebasecollectAll( increaseBy(a, 1), increaseBy(a, 2)); ## Synchronization Which tools? • Regular mutexes • Coro mutex ## Synchronization – Regular DON'T HOLD ACROSS SUSPENSION POINTS!!! • UB if held Knowledge • Do not hold regular lock across suspension points • Use coro mutexes, including guards • Use try_lock() to for coro mutexes in destructor ## Conclusions • Saw patterns to do and avoid • Build0 码力 | 70 页 | 1.45 MB | 1 年前3
What Volatile Means (and Doesn't Mean)inter-thread communication, such as: • mutexes • semaphores • condition variables ✓ For inter-thread communication, use synchronization tools such as mutexes and semaphores. ✓ Don’t use volatile objects but may reorder accesses to non-volatile objects around them. ■ Use synchronization tools (e.g., mutexes and semaphores) rather than volatile objects to manage inter-thread communication. ■ Accesses to0 码力 | 32 页 | 901.80 KB | 1 年前3
MuPDF 1.22.0 Documentationapplication. MuPDF can be invoked with a user-supplied set of locking functions. It uses these to take mutexes around operations that would conflict if performed concurrently in multiple threads. By leaving the should be a pointer to a set of locking functions. The calling code should provide FZ_LOCK_MAX mutexes, which will be locked/unlocked by MuPDF calling the lock/unlock function pointers in the supplied user pointer from the structure and the lock number, i ( $ 0 \leq i < FZ\_LOCK\_MAX $ ). These mutexes can safely be recursive or non-recursive as MuPDF only calls in a non-recursive style. To make subsequent0 码力 | 175 页 | 698.87 KB | 1 年前3
MuPDF 1.25.0 Documentationapplication. MuPDF can be invoked with a user-supplied set of locking functions. It uses these to take mutexes around operations that would conflict if performed concurrently in multiple threads. By leaving the argument should be a pointer to a set of locking functions. The calling code should provide FZ_LOCK_MAX mutexes, which will be locked/unlocked by MuPDF calling the lock/unlock function pointers in the supplied user pointer from the structure and the lock number, i ( $ 0 \leq i < FZ\_LOCK\_MAX $ ). These mutexes can safely be recursive or non-recursive as MuPDF only calls in a non-recursive style. To make subsequent0 码力 | 259 页 | 1.11 MB | 1 年前3
MuPDF 1.23.0 Documentationapplication. MuPDF can be invoked with a user-supplied set of locking functions. It uses these to take mutexes around operations that would conflict if performed concurrently in multiple threads. By leaving the should be a pointer to a set of locking functions. The calling code should provide FZ_LOCK_MAX mutexes, which will be locked/unlocked by MuPDF calling the lock/unlock function pointers in the supplied user pointer from the structure and the lock number, i ( $ 0 \leq i < FZ\_LOCK\_MAX $ ). These mutexes can safely be recursive or non-recursive as MuPDF only calls in a non-recursive style. To make subsequent0 码力 | 245 页 | 817.74 KB | 1 年前3
MuPDF 1.24.0 Documentationapplication. MuPDF can be invoked with a user-supplied set of locking functions. It uses these to take mutexes around operations that would conflict if performed concurrently in multiple threads. By leaving the argument should be a pointer to a set of locking functions. The calling code should provide FZ_LOCK_MAX mutexes, which will be locked/unlocked by MuPDF calling the lock/unlock function pointers in the supplied user pointer from the structure and the lock number, i ( $ 0 \leq i < FZ\_LOCK\_MAX $ ). These mutexes can safely be recursive or non-recursive as MuPDF only calls in a non-recursive style. To make subsequent0 码力 | 249 页 | 830.15 KB | 1 年前3
共 243 条
- 1
- 2
- 3
- 4
- 5
- 6
- 25
相关搜索词
ConcurrencyparallelismData RacesMutexesatomic operationsC++MISRAsafety-critical systemsconcurrencymemory_order_relaxedC++20OOTARFUBFutures/PromisesActorsLazy ContinuationsEventualsSchedulingcoroutine patternssynchronizationRAIIexception handlinglifetime managementvolatilecompiler optimizationsmemory barriersatomicitystd::uint32_tMuPDF安装构建APIPython绑定错误处理上下文克隆渐进式加载CAPIJavaScriptmutoolOpenGLC++ APIthird-party librariesbuilding the libraryinstallationC APIFitz ContextFitz libraryMuPDF modules













