#include "frsh_forb.h"
#include <frsh_resources.h>
-#ifdef FRSH_DISTRIBUTED_MODULE_SUPPORTED
+#if FRSH_DISTRIBUTED_MODULE_SUPPORTED
#include <frsh_distributed.h>
#endif
static void *alloc_executor_thread(void *arg)
{
- return (void*)forb_executor_run(&frsh_forb_global.alloc_executor);
+ return (void*)(uintptr_t)forb_executor_run(&frsh_forb_global.alloc_executor);
}
int frsh_init()
{
int ret;
+ struct forb_init_attr attr = {
+ .orb_id = "org.frescor.frsh_app"
+ };
- frsh_forb_global.orb = forb_init(NULL, NULL, "frsh");
+ frsh_forb_global.orb = forb_init(NULL, NULL, &attr);
if (!frsh_forb_global.orb) {
- if (errno) return errno;
- else return -1;
+ ret = errno;
+ goto err;
}
frsh_forb_global.fcb = forb_resolve_reference(frsh_forb_global.orb,
ret = forb_executor_init(&frsh_forb_global.alloc_executor);
if (ret) goto err;
- fra_registry_init(frsh_forb_global.orb, frsh_forb_global.fcb,
- &frsh_forb_global.alloc_executor);
+ ret = fra_registry_init(frsh_forb_global.orb, frsh_forb_global.fcb,
+ &frsh_forb_global.alloc_executor);
+ if (ret) goto err;
#ifdef CONFIG_AQUOSA
ret = aqcpu_fra_init();
if (ret) goto err;
#endif
-#ifdef FRSH_DISTRIBUTED_MODULE_SUPPORTED
+#if FRSH_DISTRIBUTED_MODULE_SUPPORTED
ret = frsh_distributed_init();
if (ret) goto err;
#endif
return 0;
err:
+ if (ret == -1) ret = errno;
return ret;
}
+void frsh_destroy()
+{
+ forb_destroy(frsh_forb_global.orb);
+
+ pthread_cancel(frsh_forb_global.alloc_executor_thread.pthread_id);
+ pthread_join(frsh_forb_global.alloc_executor_thread.pthread_id, NULL);
+
+ /* TODO: Destroy all FRAs etc. */
+}
+
+
+
bool frsh_config_is_admission_test_enabled()
{
return true;
}
+frsh_resource_id_t frsh_get_local_cpu_id(void)
+{
+ long int ret = FRSH_CPU_ID_DEFAULT;
+ if (getenv("FRSH_CPU_ID")) {
+ errno = 0; /* See strtol(1) */
+ ret = strtol(getenv("FRSH_CPU_ID"), NULL, 10);
+ if (errno != 0)
+ ret = FRSH_CPU_ID_DEFAULT;
+ }
+ return ret;
+}