tset here is probably a short form for
test_and_set. Each thread tries to acquire both locks. If it succeeds, it increments the variables and releases the locks. Otherwise it gives up.
Looks like this is enough to avoid a race condition, assuming that
tset is atomic.
Both threads use
tset and release the lock immediately if they fail two acquire them. Therefore this code also is deadlock free.
However this does not mean that there are no problems with this code.
It is possible that the threads will keep acquiring and releasing locks without making any progress. This is situation is called livelock in concurrency theory.
If you have atomic
test_and_set you could implement a proper critical section as Antti Haapala suggests in the comments.