add my own broken example for uiowa-threads.c

master
neingeist 11 years ago
parent 8141a18cab
commit a5638de011

1
.gitignore vendored

@ -33,3 +33,4 @@ multibrot-openmp.png
hello-openmp
mandelbrot-openmp
positional-format-strings
uiowa-threads-my-example

@ -7,7 +7,8 @@ CFLAGS_OPENMP=$(CFLAGS) -fopenmp
TARGETS=approximate-pi linked-list mandelbrot threads circular-buffer structs \
ncurses-pong bit-fuckery bit-fuckery2 checkcheck multibrot bloom \
wo-lernen lua-foo binsearch test-inline-assembly uiowa-threads-example \
wo-lernen lua-foo binsearch test-inline-assembly \
uiowa-threads-example uiowa-threads-my-example \
mtrace-test av-variance undefined-behaviour \
multibrot-openmp hello-openmp mandelbrot-openmp \
positional-format-strings
@ -81,6 +82,9 @@ mtrace-test.txt: mtrace-test.trace
uiowa-threads-example: uiowa-threads.o uiowa-threads-example.c
$(CC) $(CFLAGS) -o $@ $^
uiowa-threads-my-example: uiowa-threads.o uiowa-threads-my-example.c
$(CC) $(CFLAGS) -o $@ $^
av-variance: av-variance.c
$(CC) $(CFLAGS) -o $@ $< -lm

@ -0,0 +1,28 @@
#include <stdio.h>
#include "uiowa-threads.h"
void test_thread(int n) {
for (int i=0; i<10; i++) {
printf("thread %d: %d\n", n, i);
thread_relinquish();
}
}
void test_thread2(int n) {
for (int i=0; i<10; i++) {
printf("thread %d: %d\n", n, i);
thread_relinquish();
}
}
int main()
{
thread_manager_init();
thread_startup_report();
thread_launch(4000, test_thread, 1);
thread_launch(4000, test_thread2, 2);
thread_manager_start();
/* control never reaches this point */
}
Loading…
Cancel
Save