Skip to content

Instantly share code, notes, and snippets.

@jpopesculian
Created July 14, 2021 11:34
Show Gist options
  • Save jpopesculian/c87ee511ce1e9b259e50910b16b36d84 to your computer and use it in GitHub Desktop.
Save jpopesculian/c87ee511ce1e9b259e50910b16b36d84 to your computer and use it in GitHub Desktop.
Zenroom Threaded Bug
#include <stdlib.h>
#include <pthread.h>
#include <zenroom.h>
void *zenExec(void *vargp)
{
zencode_exec("Scenario 'ecdh': Create the keypair\n\
Given that I am known as 'Alice'\n\
When I create the keypair\n\
Then print my data\n", "", "", "");
return NULL;
}
int main()
{
const int NUM_THREADS = 5;
pthread_t thread_ids[NUM_THREADS];
for (int i = 0; i < NUM_THREADS; i++) {
pthread_create(&thread_ids[i], NULL, zenExec, NULL);
}
for (int i = 0; i < NUM_THREADS; i++) {
pthread_join(thread_ids[i], NULL);
}
exit(0);
}
CC=gcc
ZENDIR =../zenroom/src
LIBS=-lm -lpthread -lzenroom-x86_64
CFLAGS := -I$(ZENDIR) -L$(ZENDIR) -Wl,-rpath=$(ZENDIR) $(LIBS)
OBJ = main.o
BIN = main
$(BIN): $(OBJ)
$(CC) -o $@ $^ $(CFLAGS)
%.o: %.c
$(CC) -c -o $@ $< $(CFLAGS)
.PHONY: clean
clean:
rm -f $(BIN)
rm -f *.o
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment