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

Subversion Repositories or1k

[/] [or1k/] [tags/] [stable_0_2_0_rc1/] [or1ksim/] [support/] [sched.h] - Diff between revs 1452 and 1541

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

Rev 1452 Rev 1541
Line 25... Line 25...
#include "sched_i386.h"
#include "sched_i386.h"
#endif
#endif
 
 
#include "debug.h"
#include "debug.h"
 
 
/* Scheduler debug level */
 
#define SCHED_DEBUG     0
 
 
 
#define SCHED_HEAP_SIZE 128
#define SCHED_HEAP_SIZE 128
#define SCHED_TIME_MAX  INT32_MAX
#define SCHED_TIME_MAX  INT32_MAX
 
 
DECLARE_DEBUG_CHANNEL(sched);
DECLARE_DEBUG_CHANNEL(sched);
 
DECLARE_DEBUG_CHANNEL(sched_jobs);
 
 
/* Structure for holding one job entry */
/* Structure for holding one job entry */
struct sched_entry {
struct sched_entry {
  int32_t time;          /* Clock cycles before job starts */
  int32_t time;          /* Clock cycles before job starts */
  void *param;           /* Parameter to pass to the function */
  void *param;           /* Parameter to pass to the function */
Line 52... Line 50...
void sched_init(void);
void sched_init(void);
void sched_reset(void);
void sched_reset(void);
 
 
extern struct scheduler_struct scheduler;
extern struct scheduler_struct scheduler;
 
 
#if SCHED_DEBUG > 1
 
#define SCHED_PRINT_JOBS() sched_print_jobs()
 
static inline void sched_print_jobs(void)
static inline void sched_print_jobs(void)
{
{
  struct sched_entry *cur;
  struct sched_entry *cur;
  int i;
  int i;
 
 
  for (cur = scheduler.job_queue, i = 0; cur; cur = cur->next, i++)
  for (cur = scheduler.job_queue, i = 0; cur; cur = cur->next, i++)
    TRACE_(sched)("\t%i: %p $%p @ %"PRIi32"\n", i, cur->func, cur->param,
    TRACE_(sched)("\t%i: %p $%p @ %"PRIi32"\n", i, cur->func, cur->param,
                  cur->time);
                  cur->time);
}
}
#else
 
#define SCHED_PRINT_JOBS()
 
#endif
 
 
 
/* Adds new job to the queue */
/* Adds new job to the queue */
static inline void sched_add(void (*job_func)(void *), void *job_param,
static inline void sched_add(void (*job_func)(void *), void *job_param,
                             int32_t job_time, const char *func)
                             int32_t job_time, const char *func)
{
{
  struct sched_entry *cur, *prev, *new_job;
  struct sched_entry *cur, *prev, *new_job;
  int32_t alltime;
  int32_t alltime;
 
 
  if (SCHED_DEBUG > 1)
  TRACE_(sched)("%s@%lli:SCHED_ADD(time %"PRIi32")\n", func, runtime.sim.cycles,
    TRACE_(sched)("%s@%lli:SCHED_ADD(time %"PRIi32")\n", func,
                job_time);
                  runtime.sim.cycles, job_time);
  if(TRACE_ON(sched_jobs))
  SCHED_PRINT_JOBS();
    sched_print_jobs();
 
 
  if (SCHED_DEBUG > 1) TRACE_(sched) ("--------\n");
  if(TRACE_ON(sched_jobs))
 
    TRACE_(sched) ("--------\n");
 
 
  cur = scheduler.job_queue;
  cur = scheduler.job_queue;
  prev = NULL;
  prev = NULL;
  alltime = cur->time;
  alltime = cur->time;
  while(cur && (alltime < job_time)) {
  while(cur && (alltime < job_time)) {
Line 118... Line 112...
  }
  }
 
 
  if(cur)
  if(cur)
    cur->time -= new_job->time;
    cur->time -= new_job->time;
 
 
  SCHED_PRINT_JOBS();
  if(TRACE_ON(sched_jobs))
 
    sched_print_jobs();
}
}
 
 
#define SCHED_ADD(job_func, job_param, job_time) sched_add(job_func, job_param, job_time, __FUNCTION__)
#define SCHED_ADD(job_func, job_param, job_time) sched_add(job_func, job_param, job_time, __FUNCTION__)
 
 
/* Returns a job with specified function and param, NULL if not found */
/* Returns a job with specified function and param, NULL if not found */

powered by: WebSVN 2.1.0

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