]> rtime.felk.cvut.cz Git - frescor/frsh.git/blobdiff - fres/resalloc/fra_generic.h
Fixed race condition in allocator registration
[frescor/frsh.git] / fres / resalloc / fra_generic.h
index 0a1c5bc2d1887c232a0952f702def69fca44f777..650e3df6630bef6715dcd1def280b235a3e700d6 100644 (file)
@@ -81,6 +81,8 @@ GAVL_CUST_NODE_INT_DEC(fres_vreses_nolock /* cust_prefix */,
 
 extern struct fres_vreses fres_vreses;
 
+struct fres_vres *
+fres_vreses_find_label(fres_block_label *label, fres_block_resource *res);
 
 /** Registry of all threads in an application that are bound to a VRES. */
 struct fres_threads_vres {
@@ -91,10 +93,10 @@ struct fres_threads_vres {
 GAVL_CUST_NODE_INT_DEC(fres_threads_vres_nolock        /* cust_prefix */,
                       struct fres_threads_vres /* cust_root_t */,
                       struct fres_thread_vres  /* cust_item_t */,
-                      fosa_thread_id_t         /* cust_key_t */,
+                      fres_thread_vres_key_t   /* cust_key_t */,
                       threads                  /* cust_root_node */,
                       node                     /* cust_item_node */,
-                      id                       /* cust_item_key */,
+                      thread_vres              /* cust_item_key */,
                       fres_thread_vres_cmp     /* cust_cmp_fnc */)
 
 extern struct fres_threads_vres fres_threads_vres;
@@ -179,6 +181,21 @@ struct fres_allocator {
        int (*apply_vres_changes)(fres_vres_t *vreses[], unsigned length, void *priv);
        /*@}*/
 
+       /** @name Feedback module support */
+       /*@{*/
+       int (*set_spare_bandwidth)(fres_vres_t *vres);
+       int (*get_desired_budget)(fres_vres_t *vres, frsh_rel_time_t *p_budget_out);
+       int (*set_desired_budget)(fres_vres_t *vres_id, frsh_rel_time_t *p_budget_in);
+       int (*get_actual_budget)(fres_vres_t *vres_id, frsh_rel_time_t *budget);
+       /*@}*/
+
+       int (*bind_thread)(fres_vres_t *vres, fosa_thread_id_t thread);
+       int (*unbind_thread)(fosa_thread_id_t thread);
+
+       int (*vres_get_job_usage)(const fres_vres_t *vres, frsh_rel_time_t *spent);
+       int (*vres_get_remaining_budget)(const fres_vres_t *vres, frsh_rel_time_t *budget);
+       int (*vres_get_usage)(const fres_vres_t *vres, frsh_rel_time_t *spent);
+
        void *priv;             /**< Pointer to allocator's private data */
 
        /**
@@ -192,18 +209,26 @@ fres_resource_allocator fra_new(forb_orb orb,
                                forb_executor_t *executor,
                                struct fres_allocator *allocator);
 
-void fra_registry_init(forb_orb                   orb,
-                      fres_contract_broker fcb,
-                      forb_executor_t     *executor);
+int fra_registry_init(forb_orb            orb,
+                     fres_contract_broker fcb,
+                     forb_executor_t      *executor);
 int fra_register(struct fres_allocator *allocator);
 int fra_activate(frsh_resource_type_t res_type,
                 frsh_resource_id_t   res_id);
+struct fres_allocator *fra_get(frsh_resource_type_t res_type,
+                              frsh_resource_id_t   res_id);
 
 fres_vres_t *fra_get_vres(fres_contract_id_t *id);
 
-int fra_insert_thread_vres(const fosa_thread_id_t *id, fres_vres_t *vres);
-int fra_delete_thread_vres(const fosa_thread_id_t *id);
-fres_thread_vres_t *fra_get_thread_vres(const fosa_thread_id_t *id);
-fres_vres_t *fra_get_vres_thread_vres(const fosa_thread_id_t *id);
+int fra_insert_thread_vres(const fosa_thread_id_t *id,
+                          int vres_type,
+                          fres_vres_t *vres);
+int fra_delete_thread_vres(const fosa_thread_id_t *id,
+                          int vres_type);
+fres_thread_vres_t *fra_get_thread_vres(const fosa_thread_id_t *id,
+                                       int vres_type);
+fres_vres_t *fra_get_vres_thread_vres(const fosa_thread_id_t *id,
+                                     int vres_type);
 
 #endif
+