《操作系统》的实验代码。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.6 KiB

10 years ago
10 years ago
  1. #ifndef __KERN_SCHEDULE_SCHED_H__
  2. #define __KERN_SCHEDULE_SCHED_H__
  3. #include <defs.h>
  4. #include <list.h>
  5. #include <skew_heap.h>
  6. #define MAX_TIME_SLICE 5
  7. struct proc_struct;
  8. struct run_queue;
  9. // The introduction of scheduling classes is borrrowed from Linux, and makes the
  10. // core scheduler quite extensible. These classes (the scheduler modules) encapsulate
  11. // the scheduling policies.
  12. struct sched_class {
  13. // the name of sched_class
  14. const char *name;
  15. // Init the run queue
  16. void (*init)(struct run_queue *rq);
  17. // put the proc into runqueue, and this function must be called with rq_lock
  18. void (*enqueue)(struct run_queue *rq, struct proc_struct *proc);
  19. // get the proc out runqueue, and this function must be called with rq_lock
  20. void (*dequeue)(struct run_queue *rq, struct proc_struct *proc);
  21. // choose the next runnable task
  22. struct proc_struct *(*pick_next)(struct run_queue *rq);
  23. // dealer of the time-tick
  24. void (*proc_tick)(struct run_queue *rq, struct proc_struct *proc);
  25. /* for SMP support in the future
  26. * load_balance
  27. * void (*load_balance)(struct rq* rq);
  28. * get some proc from this rq, used in load_balance,
  29. * return value is the num of gotten proc
  30. * int (*get_proc)(struct rq* rq, struct proc* procs_moved[]);
  31. */
  32. };
  33. struct run_queue {
  34. list_entry_t run_list;
  35. unsigned int proc_num;
  36. int max_time_slice;
  37. // For LAB6 ONLY
  38. skew_heap_entry_t *lab6_run_pool;
  39. };
  40. void sched_init(void);
  41. void wakeup_proc(struct proc_struct *proc);
  42. void schedule(void);
  43. #endif /* !__KERN_SCHEDULE_SCHED_H__ */