-* make a first implementation using rtep
+* rtep spare capacity
+* make the unix platform working with a linux external thread
+* finish frescan
@exec echo -e "\n>> Building $@: ";
@if [ -f $< ]; \
then \
- $(CC) $(CFLAGS) $< $(LDFLAGS); \
- fi; # -o $@ (fix marte mgcc)
+ $(CC) $(CFLAGS) $< $(LDFLAGS) -o $@; \
+ fi;
@exec echo ">> End Building $@";
libfna:
endif
ifeq ($(UNIX_ENABLE),UNIX_FNA_ENABLED)
@make -C $(FNA_PATH)/src_unix libunixfna.a
+endif
+ifeq ($(FRESCAN_ENABLE),FRESCAN_FNA_ENABLED)
+ @make -C $(FNA_PATH)/src_frescan libfrescan.a
endif
@ar -rc libfna.a $(FNA_PATH)/src/*.o
@mv libfna.a $(FNA_PATH)/lib/
fna_operations_t *fna_operations[FNA_MAX_NETWORKS] = {
- &rtep_fna_operations,
+ NULL, // &rtep_fna_operations,
// &unix_fna_operations,
// NULL, // resource_id 0
NULL, // resource_id 1
-.PHONY: none frescan clean cleanall
+.PHONY: none libfrescan.a clean cleanall
include ../config.mk
include ../rules.mk
-CC = mgcc
-CFLAGS = -g -Wall
-LDFLAGS = -L./ -lfrescan
+LDFLAGS += -L$(FNA_PATH)/lib -lfrescan -L$(FOSA_PATH)/lib -lfosa_$(PLATFORM) -lm
SRCS := $(wildcard *.c)
OBJS := $(patsubst %.c,%.o,$(wildcard *.c))
HDRS := $(wildcard *.h)
-frescan: $(OBJS)
- @exec echo -e "\n>> Generating libfrescan.a.. [OK]";
+libfrescan.a: $(OBJS)
+ @exec echo -e "\n>> Building libfrescan.a:";
ar -rc libfrescan.a *.o
+ @mv libfrescan.a $(FNA_PATH)/lib
+ @exec echo ">> end libfrescan.a [OK]"
%.o: %.c $(SRCS) $(HDRS)
@$(CC) $(CFLAGS) -c $< # 1> /dev/null
-%.exe: %.c
- @exec echo -e "\n>> Building $@: ";
- @if [ -f $< ]; \
- then \
- $(CC) $(CFLAGS) $< $(LDFLAGS) -o $@; \
- fi;
- @exec echo ">> End Building $@";
#ifndef _MARTE_FRESCAN_CONFIG_H_
#define _MARTE_FRESCAN_CONFIG_H_
-#include <signal.h> // SIGRTMIN
+#include "fosa_threads_and_signals.h" // FOSA_SIGNAL_MIN
#include <sys/kernel.h> // kernel_enter_critic_section
#define FRESCAN_MX_REPL_OPS 100
#define FRESCAN_BROADCAST_ADDR 0xF
#define FRESCAN_MX_IDS 255
#define FRESCAN_MX_PRIOS 32
-#define FRESCAN_REPL_SIGNAL_NUM SIGRTMIN + 5 // real-time signal
+#define FRESCAN_REPL_SIGNAL_NUM FOSA_SIGNAL_MIN + 10 // real-time signal
#define FRESCAN_BACKGROUND_PRIO 0
#define FRESCAN_MX_REPLY_OBJECTS 40
+#define FRESCAN_REPL_THREAD_PRIO 60
#define FRESCAN_MLOCK_T unsigned
#define FRESCAN_CREATE_LOCK(l)
#include <stdint.h> // uint32_t
#include <semaphore.h> // sem_t
#include <time.h> // struct timespec, timer_t
-#include <pthread.h> // pthread_t
+#include "fosa_threads_and_signals.h" // fosa_thread_id_t
#include <misc/linux_list.h> // struct list_head
#include <misc/freelist.h> // freelist_t
FRESCAN_MLOCK_T lock;
frescan_node_t local_node;
int fd;
- pthread_t repl_thread_id;
+ fosa_thread_id_t repl_thread_id;
frescan_queues_t queues;
frescan_packet_t *last_packet;
frescan_prio_t last_packet_prio;
int frescan_replenishments_init(frescan_network_t net)
{
int ret;
- sigset_t set;
- struct sigaction action;
+ fosa_signal_t signal_set[1];
+ fosa_thread_attr_t attr;
ret = frescan_repl_op_init();
if (ret != 0) {
return ret;
}
- sigemptyset(&set);
- sigaddset(&set, FRESCAN_REPL_SIGNAL_NUM);
+ signal_set[0] = FRESCAN_REPL_SIGNAL_NUM;
+
+ ret = fosa_set_accepted_signals(signal_set, 1);
+ if (ret != 0) {
+ ERROR("could not set the repl signal\n");
+ return ret;
+ }
+
+ // create the replenishment thread
- ret = pthread_sigmask(SIG_BLOCK, &set, NULL);
+ ret = fosa_thread_attr_init(&attr);
if (ret != 0) {
- ERROR("could not put the signal mask for replenishments\n");
+ ERROR("could not init thread attributes\n");
return ret;
}
- // the following is unnecesary in MaRTE OS because all signals are RT
- action.sa_handler = SIG_DFL;
- sigemptyset(&action.sa_mask);
- action.sa_flags = SA_SIGINFO;
- ret = sigaction (FRESCAN_REPL_SIGNAL_NUM, &action, NULL);
+ ret = fosa_thread_attr_set_prio(&attr, FRESCAN_REPL_THREAD_PRIO);
if (ret != 0) {
- ERROR("could not set action for the repl signal\n");
+ ERROR("could not set repl thread prio %d\n",
+ FRESCAN_REPL_THREAD_PRIO);
return ret;
}
- // TODO: set the pthread attributes
- ret = pthread_create(&the_networks[net].repl_thread_id,
- NULL,
- frescan_repl_thread,
- (void *)(uint32_t)net);
+ ret = fosa_thread_create(&the_networks[net].repl_thread_id,
+ &attr,
+ frescan_repl_thread,
+ (void *)(uint32_t)net);
if (ret != 0) {
ERROR("could not create the replenishment thread\n");
return ret;
}
+ ret = fosa_thread_attr_destroy(&attr);
+ if (ret != 0) {
+ ERROR("could not destroy thread attributes\n");
+ return ret;
+ }
+
return 0;
}