akaros/kern/include/schedule.h
<<
>>
Prefs
   1/*
   2 * Copyright (c) 2009 The Regents of the University of California
   3 * Barret Rhoden <brho@cs.berkeley.edu>
   4 * See LICENSE for details.
   5 *
   6 * Scheduling and dispatching.
   7 */
   8
   9#pragma once
  10
  11#include <ros/common.h>
  12#include <sys/queue.h>
  13#include <corerequest.h>
  14
  15struct proc;    /* process.h includes us, but we need pointers now */
  16TAILQ_HEAD(proc_list, proc);            /* Declares 'struct proc_list' */
  17
  18/* One of these embedded in every struct proc */
  19struct sched_proc_data {
  20        TAILQ_ENTRY(proc)               proc_link;
  21        struct proc_list                *cur_list; /* which tailq we're on */
  22        struct core_request_data        crd;    /* prov/alloc cores */
  23        /* count of lists? */
  24        /* other accounting info */
  25};
  26
  27void schedule_init(void);
  28
  29/************** Process Management Callbacks **************/
  30/* Tell the ksched about the process, which it will track cradle-to-grave */
  31void __sched_proc_register(struct proc *p);
  32
  33/* The proc was an SCP and is becoming an MCP */
  34void __sched_proc_change_to_m(struct proc *p);
  35
  36/* The proc is dying */
  37void __sched_proc_destroy(struct proc *p, uint32_t *pc_arr, uint32_t nr_cores);
  38
  39/* Makes sure p is runnable. */
  40void __sched_mcp_wakeup(struct proc *p);
  41void __sched_scp_wakeup(struct proc *p);
  42
  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. */
  45void __sched_put_idle_core(struct proc *p, uint32_t coreid);
  46void __sched_put_idle_cores(struct proc *p, uint32_t *pc_arr, uint32_t num);
  47
  48/************** Decision making **************/
  49/* Call the main scheduling algorithm.  Not clear yet if the main kernel will
  50 * ever call this directly. */
  51void run_scheduler(void);
  52
  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. */
  56void poke_ksched(struct proc *p, unsigned int res_type);
  57
  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). */
  61void cpu_bored(void);
  62
  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. */
  67void avail_res_changed(int res_type, long change);
  68
  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
  72 * schedulers. */
  73int provision_core(struct proc *p, uint32_t pcoreid);
  74
  75/************** Debugging **************/
  76void sched_diag(void);
  77void print_resources(struct proc *p);
  78void print_all_resources(void);
  79void next_core_to_alloc(uint32_t pcoreid);
  80void sort_idle_cores(void);
  81