Line 62... |
Line 62... |
#endif
|
#endif
|
|
|
/* Adds new job to the queue */
|
/* Adds new job to the queue */
|
#define SCHED_ADD(job_func, job_param, job_time) {\
|
#define SCHED_ADD(job_func, job_param, job_time) {\
|
int ___i;\
|
int ___i;\
|
if (SCHED_DEBUG > 0) PRINTF ("%s@%i:SCHED_ADD(func %x, param %i, time %i)\n", __FUNCTION__, runtime.sim.cycles, (job_func), (job_param), (job_time));\
|
if (SCHED_DEBUG > 0) PRINTF ("%s@%i:SCHED_ADD(func %p, param %i, time %i)\n", __FUNCTION__, runtime.sim.cycles, (job_func), (job_param), (job_time));\
|
SCHED_PRINT_JOBS();\
|
SCHED_PRINT_JOBS();\
|
if (SCHED_DEBUG > 1) PRINTF ("--------\n");\
|
if (SCHED_DEBUG > 1) PRINTF ("--------\n");\
|
___i = scheduler.size++;\
|
___i = scheduler.size++;\
|
while (___i > 1 && scheduler.heap[___i / 2].time > (job_time)) scheduler.heap[___i] = scheduler.heap[___i /= 2];\
|
while (___i > 1 && scheduler.heap[___i / 2].time > (job_time)) scheduler.heap[___i] = scheduler.heap[___i /= 2];\
|
scheduler.heap[___i].func = (job_func);\
|
scheduler.heap[___i].func = (job_func);\
|
Line 77... |
Line 77... |
|
|
/* Removes an item from the heap */
|
/* Removes an item from the heap */
|
#define SCHED_REMOVE_ITEM(index) {\
|
#define SCHED_REMOVE_ITEM(index) {\
|
struct sched_entry *tmp;\
|
struct sched_entry *tmp;\
|
int ___i = (index), ___j;\
|
int ___i = (index), ___j;\
|
if (SCHED_DEBUG > 0) PRINTF ("%s@%i:SCHED_REMOVE%i(time %i)\n", __FUNCTION__, runtime.sim.cycles, (index), scheduler.heap[___i].time); \
|
if (SCHED_DEBUG > 0) PRINTF ("%s@%i:SCHED_REMOVE%i(time %li)\n", __FUNCTION__, runtime.sim.cycles, (index), scheduler.heap[___i].time); \
|
SCHED_PRINT_JOBS();\
|
SCHED_PRINT_JOBS();\
|
if (SCHED_DEBUG > 1) PRINTF ("--------\n");\
|
if (SCHED_DEBUG > 1) PRINTF ("--------\n");\
|
tmp = &scheduler.heap[--scheduler.size];\
|
tmp = &scheduler.heap[--scheduler.size];\
|
while (___i <= scheduler.size / 2) {\
|
while (___i <= scheduler.size / 2) {\
|
___j = 2 * ___i;\
|
___j = 2 * ___i;\
|