I have the following code: What I don’t understand is why I do not have a race condition here? We have global variable, two threads, it suppose to give different values when subtracting and adding, but for me it’s always giving 0. How to make race condition in this example? Is the global variable …
Tag: race-condition
competing regular expressions (race condition)
I’m trying to use python PLY (lex/yacc) to parse a language called ‘GRBL’. GRBL looks something like this: The ‘G’ Codes tell a machine to ‘go’ (or move) and the coordinates say where. LEX requires us to specify a unique regular expression for every possible ‘to…
Atomic increment of a counter in django
I’m trying to atomically increment a simple counter in Django. My code looks like this: If I understand Django correctly, this should wrap the function in a transaction and make the increment atomic. But it doesn’t work and there is a race condition in the counter update. How can this code be made…