]> rtime.felk.cvut.cz Git - frescor/frsh.git/commitdiff
Fixes of AQuoSA resource manager and build system.
authorDario Faggioli <faggioli@gandalf.sssup.it>
Tue, 24 Mar 2009 08:14:30 +0000 (09:14 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 24 Mar 2009 08:38:47 +0000 (09:38 +0100)
Some glaring typos and bugs were in place becaouse of some weired mess
in branches and repositories... Now they are fixed.

Also, something in the OMK was not correct. In fact the path of the
AQuoSA components was hard-coded and not parametrized in AQUOSA_PATH.

Signed-off-by: Tommaso Cucinotta
Signed-off-by: Dario Faggioli
Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>
13 files changed:
demo/dcamera/Makefile.omk
fres/contract/fres_blocks.idl
fres/contract/idl_native.h
fres/resalloc/fres_vres.h
frsh_api/Makefile.omk
frsh_api/frsh_opaque_types.h
frsh_api/frsh_sharedobj.c
frsh_api/frsh_vres.c
resources/cpu_aquosa/lib/Makefile.omk
resources/cpu_aquosa/lib/frsh_aqcpu.c
resources/cpu_aquosa/mngr/Makefile.omk
resources/cpu_aquosa/tests/Makefile.omk
resources/cpucg/lib/frsh_cpucg.c

index b9e98c844a7884608c9a37643816499dfda60a77..add8ee74c37ab169dbc6498ebd9a3a93008179d7 100644 (file)
@@ -1,4 +1,4 @@
-LDFLAGS+= -L/usr/X11R6/lib 
+LDFLAGS+= -L/usr/X11R6/lib -L$(AQUOSA_ROOT)/lib -lqreslib -lqsuplib
 C_INCLUDE_PATH = -I/usr/X11R6/include
 GLUT_LIBS = glut GL GLU 
 FRSH_LIBS = frsh 
index b15f0cf6e83e01f9ae2d24cf9da172fe3b4c9da5..52ecd9cdf7e0ac8baed9ece544ad0023f647befe 100644 (file)
@@ -98,39 +98,12 @@ enum frsh_granularity_t {
 typedef long frsh_signal_t;
 typedef long frsh_signal_info_t;
 
-typedef struct frsh_memory_area_data {
-       long size;
-       long area;
-} frsh_memory_area_data_t;
-
-typedef struct frsh_memory_areas {
-    long size;
-    frsh_memory_area_data_t memory_areas[255];
-    // FIXME: It will be better to use sequence<frsh_memory_area_data_t> memory_areas;
-} frsh_memory_areas_t;
-
-typedef struct frsh_csect {
-       // FIXME: Are all these fields needed for negotioation? I
-       // guess that at least areas and storage are not. A possible
-       // solution would be to add a new block
-       // (e.g. frsh_csect_runtime) which will not be sent for
-       // negotiation and will only be used localy by the
-       // application. This would require some changes in
-       // frsh_contract_negotiate(). Note that this is the same
-       // problem as with signals in timing_reqs.
+typedef struct frsh_csect_runtime {
        long op_kind;
-       long obj_handle;
+       char obj_label[65];
        fosa_rel_time_t wcet;
        fosa_rel_time_t blocking;
-       long op;
-       frsh_memory_areas_t areas;
-       frsh_memory_areas_t storage;
-} frsh_csect_t;
-
-typedef struct frsh_csects_group {
-       long size;
-       frsh_csect_t csects[255];
-} frsh_csects_group_t;
+} frsh_csect_runtime_t;
 
 module fres {
        native container_ptr;
@@ -173,8 +146,8 @@ module fres {
 
                /// Critical sections (for shared objects)
                struct csects {
-                       frsh_csects_group_t     sections;
-                       // FIXME: Use "sequence<frsh_csect_t>  sections;" or something similar.
+                       //frsh_csect_runtime_t  sections;
+                       sequence<frsh_csect_runtime>    sections;
                };
 
                /// Spare capacity
index e5f0c0f33e9f40478da3fab3d1fdf0c2bb7685eb..4ea653c18ede96e0dd9de62c7b5fdbef95b78dc8 100644 (file)
@@ -99,10 +99,9 @@ fosa_rel_time_t_deserialize(FORB_CDR_Codec *codec, struct timespec *ts)
 #define _frsh_granularity_t_defined 1
 #define _frsh_signal_t_defined 1
 #define _frsh_signal_info_t_defined 1
-#define _frsh_memory_area_data_t_defined 1
-#define _frsh_memory_areas_t_defined 1
-#define _frsh_csect_t_defined 1
-#define _frsh_csects_group_t_defined 1
+
+#define _frsh_csect_runtime_t_defined 1
+typedef FRSH_CSECT_RUNTIME_T_OPAQUE frsh_csect_runtime_t;
 
 #define frsh_resource_type_t_serialize(codec, val) CORBA_unsigned_long_serialize(codec, val)
 #define frsh_resource_type_t_deserialize(codec, val) CORBA_unsigned_long_deserialize(codec, val)
@@ -120,50 +119,10 @@ fosa_rel_time_t_deserialize(FORB_CDR_Codec *codec, struct timespec *ts)
 #define frsh_signal_info_t_deserialize(x,y) CORBA_long_deserialize((x),(y))
 
 
-
-  frsh_csect_op_kind_t op_kind;                \
-  frsh_sharedobj_label_t obj_label;    \
-  frsh_rel_time_t wcet;                        \
-  frsh_rel_time_t blocking;            \
-  frsh_csect_op_t op;                  \
-  frsh_memory_areas_t areas;           \
-
-static inline CORBA_boolean
-frsh_memory_area_data_t_serialize
-  (FORB_CDR_Codec *codec,
-   const frsh_memory_area_data_t *d)
-{
-       return CORBA_TRUE;
-}
-
-static inline CORBA_boolean
-frsh_memory_area_data_t_deserialize
-  (FORB_CDR_Codec *codec,
-   frsh_memory_area_data_t *d)
-{
-       return CORBA_TRUE;
-}
-
-static inline CORBA_boolean
-frsh_memory_areas_t_serialize
-  (FORB_CDR_Codec *codec,
-   const frsh_memory_areas_t *a)
-{
-       return CORBA_TRUE;
-}
-
-static inline CORBA_boolean
-frsh_memory_areas_t_deserialize
-  (FORB_CDR_Codec *codec,
-   frsh_memory_areas_t *a)
-{
-       return CORBA_TRUE;
-}
-
 static inline CORBA_boolean
-frsh_csect_t_serialize
+frsh_csect_runtime_t_serialize
   (FORB_CDR_Codec *codec,
-   const frsh_csect_t *c)
+   const frsh_csect_runtime_t *c)
 {
        CORBA_long op_kind;
        op_kind = c->op_kind;
@@ -175,67 +134,26 @@ frsh_csect_t_serialize
                return CORBA_FALSE;
        if (!fosa_rel_time_t_serialize(codec, &c->blocking))
                return CORBA_FALSE;
-       /**
-        * TODO:
-        *  since it is a function pointer, c->op is not considered..
-        */
-       if (!frsh_memory_areas_t_serialize(codec, &c->areas))
-               return CORBA_FALSE;
        return CORBA_TRUE;
 }
 
 static inline CORBA_boolean
-frsh_csect_t_deserialize
+frsh_csect_runtime_t_deserialize
   (FORB_CDR_Codec *codec,
-   frsh_csect_t *c)
+   frsh_csect_runtime_t *c)
 {
        CORBA_long op_kind;
        if (!CORBA_long_deserialize(codec, &op_kind))
                return CORBA_FALSE;
-       c->op_kind = op_kind;
+       c->op_kind = (frsh_csect_op_kind_t) op_kind;
        if (!CORBA_string_deserialize(codec, (CORBA_char**) &c->obj_label))
                return CORBA_FALSE;
        if (!fosa_rel_time_t_deserialize(codec, &c->wcet))
                return CORBA_FALSE;
        if (!fosa_rel_time_t_deserialize(codec, &c->blocking))
                return CORBA_FALSE;
-       /**
-        * TODO:
-        *  since it is a function pointer, c->op is not considered.
-        */
-       if (!frsh_memory_areas_t_deserialize(codec, &c->areas))
-               return CORBA_FALSE;
-       return CORBA_TRUE;
-}
-
-static inline CORBA_boolean
-frsh_csects_group_t_serialize
-  (FORB_CDR_Codec *codec,
-   const frsh_csects_group_t *g)
-{
-       int i;
-       CORBA_long size;
-       size = g->size;
-       if (!CORBA_long_serialize(codec, &size)) return CORBA_FALSE;
-       for (i = 0; i < g->size; i++)
-               if (!frsh_csect_t_serialize(codec, &g->csects[i]))
-                       return CORBA_FALSE;
-       return CORBA_TRUE;
-}
-
-static inline CORBA_boolean
-frsh_csects_group_t_deserialize
-  (FORB_CDR_Codec *codec,
-   frsh_csects_group_t *g)
-{
-       int i;
-       CORBA_long size;
-       if (!CORBA_long_deserialize(codec, &size)) return CORBA_FALSE;
-       g->size = size;
-       for (i = 0; i < g->size; i++)
-               if (!frsh_csect_t_deserialize(codec, &g->csects[i]))
-                       return CORBA_FALSE;
        return CORBA_TRUE;
 }
 
 #endif
+
index 1f64fb0d7f08a8bf0496c2540c8ca34efd6aa6ae..088ffc3be925b1c22405a0aabe303b0cbfa1ca76 100644 (file)
@@ -130,5 +130,4 @@ fres_thread_vres_t *fres_thread_vres_new
 
 void fres_thread_vres_destroy(fres_thread_vres_t *th_vres);
 
-
 #endif
index 55273c0cc8ad57a3d674d12a03e69791ffe9ac43..48fcfb33bf78f23d9c0c86f11adb3c39c63c11f4 100644 (file)
@@ -17,3 +17,6 @@ allocator-libs-$(CONFIG_RESOURCE_ITEM) += fra_item
 allocator-libs-$(CONFIG_FWP) += frsh_fwp fwp
 allocator-libs-$(CONFIG_AQUOSA) += frshaqcpu
 allocator-libs-$(CONFIG_CPUCG) += frshcpucg
+
+LOADLIBES += -L $(AQUOSA_ROOT)/lib
+LDFLAGS += -L $(AQUOSA_ROOT)/lib
index e778e5ca2ada6aec98e10dc4934e54c6e3a62ec7..114daaf18e22bc816c027b3eea10d46ff609a9c6 100644 (file)
@@ -112,18 +112,32 @@ struct fres_vres;
 
 typedef unsigned int FRSH_GROUP_ID_T_OPAQUE;
 
+
 /**
- * Critical section data
+ * Critical section runtime data
  * - comon parameters
  *     op_kind;     // kind of operation (READ or WRITE)
- *     obj_handle;  // handle to shared object
+ *     obj_label;   // label of the shared object
  *     wcet;        // Execution time
  *     blocking;    // Blocking time (execution time + protection overheads)
+ * 
+ **/
+#define FRSH_CSECT_RUNTIME_T_OPAQUE struct {   \
+  frsh_csect_op_kind_t op_kind;                        \
+  frsh_sharedobj_label_t obj_label;            \
+  frsh_rel_time_t wcet;                                \
+  frsh_rel_time_t blocking;                    \
+}
+
+/**
+ * Critical section data
+ * - runtime parameters
+ *    runtime;      //
  * - attributes used only for protected shared objects
  *     op;          // pointer to the operation
  * - attributes used only for protected write operations
  *     areas;       // memory areas to be protected
- * 
+ *
  **/
 #define FRSH_CSECT_T_OPAQUE struct {   \
   frsh_csect_op_kind_t op_kind;                \
index c3a4a4046070cd2071a156dc6ff53655daf47c06..9256c7fba195d729f7a2906d402b77f22c1aef03 100644 (file)
@@ -349,7 +349,7 @@ int frsh_contract_set_csects
    const frsh_csects_group_t *critical_sections)
 {
        fres_block_csects *c;
-       int i, ret;
+       int i, len, ret;
 
        if (!contract || !*contract || !critical_sections)
                return FRSH_ERR_BAD_ARGUMENT;
@@ -361,9 +361,14 @@ int frsh_contract_set_csects
        c = malloc(sizeof(*c));
        if (!c) return FOSA_ENOMEM;
 
-       c->sections.size = critical_sections->size;
-       for (i = 0; i < critical_sections->size; i++)
-               c->sections.csects[i] = critical_sections->csects[i];
+       len = critical_sections->size;
+       c->sections._length = len;
+       c->sections._maximum = len;
+       c->sections._buffer = CORBA_sequence_frsh_csect_runtime_allocbuf(len);
+       for (i = 0; i < len; i++)
+               memcpy(&c->sections._buffer[i],
+                      &critical_sections->csects[i],
+                      sizeof(c->sections._buffer[i]));
 
        fres_contract_del_csects(*contract);
        ret = fres_contract_add_csects(*contract, c);
@@ -388,9 +393,11 @@ int frsh_contract_get_csects
 
        c = fres_contract_get_csects(*contract);
 
-       critical_sections->size = c->sections.size;
-       for (i = 0; i < c->sections.size; i++)
-               critical_sections->csects[i] = c->sections.csects[i];
+       critical_sections->size = c->sections._length;
+       for (i = 0; i < critical_sections->size; i++)
+               memcpy(&critical_sections->csects[i],
+                      &c->sections._buffer[i],
+                      sizeof(critical_sections->csects[i]));
 
        return 0;
 }
index c1184a0ec4b2cebb687b9eeb11584fd95061755a..1389a8370937939eef90d8271b9a7482aaacad7c 100644 (file)
@@ -113,7 +113,6 @@ int frsh_vres_get_budget_and_period
 
        /* TODO: Reference counting */
        basic = fres_contract_get_basic(vres->perceived);
-
        if (!basic) return FRSH_ERR_NOT_INITIALIZED;
 
        if (budget)
index 834383c293c2446b905df679b5905e7a67665a82..2a12dc0fc3fda7413e90232ad248e17b9fc596f5 100644 (file)
@@ -1,7 +1,7 @@
 shared_LIBRARIES = frshaqcpu
-CFLAGS += -I /usr/local/aquosa/include
+CFLAGS += -I $(AQUOSA_ROOT)/include
+LOADLIBES += -L $(AQUOSA_ROOT)/lib
+LOADLIBES += -Xlinker -rpath -Xlinker $(AQUOSA_ROOT)/lib
 frshaqcpu_SOURCES += frsh_aqcpu.c aqcpu_contract.c aqcpu_fra.c 
 include_HEADERS += aqcpu_contract.h aqcpu_res.h
-frshaqcpu_LIBS += qreslib  
-#include_HEADERS +=$(wildcard aquosa/qresmod/*.h)
-#include_HEADERS +=$(wildcard aquosa/rresmod/*.h)
+frshaqcpu_LIBS += qreslib qsuplib
index 2acbc14e0eeaf5c18885de552436d5d64226b079..23aaebc8127a05b299826f1d6dfdc3b1c55c4759 100644 (file)
 #include <linux/unistd.h>
 #include <errno.h>
 #include <sys/types.h>
-#define _XOPEN_SOURCE 500
-#define __USE_UNIX98
+#ifndef _XOPEN_SOURCE
+#  define _XOPEN_SOURCE 500
+#endif
+#ifndef __USE_UNIX98
+#  define __USE_UNIX98
+#endif
 #include <pthread.h>
 #include <semaphore.h>
 #include <stdio.h>
 #include <aquosa/qres_lib.h>
 #include <aquosa/qsup_lib.h>
 
-/* local timepsec <-> usec utility macros */
-#include "timespec_usec_ops.h"
-
 
 /**
  * structure used to pass the new created thread (or better its wrapper) the
@@ -142,7 +143,6 @@ int frsh_thread_bind(const frsh_vres_id_t vres, const frsh_thread_id_t thread)
        int ret;
        qos_rv  qrv;
        qres_sid_t  sid =  *((qres_sid_t*)vres->priv);
-       fres_thread_vres_t *th;
 
        /*if (!aqcpu_is_initialized) {
                  return(FRSH_ERR_NOT_INITIALIZED);
@@ -336,7 +336,7 @@ int frsh_vres_get_job_usage
        rv = qres_get_curr_budget(sid, &curr_budget);
        if (rv != QOS_OK) return EINVAL;
 
-       *spent = frsh_usec_to_rel_time(q_params->Q - curr_budget);
+       *spent = frsh_usec_to_rel_time(q_params.Q - curr_budget);
 
        return 0;
 }
@@ -374,18 +374,19 @@ int frsh_feedback_set_spare
   (const frsh_contract_t *spare_contract)
 {
        int ret = 0;
-       frsh_vres_is_t vres_id;
+       frsh_vres_id_t vres_id;
        fres_block_basic *b;
+       qos_rv rv;
 
        if (!spare_contract || !*spare_contract)
                return FRSH_ERR_BAD_ARGUMENT;
 
-       ret = frsh_contract_negotiate(spare_contract, vres_id);
+       ret = frsh_contract_negotiate(spare_contract, &vres_id);
        if (ret) goto err;
 
-       b = fres_contract_get_basic(spare_contract);
+       b = fres_contract_get_basic(*spare_contract);
        if (!b) return EINVAL;
-       rv = qsup_reserve_spare(r2bw(b->budget, b->period));
+       rv = qsup_reserve_spare(r2bw(frsh_rel_time_to_usec(b->budget), frsh_rel_time_to_usec(b->period)));
        if (rv != QOS_OK) return EINVAL;
 
 err:
@@ -406,7 +407,7 @@ int frsh_feedback_get_desired_budget
        rv = qres_get_params(sid, &q_params);
        if (rv != QOS_OK) return EINVAL;
 
-       *p_budget_out = frsh_usec_to_rel_time(q_params->Q);
+       *p_budget_out = frsh_usec_to_rel_time(q_params.Q);
 
        return 0;
 }
@@ -425,7 +426,7 @@ int frsh_feedback_set_desired_budget
        rv = qres_get_params(sid, &q_params);
        if (rv != QOS_OK) return EINVAL;
 
-       q_params->Q = frsh_rel_time_to_usec(*p_budget_in);
+       q_params.Q = frsh_rel_time_to_usec(*p_budget_in);
 
        rv = qres_set_params(sid, &q_params);
        if (rv != QOS_OK) return EINVAL;
@@ -444,7 +445,7 @@ int frsh_feedback_get_actual_budget
        if (!budget)
                return FRSH_ERR_BAD_ARGUMENT;
 
-       rv_qres_get_appr_budget(sid, &appr_budget);
+       rv = qres_get_appr_budget(sid, &appr_budget);
        if (rv != QOS_OK) return EINVAL;
 
        *budget = frsh_usec_to_rel_time(appr_budget);
index b7130f8f76e1daa4b33f7ecea018e73c950ee1f8..b1e7840bc86096b74b1ffd778764baf70d0d5c43 100644 (file)
@@ -1,4 +1,5 @@
 bin_PROGRAMS = aqcpumngr
 aqcpumngr_SOURCES = aqcpu_mngr.c
+LOADLIBES += -L $(AQUOSA_ROOT)/lib -lqreslib -lqsuplib
 aqcpumngr_LIBS = frm forb contract fosa rt ulut fcb_client
 lib_LOADLIBES+= frsh
index d6c5462b559592b02e864786237e9370056c092e..56d2fec47de250363cfea588e415c00d6cd4ac1f 100644 (file)
@@ -1,4 +1,5 @@
 test_PROGRAMS = aqcputest
 aqcputest_SOURCES = aqcputest.c
+LOADLIBES += -L $(AQUOSA_ROOT)/lib -lqreslib -lqsuplib
 #aqcpumngr_LIBS = frm forb contract fosa rt ulut fcb_client
 lib_LOADLIBES += pthread rt frshaqcpu frsh qreslib
index 48edbcc2f96f32495e220a600d98c490476156f4..c49f18c05a7d58a1d4b8a98bfd15a303598ff857 100644 (file)
@@ -277,7 +277,7 @@ static void* wrapper_pthread(void *arg)
  */
 int frsh_thread_create_and_bind(const frsh_vres_id_t vres,
        frsh_thread_id_t *thread,
-       frsh_thread_attr_t *attr,
+       frsh_thread_attr_t *thread_attr,
        frsh_thread_code_t thread_code,
        void *arg)
 {
@@ -285,18 +285,12 @@ int frsh_thread_create_and_bind(const frsh_vres_id_t vres,
        int rv;
        sem_t stopper;
        struct sched_param param;
-       int p;
+       int p = 0;
 
        sem_init(&stopper, 0, 0);
        
-       /* check for framework initialization and arguments */
-       /*if (!frsh_initialized)
-               PERROR_AND_RETURN(FRSH_ERR_NOT_INITIALIZED,
-               "can't proceed before initializing FRSH with 'frsh_init()'!");
-       if ((thread == NULL) || (thread_code == NULL))
-               PERROR_AND_RETURN(FRSH_ERR_BAD_ARGUMENT,
-               "can't create a thread with NULL thread_core or return it in a NULL thread");
-       */
+       if (!thread || !thread_code || !thread_attr)
+               return FRSH_ERR_BAD_ARGUMENT;
 
        wp.parent_thread_id = fosa_thread_self();
        wp.thread_id = thread;  
@@ -305,11 +299,6 @@ int frsh_thread_create_and_bind(const frsh_vres_id_t vres,
        wp.vres = vres;
        wp.stopper = &stopper;
 
-       if (!attr) {
-               /* FIXME: Probably "attr = &<something>" is needed here! */
-               pthread_attr_init(attr);
-       }
-
        pthread_attr_getschedparam(attr, &param);
        p = param.sched_priority;
        printf("priority = %d\n", p);