tag:blogger.com,1999:blog-5246987755651065286.post6123196525313259589..comments2024-02-22T16:15:42.388-08:00Comments on cbloom rants: 05-25-10 - Thread Insurancecbloomhttp://www.blogger.com/profile/10714564834899413045noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-5246987755651065286.post-61123196077273463212010-05-26T18:07:21.669-07:002010-05-26T18:07:21.669-07:00You could implement this with a handle or smart pt...You could implement this with a handle or smart ptr idiom, with methods to grab a mutable or const ptr to the actual data, and those methods assert that the current thread has the right permissions. You still have a code-correctness criterion which is "don't pass bare pointers between threads."Thatcher Ulrichhttps://www.blogger.com/profile/01374419756386535175noreply@blogger.comtag:blogger.com,1999:blog-5246987755651065286.post-19846130214747460442010-05-26T11:25:34.505-07:002010-05-26T11:25:34.505-07:00"Catching page faults I believe is pretty exp..."Catching page faults I believe is pretty expensive if you actually take the page faults often."<br /><br />Yeah, it would be a debug-runs only thing, but I wonder if it would be too slow even for debug testing runs.<br /><br />"You can typically set up stuff like this on a per process basis in Linux. You would map shared pages to let each process see the others. I'd imagine that windows would also support this type of thing."<br /><br />You can do it per-process in Windows, but I think that's just too much friction. If you use processes rather than threads it is much easier to enforce cleanness because there is no implicitly shared memory, all sharing must be done explicitly by mapping process memory to each other.<br /><br />"We're actually playing around with language support for stuff like this and having the type checker in the compiler complain about accessing protected data."<br /><br />Yeah there is a lot of good work in this direction (see Bartosz etc and previous posts on my blog), but it really only applies well to the struct-critsec kind of paradigm, not to the kind of ad-hoc threading I'm talking about here.cbloomhttps://www.blogger.com/profile/10714564834899413045noreply@blogger.comtag:blogger.com,1999:blog-5246987755651065286.post-85492673044683493112010-05-26T01:39:55.909-07:002010-05-26T01:39:55.909-07:00Catching page faults I believe is pretty expensive...Catching page faults I believe is pretty expensive if you actually take the page faults often. You can typically set up stuff like this on a per process basis in Linux. You would map shared pages to let each process see the others. I'd imagine that windows would also support this type of thing.<br /><br />We're actually playing around with language support for stuff like this and having the type checker in the compiler complain about accessing protected data. It appears to be pretty useful. If we get some time, we might port it to annotations in Java so people can actually use it.Brianhttps://www.blogger.com/profile/18061165495812067689noreply@blogger.comtag:blogger.com,1999:blog-5246987755651065286.post-82036709883732124672010-05-26T01:05:58.647-07:002010-05-26T01:05:58.647-07:00> This is just my hate for having rules for cod...> This is just my hate for having rules for code correctness that are not enforced by the compiler or at least by run-time asserts.<br /><br />Isn't that what "const" is for?<br /><br /> Thankyou folks, I'm here all night.Tom Forsythhttps://www.blogger.com/profile/01368434932814120414noreply@blogger.comtag:blogger.com,1999:blog-5246987755651065286.post-50446608604769755212010-05-25T20:27:00.720-07:002010-05-25T20:27:00.720-07:00The exception handler approach would work, but the...The exception handler approach would work, but the exceptions would end up being really expensive. Maybe you could use that approach to run automated tests of your app to verify the thread-safety, but leave the exceptions off in actual builds when you use them to crunch on lots of data?Kevin Gaddhttps://www.blogger.com/profile/04689186557672996705noreply@blogger.com