Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion halfhalf.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <stdint.h>
#include "delay.h"
#include "queue.h"
#include "primitives.h"

#ifndef LOGN_OPS
#define LOGN_OPS 7
Expand Down Expand Up @@ -37,7 +38,10 @@ void thread_init(int id, int nprocs) {
}

void thread_exit(int id, int nprocs) {
queue_free(q, hds[id]);
// Only free the queue from a single thread, to avoid double-free
static int lock = 0;
if (FAA(&lock, 1) == 0)
queue_free(q, hds[id]);
}

void * benchmark(int id, int nprocs) {
Expand Down
6 changes: 5 additions & 1 deletion pairwise.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <stdint.h>
#include "delay.h"
#include "queue.h"
#include "primitives.h"

#ifndef LOGN_OPS
#define LOGN_OPS 7
Expand Down Expand Up @@ -57,7 +58,10 @@ void * benchmark(int id, int nprocs) {
}

void thread_exit(int id, int nprocs) {
queue_free(q, hds[id]);
// Only free the queue from a single thread, to avoid double-free
static int lock = 0;
if (FAA(&lock, 1) == 0)
queue_free(q, hds[id]);
}

#ifdef VERIFY
Expand Down