#include <stdio.h> #include <pthread.h> #include <unistd.h> #define NUM_THREADS 5 void *thread_function(void *arg) { printf("Hello World from %d!\n", (int)arg); sleep(1); pthread_exit(NULL); } int main(int argc, char *argv[]) { int i; pthread_t threads[NUM_THREADS]; for (i = 0; i < NUM_THREADS; i++) pthread_create(&threads[i], NULL, thread_function, (void *)i); for (i = 0; i < NUM_THREADS; i++) pthread_join(threads[i], NULL); return 0; }
AXIS_USABLE_LIBS = UCLIBC GLIBC include $(AXIS_TOP_DIR)/tools/build/Rules.axis PROGS = pthread_test LDFLAGS += -lpthread -D_REENTRANT all: $(PROGS) $(PROGS): $(PROGS).o $(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@ cris-strip $(PROGS) clean: rm -f $(PROGS) *.o core copytofox: scp $(PROGS) 192.168.0.90:/mnt/flash