struct res_mng {
gavl_node_t node;
struct res_key resource;
- fres_resource_manager rm;
- gavl_cust_root_field_t schedulers; /**< Registered schedulers for this resource (from multiple applications/nodes) */
+ fres_resource_manager rm; /**< Object reference of the resource manager */
+ gavl_cust_root_field_t schedulers; /**< Registered schedulers for this resource (from multiple applications/nodes) */
};
/**
- * Registered resource scheduler
+ * Resource scheduler registered in different nodes/applications
*/
struct res_sched {
gavl_node_t node;
resources /* cust_root_node */, \
node /* cust_item_node */, \
resource /* cust_item_key */, \
- res_key_cmp /* cust_cmp_fnc */)
+ res_key_cmp /* cust_cmp_fnc */);
GAVL_CUST_NODE_INT_IMP(fcb_resource /* cust_prefix */, \
struct fcb /* cust_root_t */, \
resources /* cust_root_node */, \
node /* cust_item_node */, \
resource /* cust_item_key */, \
- res_key_cmp /* cust_cmp_fnc */)
+ res_key_cmp /* cust_cmp_fnc */);
GAVL_CUST_NODE_INT_DEC(fcb_sched /* cust_prefix */, \
struct res_mng /* cust_root_t */, \
schedulers /* cust_root_node */, \
node /* cust_item_node */, \
app /* cust_item_key */, \
- fres_contract_id_cmp /* cust_cmp_fnc */)
+ fres_contract_id_cmp /* cust_cmp_fnc */);
GAVL_CUST_NODE_INT_IMP(fcb_sched /* cust_prefix */, \
struct res_mng /* cust_root_t */, \
schedulers /* cust_root_node */, \
node /* cust_item_node */, \
app /* cust_item_key */, \
- forb_server_id_cmp /* cust_cmp_fnc */)
+ forb_server_id_cmp /* cust_cmp_fnc */);
#define o2fcb(o) (struct fcb*)forb_instance_data(o)
forb_server_id app;
fres_contract_ptr contract_seq_buf;
fres_contract_ptr_seq contracts;
- fres_contract_ptr_seq *contracts_sched;
+ fres_contract_ptr_seq *schedulable_contracts;
fres_contract_id_seq ids;
res = fres_contract_get_resource(contract);
if (!res) {
ul_logerr("No resource specified\n");
- ret = -1;
+ ret = FRSH_ERR_RESOURCE_ID_INVALID;
goto err;
}
res_key.type = res->resource_type;
/* Commit contract */
ids._length = ids._maximum = 1;
ids._buffer = id;
- fres_resource_manager_commit_contracts(rm->rm, &ids, &contracts_sched, ev);
+ fres_resource_manager_commit_contracts(rm->rm, &ids, &schedulable_contracts, ev);
if (forb_exception_occured(ev)) {
goto err;
}
/* Create VRes */
- ret = fres_resource_scheduler_create_vreses(rs->rs, contracts_sched, ev);
- if (CORBA_sequence_get_release(contracts_sched)) forb_free(contracts_sched->_buffer);
- forb_free(contracts_sched);
+ ret = fres_resource_scheduler_change_vreses(rs->rs, schedulable_contracts, ev);
+ if (CORBA_sequence_get_release(schedulable_contracts)) {
+ int i;
+ for (i=0; i<schedulable_contracts->_length; i++) {
+ fres_contract_destroy(schedulable_contracts->_buffer[i]);
+ }
+ forb_free(schedulable_contracts->_buffer);
+ }
+ forb_free(schedulable_contracts);
if (forb_exception_occured(ev)) {
goto err;
}
return ret;
}
-CORBA_long register_manager(fres_contract_broker obj,
+CORBA_long register_resource(fres_contract_broker obj,
const frsh_resource_type_t restype,
const frsh_resource_id_t resid,
- const fres_resource_manager rm_obj,
+ const fres_resource_desc *desc,
CORBA_Environment *ev)
{
struct fcb *fcb = o2fcb(obj);
goto free_err;
}
}
- rm->rm = forb_object_duplicate(rm_obj);
+ rm->rm = forb_object_duplicate(desc->manager);
fcb_sched_init_root_field(rm);
ul_logmsg("Registering manager for resource %d.%d\n",
resource.id = resid;
rm = fcb_resource_find(fcb, &resource);
if (!rm) {
+ ul_logerr("No manager found for %d.%d. Unable to register the scheduler!\n",
+ restype, resid);
goto err;
}
rs = fcb_sched_find(rm, &server_id);
struct forb_fres_contract_broker_impl impl = {
.negotiate_contract = negotiate_contract,
- .register_manager = register_manager,
+ .register_resource = register_resource,
.register_scheduler = register_scheduler,
};
#include "../ressched/frs.idl"
module fres {
+
+ /** Description of a resource */
+ struct resource_desc {
+ /** Manager */
+ resource_manager manager;
+ };
interface contract_broker {
const string reg_name = "fcb";
/**
- * Registers a resource manager with the contract broker
+ * Registers a resource with the contract broker
*
* @param restype
* @param resid
- * @param rm_obj
+ * @param res_desc Description of the resource
*
* @return Zero on success, non-zero error code on error.
*/
- long register_manager(in frsh_resource_type_t restype,
- in frsh_resource_id_t resid,
- in resource_manager rm_obj);
+ long register_resource(in frsh_resource_type_t restype,
+ in frsh_resource_id_t resid,
+ in resource_desc res_desc);
/**
* Registers a resource scheduler with the contract broker
(*my_data)++;
- fres_contract_id_to_string(id, &vres->contract->id, sizeof(id));
- basic = fres_contract_get_basic(vres->contract);
- dummy_sched = fres_contract_get_block(vres->contract, FRES_BLOCK_DUMMY_SCHED);
+ fres_contract_id_to_string(id, &vres->id, sizeof(id));
+ basic = fres_contract_get_basic(vres->new);
+ dummy_sched = fres_contract_get_block(vres->new, FRES_BLOCK_DUMMY_SCHED);
printf("Creating VRes #%d (id=%s, period=%ld ms, budget=%ld ms, priority=%d)\n",
*my_data, id,
fosa_rel_time_to_msec(basic->period),
fres_block_dummy_sched *dummy_sched;
char id[40];
- fres_contract_id_to_string(id, &vres->contract->id, sizeof(id));
- basic = fres_contract_get_basic(vres->contract);
- dummy_sched = fres_contract_get_block(vres->contract, FRES_BLOCK_DUMMY_SCHED);
+ fres_contract_id_to_string(id, &vres->id, sizeof(id));
+ basic = fres_contract_get_basic(vres->allocated);
+ dummy_sched = fres_contract_get_block(vres->allocated, FRES_BLOCK_DUMMY_SCHED);
printf("Canceling VRes #%d (id=%s, period=%ld ms, budget=%ld ms, priority=%d)\n",
*my_data, id,