7 ms·
Or you just use static atomic variables no? I mean it wont solve your race conditions but it also wont crash. And it will be VERY fast because parallelism wit
by spintin 2y ago
Or you just use static atomic variables no?
I mean it wont solve your race conditions but it also wont crash.
And it will be VERY fast because parallelism without cache misses!
I wish there was a Java with C struct JNI access.
- bugbuddy 2y agoThis is false. Depending on the CPU Arch, updating a shared static atomic variable may cause cache invalidation. How fast depends on how hot and tight you critical sections are.
- yvdriess 2y agoSaying this as a big hardware atomics enjoyer: Static atomic variables are not fast, are not parallel and definitely are the worst kind of cache misses. Atomics are also atomic only on that one single operation, such as manipulating a single number in a struct or swapping out a pointer from one version of an object to another. To atomically expose a set of changes to a datastructure, you either use a lock or swap the old for the new, which is the driving example in the article.
- neonsunset 2y agoIt's called C# (supporting plain C structs is just a small part of its low-level features)
- pjmlp 2y agoOr D, available as official fronted language on GCC and LLVM projects, :)
- gmokki 2y agoModern Java does support directly calling C functions, with structs. And also upcalls back to java. All without any JNI style preprocessing or stubs. https://docs.oracle.com/en/java/javase/21/core/calling-c-library-function-foreign-function-and-memory-api.html https://docs.oracle.com/en/java/javase/21/core/calling-c-lib...
- spintin 2y agoHm, ok I have Arrays of 64 byte atomic Structs defined in C and I want to iterate over them in Java, is that possible with the Memory API?