-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
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;
/// 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
#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)
#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;
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
+
void fres_thread_vres_destroy(fres_thread_vres_t *th_vres);
-
#endif
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
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; \
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;
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);
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;
}
/* TODO: Reference counting */
basic = fres_contract_get_basic(vres->perceived);
-
if (!basic) return FRSH_ERR_NOT_INITIALIZED;
if (budget)
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
#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
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);
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;
}
(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:
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;
}
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;
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);
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
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
*/
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)
{
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;
wp.vres = vres;
wp.stopper = &stopper;
- if (!attr) {
- /* FIXME: Probably "attr = &<something>" is needed here! */
- pthread_attr_init(attr);
- }
-
pthread_attr_getschedparam(attr, ¶m);
p = param.sched_priority;
printf("priority = %d\n", p);