]> rtime.felk.cvut.cz Git - frescor/frsh.git/commitdiff
Bugfix and FRSH thread function generalization.
authorDario Faggioli <faggioli@gandalf.sssup.it>
Sat, 14 Feb 2009 10:41:40 +0000 (11:41 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Sun, 1 Mar 2009 17:19:23 +0000 (18:19 +0100)
Some bugs introduced in my previous commit have been fixed. More
important, some functions related to thread creation and management in
FRSH have been moved from resource managers to frsh_forb.

These functions are, for example frsh_thread_create_in_background, or
frsh_{set, get}_service_thread_data. This avoid code duplication inside
resource managers.

Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>
frsh_api/Makefile.omk
frsh_api/frsh_contract.c
frsh_api/frsh_thread.c [new file with mode: 0644]
resources/cpu_aquosa/lib/frsh_aqcpu.c
resources/cpucg/lib/frsh_cpucg.c

index 4f0c176438a767567c1484bad638e8d7a762fc90..66e1c541e47b3cd69c184d21dae73f543958b9b9 100644 (file)
@@ -1,7 +1,7 @@
 SUBDIRS = tests
 
 shared_LIBRARIES = frsh
-frsh_SOURCES = frsh_contract.c frsh_distributed.c frsh_core.c frsh_error.c
+frsh_SOURCES = frsh_contract.c frsh_distributed.c frsh_core.c frsh_error.c frsh_thread.c
 include_HEADERS = frsh_opaque_types.h frsh_forb.h
 frsh_LIBS = fna fcb_client forb contract fra ulut fosa $(allocator-libs-y)
 
index bdfbb99464014deb7fec35e668f20366f9fb9dc0..2bee44f46ff78a1ec4cb055f1c96444db6cac474 100644 (file)
@@ -47,6 +47,7 @@
 /**
  * @file   frsh_contract.c
  * @author Michal Sojka <sojkam1@fel.cvut.cz>
+ *        Dario Faggioli <faggioli@gandalf.sssup.it>
  * 
  * @brief  Implementation of FRSH contract API on top of FRES contracts.
  * 
@@ -316,17 +317,6 @@ int frsh_contract_get_timing_reqs
        if (deadline)
                *deadline = t->deadline;
 
-       /*if (budget_overrun_signal) {
-               *budget_overrun_signal = t->budget_overrun_signal;
-               if (budget_overrun_siginfo)
-                       *budget_overrun_siginfo  = t->budget_overrun_siginfo;
-       }
-       if (deadline_miss_signal) {
-               *deadline_miss_signal  = t->deadline_miss_signal;
-               if (deadline_miss_siginfo)
-                       *deadline_miss_siginfo = t->deadline_miss_siginfo;
-       }*/
-
        return 0;
 }
 
diff --git a/frsh_api/frsh_thread.c b/frsh_api/frsh_thread.c
new file mode 100644 (file)
index 0000000..0ceaecd
--- /dev/null
@@ -0,0 +1,76 @@
+/**
+ * @file   frsh_thread.c
+ * @author Dario Faggioli <faggioli@gandalf.sssup.it>
+ *
+ * @brief  FRSH core thread related functions not implamented in managers..
+ *
+ *
+ */
+#include <fres_contract.h>
+#include <fres_contract_idl.h>
+#include <frsh_core.h>
+#include <frsh_error.h>
+#include <fres_blocks.h>
+#include <string.h>
+#include <fcb.h>
+#include "frsh_forb.h"
+#include <fra_generic.h>
+
+int frsh_thread_create_in_background
+  (frsh_thread_code_t thread_code,
+   const void *thread_arg,
+   const frsh_contract_label_t contract_label,
+   frsh_thread_attr_t *attr,
+   frsh_thread_id_t *thread,
+   frsh_vres_id_t *vres_id)
+{
+       frsh_contract_t contract;
+       fosa_rel_time_t zero_msec = fosa_msec_to_rel_time(0);
+       int rv = 0;
+
+       /* Background contract creation and negotiation */
+       frsh_contract_init(&contract);
+       frsh_contract_set_resource_and_label(&contract,
+                                            FRSH_RT_PROCESSOR,
+                                            contract_label,
+                                            NULL);
+       frsh_contract_set_basic_params(&contract,
+                                      &zero_msec,
+                                      &zero_msec,
+                                      FRSH_WT_INDETERMINATE,
+                                      FRSH_CT_BACKGROUND);
+
+       /* It will be accepted: we are asking for 0 budget over 0 period */
+       rv = frsh_contract_negotiate(&contract, vres_id);
+       if (rv !=0) goto error;
+
+       rv = fosa_thread_create(thread, attr, thread_code, thread_arg);
+       if (rv != 0) goto error;
+
+       return 0;
+error:
+       return rv;
+}
+
+int frsh_thread_get_vres_id
+  (const frsh_thread_id_t thread,
+   frsh_vres_id_t *vres_id)
+{
+       return FRSH_ERR_NOT_IMPLEMENTED;
+}
+
+int frsh_service_thread_set_data
+  (const struct timespec *budget,
+   const struct timespec *period,
+   bool *accepted)
+{
+       return FRSH_ERR_NOT_IMPLEMENTED; 
+}
+
+int frsh_service_thread_get_data
+  (frsh_rel_time_t *budget,
+   frsh_rel_time_t *period)
+{
+       return FRSH_ERR_NOT_IMPLEMENTED; 
+}
+
index 80def55e40420d1c874c0826f409abaa2f240a22..b76960907be76677275b296ad112dac91a792054 100644 (file)
@@ -287,132 +287,3 @@ int frsh_thread_create_and_bind(const frsh_vres_id_t vres,
        return (wp.errcode);
 }
 
-/*
- * API call for 'frsh_thread_create_in_background()', as said creates a
- * background contract and negotiate it (we know they're always accepted
- * but we need to get the service thread account fo the new vres), then
- * create the new thread, exactly as seen in 'frsh_thread_create_and_bind()'
- * and wait for its acknowledgment
- *
- * possible return values:
- *  FRSH_NO_ERROR
- *  FRSH_ERR_NOT_INITIALIZED
- *  FRSH_ERR_BAD_ARGUMENT (NULL thread_id, thread_code, contract_label or vres_id)
- *  FRSH_ERR_TOO_MANY_VRES(*)
- *  FRSH_ERR_CONTRACT_ID_ALREADY_EXISTS(*)
- *  FRSH_ERR_CONTRACT_REJECTED(*)
- *  whatever 'fosa_thread_create()' returns
- *  FRSH_ERR_INTERNAL_ERROR(*) (something wrong with AQuoSA or with the service thread internal data structures)
- *  FRSH_ERR_INTERNAL_ERROR (something wrong in signal handling)
- */
-int frsh_thread_create_in_background(frsh_thread_code_t thread_code,
-       const void *thread_arg,
-       const frsh_contract_label_t contract_label,
-       frsh_thread_attr_t *attr,
-       frsh_thread_id_t *thread_id,
-       frsh_vres_id_t *vres_id)
-{
-       return FRSH_ERR_NOT_IMPLEMENTED; 
-}
-
-/*
- * frsh_thread_get_vres_id(), get the id vres of a vres bound to a thread
- *
- * Asks the service thread for the id of a particular vres, knowing the thread
- * bound to it.
- *
- * The code below only prepares the message, send it and wait for the answer,
- * for details on the implementation check 'get_thread_vres_id()' in the
- * frsh_service_th.c source file
- * possible return values:
- *  FRSH_NO_ERROR
- *  FRSH_ERR_NOT_INITIALIZED
- *  FRSH_BAD_ARGUMENT(*) (invalid thread or NULL vres)
- *  FRSH_ERR_NOT_BOUND(*) (-IMPOSSIBLE- thread not bound)
- *  FRSH_ERR_INTERNAL_ERROR(*) (something wrong with AQuoSA or with the service thread internal data structures)
- *  FRSH_ERR_INVALID_SCHEDULER_REPLY (error in communication with the service thread)
- */
-int frsh_thread_get_vres_id(const frsh_thread_id_t thread,
-       frsh_vres_id_t *vres_id)
-{
-       return FRSH_ERR_NOT_IMPLEMENTED; 
-}
-
-/*
- * frsh_thread_self(), get the thread and vres id of the caller
- *
- * Simply returns the thread id of the caller and the vres id to which
- * (if any) it's bound.
- *
- * Note that the thread id is always returned, while the retrieval of the vres
- * id can be skipped passing a NULL pointer as vres_self argument.
- *
- * Nota also that the thread id could be retieved via a simple FOSA call, while
- * for the vres id we can only ask it to the service thread.
- *
- * possible return values:
- *  FRSH_NO_ERROR
- *  FRSH_ERR_NOT_INITIALIZED
- *  FRSH_ERR_BAD_ARGUMENT (NULL thread_self)
- *  all that 'frsh_thread_get_vres_id()' returns (FRSH_ERR_NOT_BOUND)
- *  FRSH_ERR_INTERNAL_ERROR(*) (something wrong with AQuoSA or with the service thread internal data structures)
- *  FRSH_ERR_INVALID_SCHEDULER_REPLY (error in communication with the service thread)
- */
-int frsh_thread_self(frsh_thread_id_t *thread_self, frsh_vres_id_t *vres_self)
-{
-       return FRSH_ERR_NOT_IMPLEMENTED; 
-}
-
-
-
-/////////////////////////////////////////////
-// S E R V I C E   T H R E A D   T U N I N G
-/////////////////////////////////////////////
-
-/*
- * frsh_service_thread_set_data(), adapt timing guarantees for the service thread
- *
- * Modifies the execution period and budget of the service thread from the
- * defaults configured for it and negotiated during service thread
- * initialization.
- *
- * Here we only request the operation sending a message to the service thread
- * itself (and waiting for the answer), check the service thread main code
- * in the frsh_service_th.c source file for the implementation details.
- *
- * possible return values:
- *  FRSH_NO_ERROR
- *  FRSH_ERR_NOT_INITIALIZED
- *  FRSH_ERR_BAD_ARGUMENT (NULL or inconsistent budget or period)
- *  FRSH_ERR_CONTRACT_REJECTED(*)
- *  FRSH_ERR_INTERNAL_ERROR(*) (something wrong with AQuoSA or with the service thread internal data structures)
- *  FRSH_ERR_INVALID_SCHEDULER_REPLY (error in communication with the service thread) *
- */
-int frsh_service_thread_set_data(const struct timespec *budget,
-       const struct timespec *period,
-       bool *accepted)
-{
-       return FRSH_ERR_NOT_IMPLEMENTED; 
-}
-
-/*
- * frsh_service_thread_get_data(), obtain timing guarantees for the service thread
- *
- * Obtains the actual execution period and budget of the service.
- *
- * Here we only request the operation sending a message to the service thread
- * itself (and waiting for the answer), check the service thread main code
- * in the frsh_service_th.c source file for the implementation details.
- *
- * possible return values:
- *  FRSH_NO_ERROR
- *  FRSH_ERR_NOT_INITIALIZED
- *  FRSH_ERR_BAD_ARGUMENT (NULL budget or period)
- *  FRSH_ERR_INTERNAL_ERROR(*) (something wrong with AQuoSA or with the service thread internal data structures)
- *  FRSH_ERR_INVALID_SCHEDULER_REPLY (error in communication with the service thread) *
- */
-int frsh_service_thread_get_data(frsh_rel_time_t *budget, frsh_rel_time_t *period)
-{
-
-       return FRSH_ERR_NOT_IMPLEMENTED; 
-}
index 1cf3f91123698bf490df7795be70649d7998ff9a..0257b800400ae76de90fad390735692016130d6c 100644 (file)
@@ -314,132 +314,3 @@ int frsh_thread_create_and_bind(const frsh_vres_id_t vres,
        return (wp.errcode);
 }
 
-/*
- * API call for 'frsh_thread_create_in_background()', as said creates a
- * background contract and negotiate it (we know they're always accepted
- * but we need to get the service thread account fo the new vres), then
- * create the new thread, exactly as seen in 'frsh_thread_create_and_bind()'
- * and wait for its acknowledgment
- *
- * possible return values:
- *  FRSH_NO_ERROR
- *  FRSH_ERR_NOT_INITIALIZED
- *  FRSH_ERR_BAD_ARGUMENT (NULL thread_id, thread_code, contract_label or vres_id)
- *  FRSH_ERR_TOO_MANY_VRES(*)
- *  FRSH_ERR_CONTRACT_ID_ALREADY_EXISTS(*)
- *  FRSH_ERR_CONTRACT_REJECTED(*)
- *  whatever 'fosa_thread_create()' returns
- *  FRSH_ERR_INTERNAL_ERROR(*) (something wrong with AQuoSA or with the service thread internal data structures)
- *  FRSH_ERR_INTERNAL_ERROR (something wrong in signal handling)
- */
-int frsh_thread_create_in_background(frsh_thread_code_t thread_code,
-       const void *thread_arg,
-       const frsh_contract_label_t contract_label,
-       frsh_thread_attr_t *attr,
-       frsh_thread_id_t *thread_id,
-       frsh_vres_id_t *vres_id)
-{
-       return FRSH_ERR_NOT_IMPLEMENTED; 
-}
-
-/*
- * frsh_thread_get_vres_id(), get the id vres of a vres bound to a thread
- *
- * Asks the service thread for the id of a particular vres, knowing the thread
- * bound to it.
- *
- * The code below only prepares the message, send it and wait for the answer,
- * for details on the implementation check 'get_thread_vres_id()' in the
- * frsh_service_th.c source file
- * possible return values:
- *  FRSH_NO_ERROR
- *  FRSH_ERR_NOT_INITIALIZED
- *  FRSH_BAD_ARGUMENT(*) (invalid thread or NULL vres)
- *  FRSH_ERR_NOT_BOUND(*) (-IMPOSSIBLE- thread not bound)
- *  FRSH_ERR_INTERNAL_ERROR(*) (something wrong with AQuoSA or with the service thread internal data structures)
- *  FRSH_ERR_INVALID_SCHEDULER_REPLY (error in communication with the service thread)
- */
-int frsh_thread_get_vres_id(const frsh_thread_id_t thread,
-       frsh_vres_id_t *vres_id)
-{
-       return FRSH_ERR_NOT_IMPLEMENTED; 
-}
-
-/*
- * frsh_thread_self(), get the thread and vres id of the caller
- *
- * Simply returns the thread id of the caller and the vres id to which
- * (if any) it's bound.
- *
- * Note that the thread id is always returned, while the retrieval of the vres
- * id can be skipped passing a NULL pointer as vres_self argument.
- *
- * Nota also that the thread id could be retieved via a simple FOSA call, while
- * for the vres id we can only ask it to the service thread.
- *
- * possible return values:
- *  FRSH_NO_ERROR
- *  FRSH_ERR_NOT_INITIALIZED
- *  FRSH_ERR_BAD_ARGUMENT (NULL thread_self)
- *  all that 'frsh_thread_get_vres_id()' returns (FRSH_ERR_NOT_BOUND)
- *  FRSH_ERR_INTERNAL_ERROR(*) (something wrong with AQuoSA or with the service thread internal data structures)
- *  FRSH_ERR_INVALID_SCHEDULER_REPLY (error in communication with the service thread)
- */
-int frsh_thread_self(frsh_thread_id_t *thread_self, frsh_vres_id_t *vres_self)
-{
-       return FRSH_ERR_NOT_IMPLEMENTED; 
-}
-
-
-
-/////////////////////////////////////////////
-// S E R V I C E   T H R E A D   T U N I N G
-/////////////////////////////////////////////
-
-/*
- * frsh_service_thread_set_data(), adapt timing guarantees for the service thread
- *
- * Modifies the execution period and budget of the service thread from the
- * defaults configured for it and negotiated during service thread
- * initialization.
- *
- * Here we only request the operation sending a message to the service thread
- * itself (and waiting for the answer), check the service thread main code
- * in the frsh_service_th.c source file for the implementation details.
- *
- * possible return values:
- *  FRSH_NO_ERROR
- *  FRSH_ERR_NOT_INITIALIZED
- *  FRSH_ERR_BAD_ARGUMENT (NULL or inconsistent budget or period)
- *  FRSH_ERR_CONTRACT_REJECTED(*)
- *  FRSH_ERR_INTERNAL_ERROR(*) (something wrong with AQuoSA or with the service thread internal data structures)
- *  FRSH_ERR_INVALID_SCHEDULER_REPLY (error in communication with the service thread) *
- */
-int frsh_service_thread_set_data(const struct timespec *budget,
-       const struct timespec *period,
-       bool *accepted)
-{
-       return FRSH_ERR_NOT_IMPLEMENTED; 
-}
-
-/*
- * frsh_service_thread_get_data(), obtain timing guarantees for the service thread
- *
- * Obtains the actual execution period and budget of the service.
- *
- * Here we only request the operation sending a message to the service thread
- * itself (and waiting for the answer), check the service thread main code
- * in the frsh_service_th.c source file for the implementation details.
- *
- * possible return values:
- *  FRSH_NO_ERROR
- *  FRSH_ERR_NOT_INITIALIZED
- *  FRSH_ERR_BAD_ARGUMENT (NULL budget or period)
- *  FRSH_ERR_INTERNAL_ERROR(*) (something wrong with AQuoSA or with the service thread internal data structures)
- *  FRSH_ERR_INVALID_SCHEDULER_REPLY (error in communication with the service thread) *
- */
-int frsh_service_thread_get_data(frsh_rel_time_t *budget, frsh_rel_time_t *period)
-{
-
-       return FRSH_ERR_NOT_IMPLEMENTED; 
-}