[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [tlaplus] Verifying concurrent data structures
- From: Jones Martins <jonesmvc@xxxxxxxxx>
- Date: Thu, 23 Dec 2021 16:03:32 -0300
- Ironport-data: A9a23:IDP1V6modFM87QBMXI5Uc5Ho5gygJ0RdPkR7XQ2eYbTBsI5bp2QGxjdNCmyCOK6JMWCjfIsjYIm3oEwF657RzdBqTVM53Hw8FHgiRejtVY3IdB+oV8+xBpSeFxw/t512huEtnanYd1eEzvuWGuWn/SkUOZ2gHOKmUbeeYHspHmeIdQ944f5ds75h6mJXqYPha++9kYuaT/z3YDdJ6RYsWo4nw/7rRCdUgRjHkGhwUmrSyhx8lAS2e3E9VPrzLEwqRpfyatE88uWSH44vwFwll1418SvBCvv9+lr6WkgDQ7qXOgnXz3QPCvHkjR9FqSg/lK08MZLwa28N02TPz403kYsS88XhEG/FPYWU8AgZewVcGjl6ILYF8rnMC1OPiZOx73KcVlfW6dhLNXoRHaQ91d9aIV5h1NspCRgCaReMg++52rWmUvIqjcMmRCXuFNJF5y04lFk1Ct5/GcyZK0nQ3vdU3Sw7m9tVNerabowcciAqbRLaYhQJO1ENCZt4kv3Au5VVWykA/RfN4/Ujuj2LilRliu21doSOJoyeHpAN2BuM+Tfv4UDSBzU2NPi+wB+56FaSh8rbxHuuAMZKANVU7dZviVyXg2sSUVgYDAri5/a+jUG6VpRULEl8x8bnloBqnGTDczU3d0TQTL+4Uh8gtx54FuQ77ESKy/OR7V/IXy4LSTlObNFgv8gzLdDv/jdlgPuxbQGDcpXMIZ5eyltQhTy1PicRIGAYYjIcVk0O5NyLTEQbkEfUVtg6eEKqpoSdJNwzqgxmaAAxgLIcicMEzaKm5UuBiDWpznQMZmbZ+S2PNl+YAshFiEJJqmBmBZU3LRqNEWpBcmS8gQ==
- Ironport-hdrordr: A9a23:I6P0haMWjWES3cBcTmejsMiBIKoaSvp037B17SwBMiC9I/b05riTdaogv26MtN9xYgBXpTnkAsbvfZqyz+8G3WB8B8bQYOCighrZEGmNhbGSgAEJNUXFh65gPORbAuRD4OSZNyk6sS+C2nj7Lz9C+qj4zEgc7t2ugkuFLzsaHp2ItD0JQDpze3ceLGI2YutCZeahC9J81kedkDYsH7WG7x8+LqP+TvLw9K4OCiR2cyLPhjP++g9BKdbBYnylN9QlIlByKHUZkFQsI2fCl+ueWj2Au33hP2K51eUfpDMQoeEzTfBkQ/JlT0SL+3mVTbUkYaSLuHQeoe2k6lom1PnK5zk6OdhrgkmhMV2InQ==
- References: <firstname.lastname@example.org> <email@example.com> <firstname.lastname@example.org> <email@example.com>
Thank you, Dmytro!
Your insight about sequence points and sequentially consistency is something of which I should've reminded myself.
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 ..
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 a topic in the Google Groups "tlaplus" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tlaplus/4a8vbujvAZg/unsubscribe.
To unsubscribe from this group and all its topics, 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.
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/CABW84KygKq8vBg8kY8_gjZgu9%2BAKcChoZXgdOkUpVnuGaex%3DsA%40mail.gmail.com.