Clean up threading code some more

This commit is contained in:
Justine Tunney 2022-09-13 14:57:38 -07:00
parent 6a3330d7c9
commit 654ceaba7d
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
28 changed files with 119 additions and 134 deletions

View file

@ -16,12 +16,13 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#define EZBENCH_COUNT 10000
#include "libc/atomic.h"
#include "libc/calls/calls.h"
#include "libc/calls/struct/timespec.h"
#include "libc/intrin/atomic.h"
#include "libc/mem/mem.h"
#include "libc/mem/gc.internal.h"
#include "libc/mem/mem.h"
#include "libc/testlib/ezbench.h"
#include "libc/testlib/testlib.h"
#include "libc/thread/posixthread.internal.h"
@ -175,9 +176,9 @@ struct MutexContentionArgs {
int MutexContentionWorker(void *arg, int tid) {
struct MutexContentionArgs *a = arg;
while (!atomic_load_explicit(&a->done, memory_order_relaxed)) {
pthread_mutex_lock(a->mutex);
if (pthread_mutex_lock(a->mutex)) notpossible;
atomic_store_explicit(&a->ready, 1, memory_order_relaxed);
pthread_mutex_unlock(a->mutex);
if (pthread_mutex_unlock(a->mutex)) notpossible;
}
return 0;
}