2 * Copyright (c) 2009 The Regents of the University of California
3 * Barret Rhoden <brho@cs.berkeley.edu>
4 * See LICENSE for details.
6 * Scheduling and dispatching.
11 #include <ros/common.h>
12 #include <sys/queue.h>
13 #include <corerequest.h>
15 struct proc; /* process.h includes us, but we need pointers now */
16 TAILQ_HEAD(proc_list, proc); /* Declares 'struct proc_list' */
18 /* One of these embedded in every struct proc */
19 struct sched_proc_data {
20 TAILQ_ENTRY(proc) proc_link; /* tailq linkage */
21 struct proc_list *cur_list; /* which tailq we're on */
22 struct core_request_data crd; /* prov/alloc cores */
24 /* other accounting info */
27 void schedule_init(void);
29 /************** Process Management Callbacks **************/
30 /* Tell the ksched about the process, which it will track cradle-to-grave */
31 void __sched_proc_register(struct proc *p);
33 /* The proc was an SCP and is becoming an MCP */
34 void __sched_proc_change_to_m(struct proc *p);
36 /* The proc is dying */
37 void __sched_proc_destroy(struct proc *p, uint32_t *pc_arr, uint32_t nr_cores);
39 /* Makes sure p is runnable. */
40 void __sched_mcp_wakeup(struct proc *p);
41 void __sched_scp_wakeup(struct proc *p);
43 /* Gets called when a pcore becomes idle (like in proc yield). These are 'cg'
44 * cores, given to MCPs, that have been async returned to the ksched. */
45 void __sched_put_idle_core(struct proc *p, uint32_t coreid);
46 void __sched_put_idle_cores(struct proc *p, uint32_t *pc_arr, uint32_t num);
48 /************** Decision making **************/
49 /* Call the main scheduling algorithm. Not clear yet if the main kernel will
50 * ever call this directly. */
51 void run_scheduler(void);
53 /* Proc p's resource desires changed, or something in general that would lead to
54 * a new decision. The process can directly poke the ksched via a syscall, so
55 * be careful of abuse. */
56 void poke_ksched(struct proc *p, unsigned int res_type);
58 /* The calling cpu/core has nothing to do and plans to idle/halt. This is an
59 * opportunity to pick the nature of that halting (low power state, etc), or
60 * provide some other work (_Ss on LL cores). */
63 /* Available resources changed (plus or minus). Some parts of the kernel may
64 * call this if a particular resource that is 'quantity-based' changes. Things
65 * like available RAM to processes, bandwidth, etc. Cores would probably be
66 * inappropriate, since we need to know which specific core is now free. */
67 void avail_res_changed(int res_type, long change);
69 /************** Provisioning / Allocating *************/
70 /* This section is specific to a provisioning ksched. Careful calling any of
71 * this from generic kernel code, since it might not be present in all kernel
73 int provision_core(struct proc *p, uint32_t pcoreid);
75 /************** Debugging **************/
76 void sched_diag(void);
77 void print_resources(struct proc *p);
78 void print_all_resources(void);
79 void next_core_to_alloc(uint32_t pcoreid);
80 void sort_idle_cores(void);