(const frsh_vres_id_t vres,
const frsh_thread_id_t thread)
{
- struct fres_contract *contract = vres->perceived;
- fres_block_resource *r = fres_contract_get_resource(contract);
int ret;
-
- ret = fra_insert_thread_vres(&thread, r->resource_type, vres);
+ ret = fra_insert_thread_vres(&thread, vres->allocator->res_type, vres);
if (ret) goto err;
- switch(r->resource_type)
- {
- case FRSH_RT_PROCESSOR:
- {
- ret = fra_CPU_bind_thread(vres, thread);
- break;
- }
- case FRSH_RT_DISK:
- {
- ret = fra_DISK_bind_thread(vres, thread);
- break;
- }
- default:
- goto err_delete;
+
+ if (vres->allocator->bind_thread) {
+ ret = vres->allocator->bind_thread(vres, thread);
+ } else {
+ ret = FRSH_ERR_NOT_IMPLEMENTED;
}
if (ret) goto err_delete;
return FRSH_NO_ERROR;
err_delete:
- fra_delete_thread_vres(&thread, r->resource_type);
+ fra_delete_thread_vres(&thread, vres->allocator->res_type);
err:
return FRSH_ERR_INTERNAL_ERROR;
}
int frsh_thread_unbind(const frsh_thread_id_t thread)
{
fres_vres_t *vres;
- struct fres_contract *contract;
- fres_block_resource *r;
int ret;
/* Unbound from FRSH_RT_PROCESSOR resource (if any) */
vres = fra_get_vres_thread_vres(&thread, FRSH_RT_PROCESSOR);
if (vres) {
- contract = vres->perceived;
- r = fres_contract_get_resource(contract);
- ret = fra_CPU_unbind_thread(thread);
+ if (vres->allocator->unbind_thread) {
+ ret = vres->allocator->unbind_thread(thread);
+ } else {
+ ret = FRSH_ERR_NOT_IMPLEMENTED;
+ }
if (ret) goto err;
- ret = fra_delete_thread_vres(&thread, FRSH_RT_PROCESSOR);
+ ret = fra_delete_thread_vres(&thread, vres->allocator->res_type);
if (ret) goto err;
}
/* Unbound from FRSH_RT_DISK resource (if any) */
vres = fra_get_vres_thread_vres(&thread, FRSH_RT_DISK);
if (vres) {
- contract = vres->perceived;
- r = fres_contract_get_resource(contract);
- ret = fra_DISK_unbind_thread(thread);
+ if (vres->allocator->unbind_thread) {
+ ret = vres->allocator->unbind_thread(thread);
+ } else {
+ ret = FRSH_ERR_NOT_IMPLEMENTED;
+ }
if (ret) goto err;
- ret = fra_delete_thread_vres(&thread, FRSH_RT_DISK);
+ ret = fra_delete_thread_vres(&thread, vres->allocator->res_type);
if (ret) goto err;
}
return FRSH_ERR_NOT_IMPLEMENTED;
}
+int frsh_vres_set_notification(
+ frsh_vres_id_t vres,
+ const frsh_signal_t budget_overrun_signal,
+ const frsh_signal_info_t budget_overrun_siginfo,
+ const frsh_signal_t deadline_miss_signal,
+ const frsh_signal_info_t deadline_miss_siginfo)
+{
+ fres_block_basic *b;
+
+ /* deadline and period must be coherent between each other */
+ b = fres_contract_get_basic(vres->allocated);
+
+ /* signal delivery can only be requested for BUONDED workloads */
+ if (b &&
+ (b->workload == FRSH_WT_INDETERMINATE &&
+ (deadline_miss_signal != FRSH_NULL_SIGNAL ||
+ budget_overrun_signal != FRSH_NULL_SIGNAL)))
+ return FRSH_ERR_BAD_ARGUMENT;
+
+ /* TODO - handle overrun and deadline signals */
+/* vres->budget_overrun_signal = budget_overrun_signal; */
+/* vres->budget_overrun_siginfo = budget_overrun_siginfo; */
+/* vres->deadline_miss_signal = deadline_miss_signal; */
+/* vres->deadline_miss_siginfo = deadline_miss_siginfo; */
+ return FRSH_ERR_NOT_IMPLEMENTED;
+}