]> rtime.felk.cvut.cz Git - frescor/frsh.git/commitdiff
Added initialization of resource schedulers in frsh_init()
authorMichal Sojka <sojkam1@fel.cvut.cz>
Sat, 25 Oct 2008 22:28:50 +0000 (00:28 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Sat, 25 Oct 2008 22:28:50 +0000 (00:28 +0200)
frsh_api/Makefile.omk
frsh_api/frsh_contract.c
frsh_api/frsh_core.c
frsh_api/frsh_forb.h
resources/dummy/Makefile.omk
resources/dummy/res_dummy.h

index 480352b7ee0eeae98a71e4ccdbbc0ab62465b074..56d41007dae4df1299ac7eb01aed7d327dd879d0 100644 (file)
@@ -1,6 +1,14 @@
-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
+
+
+
index bfb5a38c795d120c6672551c51202b1252d12001..2c6e7906584190d34b563aaff7466e7165a35ccd 100644 (file)
@@ -163,7 +163,7 @@ int frsh_contract_negotiate
        struct forb_env env;
        int ret;
        fres_contract_id_t id;
-       ret = fres_contract_broker_negotiate_contract(global.fcb,
+       ret = fres_contract_broker_negotiate_contract(frsh_forb_global.fcb,
                                                      *contract,
                                                      &id, &env);
        if (forb_exception_occured(&env)) {
index 0fef9f43ff43cc666c339459e5caea402d46901b..00dc27a4ab294cb2674e43b09dbe544b5f2d2cba 100644 (file)
@@ -2,21 +2,53 @@
 #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;
 }
 
index e54cdfa34ba62f90cf1ad82a0c3226132691e1af..08aa85a8e63b0368e0d52f248fdde47924190849 100644 (file)
@@ -1,12 +1,18 @@
 #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
index 58521c884c3b1e9dd980f924c778abc806af1cab..058955b2b3f6a7449f26c49a41d13617eb55f929 100644 (file)
@@ -1,3 +1,5 @@
+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
@@ -5,3 +7,5 @@ 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
index a699d5a7576143e520eff6996117e92dab48c5d6..2855838a96e02eb949d76dba1e5fdcc2d0d2706d 100644 (file)
@@ -1,7 +1,12 @@
 #ifndef RES_DUMMY_H
 #define RES_DUMMY_H
 
+#include <forb.h>
+#include <fcb.h>
+
 #define DUMMY_RESOURCE_TYPE FRSH_RT_PROCESSOR
 #define DUMMY_RESOURCE_ID   0
 
+int frs_dummy_init(forb_orb orb, fres_contract_broker fcb, forb_executor_t *executor);
+
 #endif