[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [tlaplus] Verifying concurrent data structures
- From: Dmytro Ivanov <dmytro@xxxxxxxxxxxxxx>
- Date: Thu, 23 Dec 2021 02:05:29 -0800 (PST)
- Ironport-data: A9a23:sHJjIaDNVHYLexVW/w7iw5YqxClBgxIJ4g17XOLfBwaw0jsl1TBWzmNJX2/QPvbYYmX2f91xOYvj8xgAu8Wkm99gGjLY11k9FiMQ8ZKt6fexdxqrYXvKdqUvdK/WhiknQoGowPscEzmM9n9BDpC79SMljPvSHeKmYAL5EnkZqTFMGH9JZS1LwLZRbr5A2bBVMivV0T/Ai5W31GyNh1aYBlkpB5er83uDihhdVAQw5TTSbdgT1LPXeuJ84Jg3fcldJFOgKmVY83LTegrN8F251juxExYFD9qklvP8dRRPTOCJeweJjXVSVu6phR0qSi4aiP5qcqpBLx4J0nPXxLidy/0V3XC0YRstN7XIhf9eWR9TOQ1SY5NmyJ76AF2Fm5bP83bpU1LJ7MxDIGIGGtY52854BmZB8fEXMjcQdgvFjOWzqF6+YrA23Zl+c5K3VG8Ykig4kWux4ewdaZzCWK7X/sRwwDM5wMVVB7PfYdAYYHxuag7BaltBID8q5DgWiL/9wyG5LSkB/QrT/b5ttjCVklYuiay2ZYKTJ8jVEOxLuG2dgE7G20XwJy0AEOKe7C7cqif0wrbb9c/gcIcbFbn98fkzxVPNnSocDxoZUVb9qv684nNSkul3cyQ8khfCZ4BrnKBqcjX8Y/F8iHuNvxpZXN0JVuNks0eCza3b5wvfDW8BJtKEQLTKq+duLQHGFHfQ9z8qOdCrmLKSTn2Z+7iOqi6qIm4eKmpqieosU14e+9e6yG0spkunczugeZJZSvX6Hjb/xz2Fti8jn65VhskOv0l+1TgrnBr0zqX0osUJCsk7k45rAs6VpGJoWmBw1WXm0A==
- Ironport-hdrordr: A9a23:c0rp+qikHhNga+EHabsLuU2kY3BQXlUji2hC6mlwRA09TyVXraGTdZMgpHvJYVcqKRQdcLW7UpVoLkmwyXcY2+Us1VnLZnidhILqFvAY0WPaqweQZhEWj9QtqZuIEZIfNDSANykZsS+g2njeLz9I+rDum5xA492w854Hd3AIV0gP1WlE4y+gYzJLbTgDK5olNYaWovFKryCnfh0sH7yGL0hAcejfhsHB0Knrax4eBxIh9WC1/EqVwY+/PRiE/wsUFwhCy7c68WTDjkjQ66i5v+ugoyWsqVP73tB5mMbB1tAGPsCKh8QPQw+c7DqVWA==
- References: <firstname.lastname@example.org> <email@example.com> <firstname.lastname@example.org>
I've implemented something similar to one of my employers:
- We had existing lockfree MPMC stack/queue/etc data structures in C.
- I've converted existing code to PlusCal almost 1-to-1 to best of my ability. There were some nitpicks regarding how PlusCal implements return values, so I took some liberties. But important part is from a view of sequential consistency, most if not all sequence points were preserved. That is a bit weak guarantee as obviously every C sequence point potentially compiles to multiple instructions, so one could go and model instructions directly if that is what required. But most lockfree algorithms are not relying on specific ordering of instructions between threads, they more relying on ordering of sequence points, so overall it's fairly ok.
- On top of that I've added a "test program" written also in PlusCal that emulates 2-3+ threads and tries to add/remove elements from the data structure, test program keeps a separate set of "correct" elements. And it compares reference to result of algorithm.
- Then I've limited generation counters (common feature in lockfree algorithms to resolve ABA) to something small like 100.
- Running TLC then finds all possible states, and proves that algorithm is correct, with exception of generation counter wrap around (if one thread is stuck and another wraps around generation counter, then you still arrive at ABA).
Generally it's great for sequential consistency code. My next goal was to try different relaxed memory models, but I've moved to other stuff ..
On Thursday, December 23, 2021 at 1:19:15 AM UTC+1 jone...@xxxxxxxxx wrote:
Thank you, Markus for the example, and Calvin, for your examples and explanations!
I looked for data structure specs in the tlaplus/examples repo on Github, but I couldn't find any. Maybe I didn't search right?
Also, Markus, OpenAddressing.tla seems like a nice addition to the tlaplus/examples repository, don't you think?
On Wednesday, 22 December 2021 at 15:10:44 UTC-3 Markus Alexander Kuppe wrote:
On 12/21/21 3:29 PM, Jones Martins wrote:
> Hello, everyone
> Since TLA+ can also verify (and prove) correctness of algorithms,
> protocols, etc., I wonder how to verify data structures. When modelling
> a sequential data structure compared to a concurrent data structure, how
> should one go about specifying it?
> For example, let's say I implemented an abstract Set specification
> with "Add", "Remove" and "Contains" actions. How do I prove correctness?
> What about a concurrent Set?
is a spec of a concurrent, lock-free set (no deletion).
You received this message because you are subscribed to the Google Groups "tlaplus" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tlaplus+unsubscribe@xxxxxxxxxxxxxxxx.
To view this discussion on the web visit https://groups.google.com/d/msgid/tlaplus/d1e62261-5e38-47c8-95f0-ecb526f45bb8n%40googlegroups.com.