priority_queues.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * StarPU
  3. * Copyright (C) Université Bordeaux 1, CNRS 2008-2010 (see AUTHORS file)
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License as published by
  7. * the Free Software Foundation; either version 2.1 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. *
  14. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  15. */
  16. #include <starpu.h>
  17. #include <common/config.h>
  18. #include <core/mechanisms/priority_queues.h>
  19. #include <common/utils.h>
  20. /*
  21. * Centralized queue with priorities
  22. */
  23. struct starpu_priority_taskq_s *_starpu_create_priority_taskq(void)
  24. {
  25. struct starpu_priority_taskq_s *central_queue;
  26. central_queue = malloc(sizeof(struct starpu_priority_taskq_s));
  27. central_queue->total_ntasks = 0;
  28. unsigned prio;
  29. for (prio = 0; prio < NPRIO_LEVELS; prio++)
  30. {
  31. starpu_task_list_init(&central_queue->taskq[prio]);
  32. central_queue->ntasks[prio] = 0;
  33. }
  34. return central_queue;
  35. }
  36. void _starpu_destroy_priority_taskq(struct starpu_priority_taskq_s *priority_queue)
  37. {
  38. free(priority_queue);
  39. }