https://github.com/gikoskos/libccr
Hoare's Conditional Critical Regions implemented as a C library
https://github.com/gikoskos/libccr
c cmake concurrency concurrent-programming pthreads synchronization
Last synced: about 2 months ago
JSON representation
Hoare's Conditional Critical Regions implemented as a C library
- Host: GitHub
- URL: https://github.com/gikoskos/libccr
- Owner: Gikoskos
- License: other
- Created: 2018-07-11T21:00:21.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-07-12T08:03:55.000Z (almost 8 years ago)
- Last Synced: 2025-02-17T16:30:04.931Z (over 1 year ago)
- Topics: c, cmake, concurrency, concurrent-programming, pthreads, synchronization
- Language: C++
- Homepage:
- Size: 109 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
# libccr

Simple and easy-to-use conditional critical regions (CCR) with pthreads in C.
CCR is a high-level synchronization construct with the form
`region R when C do S`
where R is the region's name, C is a condition and S the critical section.
The above statement is translated to
Enter region R
Block current thread while condition C is false
Enter critical section S (when condition C becomes true)
Execute all code in critical section S
Leave S
Leave R
A CCR guarantees mutual exclusion and fairness (no starvation) when checking whether condition C is true or not, and when executing the code in critical section S.
## How to use
Supported platforms are Linux, OSX and Windows (only tested with mingw and libwinpthread), but it can be used anywhere where there's support for pthreads.
The library comes in two flavors: a [macro-only implementation](Doc.md#macro-api) that works simply by including the header file `ccr.h`, and a [regular library](Doc.md#library-api) `ccr.c` that can be compiled statically, and interfaced with, using the library API.
[Documentation and tutorials here](Doc.md).
Various synchronization problems solved with `libccr` can be found on the folder `examples`. These make use of POSIX APIs like `strerror_r`, and VT100 terminal color codes, so they might not compile everywhere.
## License
See LICENSE