-SUNBDIRS = tests
+SUBDIRS = tests
shared_LIBRARIES = frsh
frsh_SOURCES = frsh_contract.c frsh_distributed.c frsh_core.c frsh_error.c
include_HEADERS = frsh_opaque_types.h
-frsh_LIBS+= fna fcb_client forb contract frs ulut fosa
+frsh_LIBS = fna fcb_client forb contract frs ulut fosa $(scheduler-libs-y)
+
+config_include_HEADERS = frsh_resources.h
+frsh_resources_DEFINES = CONFIG_RESOURCE_DUMMY CONFIG_FWP
+
+scheduler-libs-$(CONFIG_RESOURCE_DUMMY) := frs_dummy
+
+
+
#include <fcb.h>
#include <forb.h>
#include "frsh_forb.h"
+#include <frsh_resources.h>
+
+#ifdef CONFIG_RESOURCE_DUMMY
+#include <res_dummy.h>
+#endif
+
+struct frsh_forb frsh_forb_global;
+
+static void *sch_executor_thread(void *arg)
+{
+ return (void*)forb_executor_run(&frsh_forb_global.sch_executor);
+}
-struct frsh_forb global;
int frsh_init()
{
- global.orb = forb_init(NULL, NULL, "frsh");
- if (!global.orb) {
+ int ret;
+
+ frsh_forb_global.orb = forb_init(NULL, NULL, "frsh");
+ if (!frsh_forb_global.orb) {
if (errno) return errno;
else return -1;
}
- global.fcb = forb_resolve_reference(global.orb,
+ frsh_forb_global.fcb = forb_resolve_reference(frsh_forb_global.orb,
fres_contract_broker_reg_name);
- if (!global.fcb) return FRES_ERR_FCB_NOT_RUNNING;
+ if (!frsh_forb_global.fcb) {
+ ret = FRES_ERR_FCB_NOT_RUNNING;
+ goto err;
+ }
+
+ /* Initialize resource schedulers */
+ ret = forb_executor_init(&frsh_forb_global.sch_executor);
+ if (ret) goto err;
+
+#ifdef CONFIG_RESOURCE_DUMMY
+ ret = frs_dummy_init(frsh_forb_global.orb, frsh_forb_global.fcb,
+ &frsh_forb_global.sch_executor);
+ if (ret) goto err;
+#endif
+
+ /* Run resource schedulers */
+ fosa_thread_create(&frsh_forb_global.sch_executor_thread, NULL,
+ sch_executor_thread, NULL);
return 0;
+err:
+ return ret;
}
#ifndef FRSH_FORB_H
#define FRSH_FORB_H
+#include <forb.h>
+#include <fcb.h>
+#include <fosa.h>
+
+/** Global FRSH_FORB variables */
struct frsh_forb {
- forb_orb orb;
- fres_contract_broker fcb;
+ forb_orb orb; /**< ORB used to communicate with contract broker */
+ fres_contract_broker fcb; /**< Contract broker object referemce */
+ forb_executor_t sch_executor; /**< Executor to execute schedulers */
+ fosa_thread_id_t sch_executor_thread; /**< Thread to run @a sch_executor */
};
-extern struct frsh_forb global;
-
+extern struct frsh_forb frsh_forb_global;
#endif
+default_CONFIG = CONFIG_RESOURCE_DUMMY=y
+
bin_PROGRAMS = frm_dummy
frm_dummy_SOURCES = frm_dummy.c
frm_dummy_LIBS = frm forb contract fosa rt ulut fcb_client
shared_LIBRARIES = frs_dummy
frs_dummy_SOURCES = frs_dummy.c
frs_dummy_LIBS = frs
+
+include_HEADERS = res_dummy.h