- A Java- / .NET-like monitor - 25 Updates
| "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Nov 08 09:18PM -0800 On 11/8/2023 9:17 PM, Kaz Kylheku wrote: > provides can make it easier to reason about correctness. > It's something to know about as part of a well-rounded education > in concurrent programming. I concur with that assessment. |
| Bonita Montero <Bonita.Montero@gmail.com>: Nov 09 06:34AM +0100 Am 09.11.2023 um 06:31 schrieb Chris M. Thomasson: > Yup. Porting your code to Relacy is going to force me to read every damn > line of your code. So, touche? Reading the code doesn't hurt since the functions are short. |
| "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Nov 08 09:35PM -0800 On 11/8/2023 9:17 PM, Bonita Montero wrote: > Wait morphing isn't implemented with glibc's condition variables. > My code doen't need that because I'm sleeping on the condvar part > and on the mutex part in *one* step. Wait morphing is a way that shows how interconnected a mutex actually is with a condition variable... |
| "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Nov 08 09:36PM -0800 On 11/8/2023 9:34 PM, Bonita Montero wrote: >> Yup. Porting your code to Relacy is going to force me to read every >> damn line of your code. So, touche? > Reading the code doesn't hurt since the functions are short. Porting your code to Relacy makes me read every damn line. You masking is interesting. |
| Bonita Montero <Bonita.Montero@gmail.com>: Nov 09 06:22AM +0100 Am 09.11.2023 um 06:17 schrieb Chris M. Thomasson: > Humm... Sounds good. However, I need to try it out. Also, if you don't > mind I might actually model it in relacy. I've witten my own unit test. The Win32 code worked immediately, but the SysV-code didn't work immediately also because I forgot to have IPC_NOWAIT while releasing a semaphore. Why is there a way to wait for the release of a mutex to be accepted by another thread ? Who comes up with that ? |
| Bonita Montero <Bonita.Montero@gmail.com>: Nov 09 06:39AM +0100 Am 09.11.2023 um 06:35 schrieb Chris M. Thomasson: > Wait morphing is a way that shows how interconnected a mutex actually is > with a condition variable... As you can derive from what I said I know what wait morphing is. I think wait morphing could be prevented unter systems supporting SysV seamphores by allocating a semaphore set of two semaphores for each mutex and leaving the second unused until you have a condition variable. |
| Bonita Montero <Bonita.Montero@gmail.com>: Nov 09 06:40AM +0100 Am 09.11.2023 um 06:36 schrieb Chris M. Thomasson: > Porting your code to Relacy makes me read every damn line. > You masking is interesting. My code is understandable if you know MT-primitives and SysV-IPC. There's nothing "damn" with my code. |
| "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Nov 08 09:40PM -0800 On 11/8/2023 9:39 PM, Bonita Montero wrote: > SysV seamphores by allocating a semaphore set of two semaphores > for each mutex and leaving the second unused until you have a > condition variable. Can you move waitsets over from mutex to futex and vise versa? |
| "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Nov 08 09:41PM -0800 On 11/8/2023 9:40 PM, Chris M. Thomasson wrote: >> for each mutex and leaving the second unused until you have a >> condition variable. > Can you move waitsets over from mutex to futex and vise versa? This is in the kernel... |
| "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Nov 08 09:42PM -0800 On 11/8/2023 9:40 PM, Bonita Montero wrote: >> You masking is interesting. > My code is understandable if you know MT-primitives > and SysV-IPC. There's nothing "damn" with my code. Oh well, like I said, you seem to be a fun person to work with... |
| Bonita Montero <Bonita.Montero@gmail.com>: Nov 09 06:42AM +0100 Am 09.11.2023 um 06:40 schrieb Chris M. Thomasson: > Can you move waitsets over from mutex to futex and vise versa? glibc doesn't do this either. |
| "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Nov 08 09:44PM -0800 On 11/8/2023 9:42 PM, Bonita Montero wrote: > Am 09.11.2023 um 06:40 schrieb Chris M. Thomasson: >> Can you move waitsets over from mutex to futex and vise versa? > glibc doesn't do this either. Wait morphing is not in the realm of the compiler. It's in the kernel. |
| "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Nov 08 09:44PM -0800 On 11/8/2023 9:44 PM, Chris M. Thomasson wrote: >>> Can you move waitsets over from mutex to futex and vise versa? >> glibc doesn't do this either. > Wait morphing is not in the realm of the compiler. It's in the kernel. OOPS! I thought you were talking about gcc. Sorry Bonita! |
| Bonita Montero <Bonita.Montero@gmail.com>: Nov 09 06:45AM +0100 Am 09.11.2023 um 06:44 schrieb Chris M. Thomasson: > Wait morphing is not in the realm of the compiler. It's in the kernel. Read this: https://stackoverflow.com/questions/45163701/which-os-platforms-implement-wait-morphing-optimization |
| "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Nov 08 09:48PM -0800 On 11/8/2023 9:45 PM, Bonita Montero wrote: >> Wait morphing is not in the realm of the compiler. It's in the kernel. > Read this: > https://stackoverflow.com/questions/45163701/which-os-platforms-implement-wait-morphing-optimization Wait morphing can be highly beneficial. |
| "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Nov 08 09:50PM -0800 On 11/8/2023 9:48 PM, Chris M. Thomasson wrote: >> Read this: >> https://stackoverflow.com/questions/45163701/which-os-platforms-implement-wait-morphing-optimization > Wait morphing can be highly beneficial. I have to go to work on my fractals right now, will get back to you. I will mostly have time to port your code into a Relacy unit test sometime later on tonight or tomorrow. This work will be for free for you. Will you even appreciate it in any way shape or form? Or mock me? |
| Bonita Montero <Bonita.Montero@gmail.com>: Nov 09 06:50AM +0100 Am 09.11.2023 um 06:39 schrieb Bonita Montero: > SysV seamphores by allocating a semaphore set of two semaphores > for each mutex and leaving the second unused until you have a > condition variable. Sorry, this dosn't work beyond one condvar per mutex. |
| Bonita Montero <Bonita.Montero@gmail.com>: Nov 09 06:52AM +0100 Am 09.11.2023 um 06:48 schrieb Chris M. Thomasson: >> Read this: >> https://stackoverflow.com/questions/45163701/which-os-platforms-implement-wait-morphing-optimization > Wait morphing can be highly beneficial. Wait morphing isn't necessary under Win32 since you can wait for the mutexe's binary semaphore and for the condvar's counting semaphore in one step with WaitForMultipleObjects. Unfortunately there's nothing under Linux like that. |
| "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Nov 08 09:58PM -0800 On 11/8/2023 9:50 PM, Chris M. Thomasson wrote: > will mostly have time to port your code into a Relacy unit test sometime > later on tonight or tomorrow. This work will be for free for you. Will > you even appreciate it in any way shape or form? Or mock me? the funny thing is that I need to model one of my new wait-free queue experiments in Relacy for use in my rendering engine. |
| Bonita Montero <Bonita.Montero@gmail.com>: Nov 09 07:32AM +0100 Am 09.11.2023 um 06:42 schrieb Chris M. Thomasson: >> My code is understandable if you know MT-primitives >> and SysV-IPC. There's nothing "damn" with my code. > Oh well, like I said, you seem to be a fun person to work with... If you were here we would go through the code together and you would immediately understand it. |
| "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Nov 08 10:46PM -0800 On 11/8/2023 9:58 PM, Chris M. Thomasson wrote: >> you. Will you even appreciate it in any way shape or form? Or mock me? > the funny thing is that I need to model one of my new wait-free queue > experiments in Relacy for use in my rendering engine. An example of my main experiment: https://youtu.be/n13GHyYEfLA All of my own GLSL shaders, pure C++ and openGL. |
| "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Nov 08 10:54PM -0800 On 11/8/2023 10:32 PM, Bonita Montero wrote: >> Oh well, like I said, you seem to be a fun person to work with... > If you were here we would go through the code together > and you would immediately understand it. Since I have to model one of my experimental algorithms in Relacy anyway, well, I will be right up in it. Wrt my code, well, its trying to make some fractals go volumetric and I need to highly efficient and specialized LIFO/FIFO stack/queue system for it. They are running on the CPU, I might even be able to get it run in shaders, but for now, I need to work on modeling my sketch of my code in Relacy, create some test units, and give it a go. Fwiw, here is one of my vector fields: https://youtu.be/poXeq5V0dso This used an older queue of mine to help distribute the field processing across multiple processors. |
| "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Nov 08 11:01PM -0800 On 11/8/2023 10:54 PM, Chris M. Thomasson wrote: > https://youtu.be/poXeq5V0dso > This used an older queue of mine to help distribute the field processing > across multiple processors. Fwiw, this one is basically embarrassingly parallel to create each frame. Well, that is kind of cheating wrt embarrassingly parallel, but, oh well: https://youtu.be/DrPp6xfLe4Q This one is from a recursive algorithm of mine, not too efficient wrt the generation part that gives me my field points to work with. It takes a while to render an animation in 4k. The recursive nature of it can blow a threads stack if I get too detailed. So, I need to refine my current quick and dirty proof of concept code, so to speak. It is kind of embarrassingly parallel... |
| Bonita Montero <Bonita.Montero@gmail.com>: Nov 09 08:01AM +0100 Am 09.11.2023 um 06:48 schrieb Chris M. Thomasson: > Wait morphing can be highly beneficial. I just checkes how many voluntary context switches I have under Linux when having a poing-pong between two theads serving a common mutex and individual condvars. #include <iostream> #include <thread> #include <mutex> #include <condition_variable> #include <atomic> #include <sys/resource.h> using namespace std; int main() { mutex mtx; struct wait_t { bool signal; condition_variable cond; } waitA, waitB; constexpr size_t ROUNDS = 100'000; atomic<uint64_t> switches( 0 ); auto thr = [&]( wait_t &waitMe, wait_t &waitYou ) { for( size_t r = ROUNDS; r--; ) { unique_lock<mutex> lock( mtx ); while( !waitMe.signal ) waitMe.cond.wait( lock ); waitMe.signal = false; waitYou.signal = true; waitYou.cond.notify_one(); } rusage ru; if( getrusage( RUSAGE_THREAD, &ru ) ) terminate(); switches += ru.ru_nvcsw; }; waitA.signal = true; waitA.cond.notify_one(); jthread thrA( thr, ref( waitA ), ref( waitB ) ), thrB( thr, ref( waitB ), ref( waitA ) ); thrA.join(); thrB.join(); cout << switches << endl; } The code prints about ROUNDS * context switches, that's great. |
| Bonita Montero <Bonita.Montero@gmail.com>: Nov 09 08:01AM +0100 Am 09.11.2023 um 08:01 schrieb Bonita Montero: > cout << switches << endl; > } > The code prints about ROUNDS * context switches, that's great. * 2 |
| You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment