Skip to content

Conversation

@cwoffenden
Copy link
Collaborator

This is a complete rethink of the lock test to do something locks would actually be used for: maintain atomicity of a complex data structure. We have this dummy struct with three members:

typedef struct {
  uint32_t val0;
  uint32_t val1;
  uint32_t val2;
} Dummy;

A series of calculations are performed thousands of times from both the main and audio thread, involving all the members. Without locks the steps are interleaved, resulting in the wrong result at the end.

It simulates a queue, for example, or any other container. Comment out the emscripten_lock_busyspin_wait_acquire() call and it will fail (with a shorter number of iterations sometimes it would get lucky, but running intensively for a few seconds ensures failure without locks).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant