how to improve concurrency of process

34 views
Skip to first unread message

陈云星

unread,
Nov 19, 2019, 2:18:15 AM11/19/19
to tlaplus
each Label is an atomic action.

but in general programming language, each expression/statement concurrency with other thread.

so, how to express fine-grain atomic action unit in PlusCal ?

for example in a CAS style while loop. each statement/expression is concurrency with other thread:

while(!lock.get() && lock.compareAndSet(false, true)) {
   
// do action 1
   
// do action 2
   
// ...
}


I want each one is atomic (concurrency unit). 

add a label to each statement/expression will be very tedious.

can any cleaner manner ?

Stephan Merz

unread,
Nov 19, 2019, 2:25:52 AM11/19/19
to tla...@googlegroups.com
As you say, adding extra labels leads to a finer grain of atomicity. If you need to go beneath the level of statements, you can introduce extra local variables and assign subexpressions to them.

Stephan

--
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+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tlaplus/2967a186-d501-4e78-b97c-d6d9f30183db%40googlegroups.com.

Markus Kuppe

unread,
Nov 19, 2019, 2:55:57 AM11/19/19
to tla...@googlegroups.com
Hi,

since you mention CAS, the spec at [1] models a multithreaded,
shared-memory algorithm including CAS.

Best
Markus

[1]
https://github.com/tlaplus/tlaplus/blob/da85c32ab840e932419cbd3ff608861d07f530bf/tlatools/src/tlc2/tool/fp/OpenAddressing.tla
Reply all
Reply to author
Forward
0 new messages