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)
/**
* @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.
*
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;
}
--- /dev/null
+/**
+ * @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;
+}
+
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;
-}
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;
-}