OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_52/] [or1ksim/] [support/] [sched.h] - Diff between revs 807 and 821

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 807 Rev 821
Line 61... Line 61...
#define SCHED_PRINT_JOBS()
#define SCHED_PRINT_JOBS()
#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__, cycles, (job_func), (job_param), (job_time));\
        if (SCHED_DEBUG > 0) printf ("%s@%i:SCHED_ADD(func %x, param %i, time %i)\n", __FUNCTION__, 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);\
        scheduler.heap[i].param = (job_param);\
        scheduler.heap[___i].param = (job_param);\
        scheduler.heap[i].time = (job_time);\
        scheduler.heap[___i].time = (job_time);\
        SCHED_PRINT_JOBS();\
        SCHED_PRINT_JOBS();\
}
}
 
 
/* 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__, cycles, (index), scheduler.heap[i].time); \
        if (SCHED_DEBUG > 0) printf ("%s@%i:SCHED_REMOVE%i(time %i)\n", __FUNCTION__, 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;\
          if (j < scheduler.size && scheduler.heap[j].time > scheduler.heap[j + 1].time) j++;\
          if (___j < scheduler.size && scheduler.heap[___j].time > scheduler.heap[___j + 1].time) ___j++;\
          if (scheduler.heap[j].time >= tmp->time) break;\
          if (scheduler.heap[___j].time >= tmp->time) break;\
          scheduler.heap[i] = scheduler.heap[j];\
          scheduler.heap[___i] = scheduler.heap[___j];\
          i = j;\
          ___i = ___j;\
        }\
        }\
        scheduler.heap[i] = *tmp;\
        scheduler.heap[___i] = *tmp;\
        SCHED_PRINT_JOBS();\
        SCHED_PRINT_JOBS();\
}
}
 
 
/* Removes first item from the heap */
/* Removes first item from the heap */
#define SCHED_REMOVE() SCHED_REMOVE_ITEM(1)
#define SCHED_REMOVE() SCHED_REMOVE_ITEM(1)

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.