+/**************************************************************************/
+/* ---------------------------------------------------------------------- */
+/* Copyright (C) 2006 - 2008 FRESCOR consortium partners: */
+/* */
+/* Universidad de Cantabria, SPAIN */
+/* University of York, UK */
+/* Scuola Superiore Sant'Anna, ITALY */
+/* Kaiserslautern University, GERMANY */
+/* Univ. Politécnica Valencia, SPAIN */
+/* Czech Technical University in Prague, CZECH REPUBLIC */
+/* ENEA SWEDEN */
+/* Thales Communication S.A. FRANCE */
+/* Visual Tools S.A. SPAIN */
+/* Rapita Systems Ltd UK */
+/* Evidence ITALY */
+/* */
+/* See http://www.frescor.org for a link to partners' websites */
+/* */
+/* FRESCOR project (FP6/2005/IST/5-034026) is funded */
+/* in part by the European Union Sixth Framework Programme */
+/* The European Union is not liable of any use that may be */
+/* made of this code. */
+/* */
+/* */
+/* This file is part of FRSH (FRescor ScHeduler) */
+/* */
+/* FRSH is free software; you can redistribute it and/or modify it */
+/* under terms of the GNU General Public License as published by the */
+/* Free Software Foundation; either version 2, or (at your option) any */
+/* later version. FRSH is distributed in the hope that it will be */
+/* useful, but WITHOUT ANY WARRANTY; without even the implied warranty */
+/* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
+/* General Public License for more details. You should have received a */
+/* copy of the GNU General Public License along with FRSH; see file */
+/* COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, */
+/* Cambridge, MA 02139, USA. */
+/* */
+/* As a special exception, including FRSH header files in a file, */
+/* instantiating FRSH generics or templates, or linking other files */
+/* with FRSH objects to produce an executable application, does not */
+/* by itself cause the resulting executable application to be covered */
+/* by the GNU General Public License. This exception does not */
+/* however invalidate any other reasons why the executable file might be */
+/* covered by the GNU Public License. */
+/**************************************************************************/
+
+/**
+ * @file frsh_core.c
+ * @author Michal Sojka <sojkam1@fel.cvut.cz>
+ * Dario Faggioli <faggioli@gandalf.sssup.it>
+ * @date Wed Feb 18 16:04:22 2009
+ *
+ * @brief Core of FRSH_FORB framework
+ *
+ */
+
+
#include <frsh_core.h>
#include <fcb.h>
#include <forb.h>
+#include <fra_generic.h>
#include "frsh_forb.h"
#include <frsh_resources.h>
-#ifdef FRSH_DISTRIBUTED_MODULE_SUPPORTED
+#if FRSH_DISTRIBUTED_MODULE_SUPPORTED
#include <frsh_distributed.h>
#endif
+#ifdef CONFIG_AQUOSA
+#include <aqcpu_res.h>
+#endif
+
+#ifdef CONFIG_CPUCG
+#include <cpucg_res.h>
+#endif
+
+#ifdef CONFIG_DISKBFQ
+#include <diskbfq_res.h>
+#endif
+
#ifdef CONFIG_RESOURCE_DUMMY
#include <res_dummy.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,
/* Initialize resource allocators */
ret = forb_executor_init(&frsh_forb_global.alloc_executor);
if (ret) goto err;
+
+ 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 CONFIG_CPUCG
+ ret = cpucg_fra_init();
+ if (ret) goto err;
+#endif
#ifdef CONFIG_RESOURCE_DUMMY
- ret = fra_dummy_init(frsh_forb_global.orb, frsh_forb_global.fcb,
- &frsh_forb_global.alloc_executor);
+ ret = fra_dummy_init();
if (ret) goto err;
#endif
-#ifdef FRSH_DISTRIBUTED_MODULE_SUPPORTED
+#ifdef CONFIG_DISKBFQ
+ ret = diskbfq_fra_init();
+ if (ret) goto err;
+#endif
+
+#if FRSH_DISTRIBUTED_MODULE_SUPPORTED
ret = frsh_distributed_init();
if (ret) goto err;
#endif
#ifdef CONFIG_RESOURCE_ITEM
- ret = fra_item_init(frsh_forb_global.orb, frsh_forb_global.fcb,
- &frsh_forb_global.alloc_executor);
+ ret = fra_item_init();
if (ret) goto err;
#endif
/* Run resource allocators */
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;
+}