И еще кстати один вопрос связанный с компилированием простейшего example кода для демонстрации одного pthread потока (из учебника Getting_started_with_uClinux_A.pdf).
Сам пример:
Код
#include <stdio.h>
#include <pthread.h>
static void* mythread(void* arg)
{
printf("mythread called arg = %s\n", (char *)arg);
return NULL;
}
int main(int argc, char* argv[])
{
int ret;
pthread_t thread1;
pthread_t thread2;
if (argc < 3) {.
printf("Usage: pthreads arg1 arg2\n");
exit(1);
}
ret = pthread_create(&thread1, NULL, mythread, argv[1]);
if (ret != 0) {
printf("Failed to create thread 1 ret=%d\n", ret);
exit(1);
}
ret = pthread_create(&thread2, NULL, mythread, argv[2]);
if (ret != 0) {
printf("Failed to create thread 2 ret=%d\n", ret);
exit(1);
}
pthread_join( thread1, NULL);
pthread_join( thread2, NULL);
return 0;
}
Вот makefile для него
Код
CFLAGS= -Wall -W
LDFLAGS= -Wl -elf2flt -lpthread
CC= /usr/local/bin/arm-elf-gcc
RM=rm -f
PROG=thread
SRC= thread.c
OBJ=$(SRC:%.c=%.o)
$(PROG): $(OBJ)
$(CC) $(CFLAGS) -o $(PROG) $(OBJ) $(LDFLAGS)
.PHONY: clean all dep
clean:
$(RM) $(PROG) $(OBJ) *~ *.gdb .depend *.elf2flt *.elf
Скомпилированное приложение получается размером 116 кб.
Ну это же неимоверно много? Почему так?
p.s. Для сборки использую тулчейн установленный из arm-elf-tools-20040427.sh (опять же по рекомендации из этого учебника...)