@ -28,7 +28,8 @@ enum SCHEDULER
{
SCHEDULER_FIFO = 0 ,
SCHEDULER_EDF = 1 ,
SCHEDULER_SRSF = 2
SCHEDULER_SRSF = 2 ,
SCHEDULER_MDL = 3
} ;
extern enum SCHEDULER scheduler ;
@ -112,6 +113,47 @@ err_allocate:
request = NULL ;
goto done ;
}
static inline struct sandbox *
scheduler_MDL_get_next ( )
{
/* Get the deadline of the sandbox at the head of the local request queue */
struct sandbox * local = local_runqueue_get_next ( ) ;
uint64_t local_remaining_MDL = local = = NULL ? UINT64_MAX : local - > absolute_deadline ;
struct sandbox_request * request = NULL ;
uint64_t global_remaining_slack = global_request_scheduler_peek ( ) ;
/* Try to pull and allocate from the global queue if earlier
* This will be placed at the head of the local runqueue */
if ( global_remaining_slack < local_remaining_MDL & & ( local_workload_count < = 2 | | local_runqueue_count = = 0 ) ) {
//if (global_remaining_slack < local_remaining_slack) {
if ( global_request_scheduler_remove_if_earlier ( & request , local_remaining_MDL ) = = 0 ) {
//uint64_t pop_time = __getcycles() - system_start_timestamp;
//mem_log("time %lu remove from GQ, request id:%d name %s remaining slack %lu\n", pop_time,
// request->id, request->module->name, request->remaining_slack);
assert ( request ! = NULL ) ;
struct sandbox * global = sandbox_allocate ( request ) ;
if ( ! global ) goto err_allocate ;
assert ( global - > state = = SANDBOX_INITIALIZED ) ;
sandbox_set_as_runnable ( global , SANDBOX_INITIALIZED ) ;
}
}
/* Return what is at the head of the local runqueue or NULL if empty */
done :
return local_runqueue_get_next ( ) ;
err_allocate :
client_socket_send ( request - > socket_descriptor , 503 ) ;
client_socket_close ( request - > socket_descriptor , & request - > socket_address ) ;
free ( request ) ;
request = NULL ;
goto done ;
}
static inline struct sandbox *
scheduler_fifo_get_next ( )
{
@ -156,6 +198,8 @@ scheduler_get_next()
return scheduler_srsf_get_next ( ) ;
case SCHEDULER_FIFO :
return scheduler_fifo_get_next ( ) ;
case SCHEDULER_MDL :
return scheduler_MDL_get_next ( ) ;
default :
panic ( " Unimplemented \n " ) ;
}
@ -171,6 +215,9 @@ scheduler_initialize()
case SCHEDULER_SRSF :
global_request_scheduler_minheap_initialize ( SCHEDULER_SRSF ) ;
break ;
case SCHEDULER_MDL :
global_request_scheduler_minheap_initialize ( SCHEDULER_MDL ) ;
break ;
case SCHEDULER_FIFO :
global_request_scheduler_deque_initialize ( ) ;
break ;
@ -189,6 +236,8 @@ scheduler_runqueue_initialize()
case SCHEDULER_SRSF :
local_runqueue_minheap_initialize ( SCHEDULER_SRSF ) ;
break ;
case SCHEDULER_MDL :
local_runqueue_minheap_initialize ( SCHEDULER_MDL ) ;
case SCHEDULER_FIFO :
local_runqueue_list_initialize ( ) ;
break ;
@ -291,6 +340,8 @@ scheduler_print(enum SCHEDULER variant)
return " FIFO " ;
case SCHEDULER_EDF :
return " EDF " ;
case SCHEDULER_MDL :
return " MDL " ;
case SCHEDULER_SRSF :
return " SRSF " ;
}