b4cf88a04f
- cotributed by Bjorn Swift - In this first phase, scheduling is moved from the kernel to the PM server. The next steps are to a) moving scheduling to its own server and b) include useful information in the "out of quantum" message, so that the scheduler can make use of this information. - The kernel process table now keeps record of who is responsible for scheduling each process (p_scheduler). When this pointer is NULL, the process will be scheduled by the kernel. If such a process runs out of quantum, the kernel will simply renew its quantum an requeue it. - When PM loads, it will take over scheduling of all running processes, except system processes, using sys_schedctl(). Essentially, this only results in taking over init. As children inherit a scheduler from their parent, user space programs forked by init will inherit PM (for now) as their scheduler. - Once a process has been assigned a scheduler, and runs out of quantum, its RTS_NO_QUANTUM flag will be set and the process dequeued. The kernel will send a message to the scheduler, on the process' behalf, informing the scheduler that it has run out of quantum. The scheduler can take what ever action it pleases, based on its policy, and then reschedule the process using the sys_schedule() system call. - Balance queues does not work as before. While the old in-kernel function used to renew the quantum of processes in the highest priority run queue, the user-space implementation only acts on processes that have been bumped down to a lower priority queue. This approach reacts slower to changes than the old one, but saves us sending a sys_schedule message for each process every time we balance the queues. Currently, when processes are moved up a priority queue, their quantum is also renewed, but this can be fiddled with. - do_nice has been removed from kernel. PM answers to get- and setpriority calls, updates it's own nice variable as well as the max_run_queue. This will be refactored once scheduling is moved to a separate server. We will probably have PM update it's local nice value and then send a message to whoever is scheduling the process. - changes to fix an issue in do_fork() where processes could run out of quantum but bypassing the code path that handles it correctly. The future plan is to remove the policy from do_fork() and implement it in userspace too.
183 lines
8 KiB
C
183 lines
8 KiB
C
/* Function prototypes. */
|
|
|
|
#ifndef PROTO_H
|
|
#define PROTO_H
|
|
|
|
#include <minix/safecopies.h>
|
|
#include <machine/archtypes.h>
|
|
#include <a.out.h>
|
|
|
|
/* Struct declarations. */
|
|
struct proc;
|
|
struct timer;
|
|
|
|
/* clock.c */
|
|
_PROTOTYPE( clock_t get_uptime, (void) );
|
|
_PROTOTYPE( void set_timer, (struct timer *tp, clock_t t, tmr_func_t f) );
|
|
_PROTOTYPE( void reset_timer, (struct timer *tp) );
|
|
_PROTOTYPE( void ser_dump_proc, (void) );
|
|
|
|
_PROTOTYPE( void cycles_accounting_init, (void) );
|
|
/*
|
|
* This functions start and stop accounting for process, kernel or idle cycles.
|
|
* It inherently have to account for some kernel cycles for process too,
|
|
* therefore it should be called asap after trapping to kernel and as late as
|
|
* possible before returning to userspace. These function is architecture
|
|
* dependent
|
|
*/
|
|
_PROTOTYPE( void cycles_accounting_stop, (struct proc * p) );
|
|
/* this is a wrapper to make calling it from assembly easier */
|
|
_PROTOTYPE( void cycles_accounting_stop_idle, (void) );
|
|
|
|
/* main.c */
|
|
_PROTOTYPE( void main, (void) );
|
|
_PROTOTYPE( void prepare_shutdown, (int how) );
|
|
_PROTOTYPE( void minix_shutdown, (struct timer *tp) );
|
|
|
|
/* proc.c */
|
|
_PROTOTYPE( int do_ipc, (int call_nr, int src_dst,
|
|
message *m_ptr, long bit_map) );
|
|
_PROTOTYPE( int mini_notify, (const struct proc *src, endpoint_t dst) );
|
|
_PROTOTYPE( void enqueue, (struct proc *rp) );
|
|
_PROTOTYPE( void dequeue, (const struct proc *rp) );
|
|
_PROTOTYPE( struct proc * schedcheck, (void) );
|
|
_PROTOTYPE( struct proc * arch_finish_schedcheck, (void) );
|
|
_PROTOTYPE( struct proc *endpoint_lookup, (endpoint_t ep) );
|
|
#if DEBUG_ENABLE_IPC_WARNINGS
|
|
_PROTOTYPE( int isokendpt_f, (const char *file, int line, endpoint_t e, int *p, int f));
|
|
#define isokendpt_d(e, p, f) isokendpt_f(__FILE__, __LINE__, (e), (p), (f))
|
|
#else
|
|
_PROTOTYPE( int isokendpt_f, (endpoint_t e, int *p, int f) );
|
|
#define isokendpt_d(e, p, f) isokendpt_f((e), (p), (f))
|
|
#endif
|
|
_PROTOTYPE( void check_ticks_left, (struct proc *p));
|
|
|
|
/* start.c */
|
|
_PROTOTYPE( void cstart, (U16_t cs, U16_t ds, U16_t mds,
|
|
U16_t parmoff, U16_t parmsize) );
|
|
|
|
/* system.c */
|
|
_PROTOTYPE( int get_priv, (register struct proc *rc, int proc_type) );
|
|
_PROTOTYPE( void set_sendto_bit, (const struct proc *rc, int id) );
|
|
_PROTOTYPE( void unset_sendto_bit, (const struct proc *rc, int id) );
|
|
_PROTOTYPE( void send_sig, (int proc_nr, int sig_nr) );
|
|
_PROTOTYPE( void cause_sig, (proc_nr_t proc_nr, int sig_nr) );
|
|
_PROTOTYPE( void sig_delay_done, (struct proc *rp) );
|
|
_PROTOTYPE( void kernel_call, (message *m_user, struct proc * caller) );
|
|
_PROTOTYPE( void system_init, (void) );
|
|
#define numap_local(proc_nr, vir_addr, bytes) \
|
|
umap_local(proc_addr(proc_nr), D, (vir_addr), (bytes))
|
|
_PROTOTYPE( phys_bytes umap_grant, (struct proc *, cp_grant_id_t, vir_bytes));
|
|
_PROTOTYPE( void clear_endpoint, (struct proc *rc) );
|
|
_PROTOTYPE( phys_bytes umap_bios, (vir_bytes vir_addr, vir_bytes bytes));
|
|
_PROTOTYPE( void kernel_call_resume, (struct proc *p));
|
|
|
|
/* system/do_newmap.c */
|
|
_PROTOTYPE( int newmap, (struct proc * caller, struct proc *rp,
|
|
struct mem_map *map_ptr));
|
|
|
|
/* system/do_vtimer.c */
|
|
_PROTOTYPE( void vtimer_check, (struct proc *rp) );
|
|
|
|
/* interrupt.c */
|
|
_PROTOTYPE( void put_irq_handler, (irq_hook_t *hook, int irq,
|
|
irq_handler_t handler) );
|
|
_PROTOTYPE( void rm_irq_handler, (const irq_hook_t *hook) );
|
|
_PROTOTYPE( void enable_irq, (const irq_hook_t *hook) );
|
|
_PROTOTYPE( int disable_irq, (const irq_hook_t *hook) );
|
|
|
|
/* debug.c */
|
|
_PROTOTYPE( int runqueues_ok, (void) );
|
|
_PROTOTYPE( char *rtsflagstr, (int flags) );
|
|
_PROTOTYPE( char *miscflagstr, (int flags) );
|
|
_PROTOTYPE( char *schedulerstr, (struct proc *scheduler) );
|
|
|
|
/* system/do_safemap.c */
|
|
_PROTOTYPE( int map_invoke_vm, (struct proc * caller, int req_type,
|
|
endpoint_t end_d, int seg_d, vir_bytes off_d,
|
|
endpoint_t end_s, int seg_s, vir_bytes off_s,
|
|
size_t size, int flag));
|
|
|
|
/* system/do_safecopy.c */
|
|
_PROTOTYPE( int verify_grant, (endpoint_t, endpoint_t,
|
|
cp_grant_id_t, vir_bytes, int,
|
|
vir_bytes, vir_bytes *, endpoint_t *));
|
|
|
|
/* system/do_sysctl.c */
|
|
_PROTOTYPE( int do_sysctl, (struct proc * caller, message *m));
|
|
|
|
#if SPROFILE
|
|
/* profile.c */
|
|
_PROTOTYPE( void init_profile_clock, (u32_t) );
|
|
_PROTOTYPE( void stop_profile_clock, (void) );
|
|
#endif
|
|
|
|
/* functions defined in architecture-dependent files. */
|
|
_PROTOTYPE( void prot_init, (void) );
|
|
_PROTOTYPE( phys_bytes phys_copy, (phys_bytes source, phys_bytes dest,
|
|
phys_bytes count) );
|
|
_PROTOTYPE( void phys_copy_fault, (void));
|
|
_PROTOTYPE( void phys_copy_fault_in_kernel, (void));
|
|
#define virtual_copy(src, dst, bytes) \
|
|
virtual_copy_f(NULL, src, dst, bytes, 0)
|
|
#define virtual_copy_vmcheck(caller, src, dst, bytes) \
|
|
virtual_copy_f(caller, src, dst, bytes, 1)
|
|
_PROTOTYPE( int virtual_copy_f, (struct proc * caller,
|
|
struct vir_addr *src, struct vir_addr *dst,
|
|
vir_bytes bytes, int vmcheck) );
|
|
_PROTOTYPE( int data_copy, (endpoint_t from, vir_bytes from_addr,
|
|
endpoint_t to, vir_bytes to_addr, size_t bytes));
|
|
_PROTOTYPE( int data_copy_vmcheck, (struct proc *,
|
|
endpoint_t from, vir_bytes from_addr,
|
|
endpoint_t to, vir_bytes to_addr, size_t bytes));
|
|
_PROTOTYPE( void alloc_segments, (struct proc *rp) );
|
|
_PROTOTYPE( void vm_init, (struct proc *first) );
|
|
_PROTOTYPE( phys_bytes umap_local, (register struct proc *rp, int seg,
|
|
vir_bytes vir_addr, vir_bytes bytes));
|
|
_PROTOTYPE( void cp_mess, (int src,phys_clicks src_clicks,
|
|
vir_bytes src_offset, phys_clicks dst_clicks, vir_bytes dst_offset));
|
|
_PROTOTYPE( phys_bytes umap_remote, (const struct proc* rp, int seg,
|
|
vir_bytes vir_addr, vir_bytes bytes) );
|
|
_PROTOTYPE( phys_bytes umap_virtual, (struct proc* rp,
|
|
int seg, vir_bytes vir_addr, vir_bytes bytes) );
|
|
_PROTOTYPE( phys_bytes seg2phys, (U16_t) );
|
|
_PROTOTYPE( int vm_phys_memset, (phys_bytes source, u8_t pattern,
|
|
phys_bytes count) );
|
|
_PROTOTYPE( vir_bytes alloc_remote_segment, (u32_t *, segframe_t *,
|
|
int, phys_bytes, vir_bytes, int));
|
|
_PROTOTYPE( int intr_init, (int, int) );
|
|
_PROTOTYPE( int intr_disabled, (void) );
|
|
_PROTOTYPE( void halt_cpu, (void) );
|
|
_PROTOTYPE( void arch_init, (void) );
|
|
_PROTOTYPE( void ser_putc, (char) );
|
|
_PROTOTYPE( void arch_shutdown, (int) );
|
|
_PROTOTYPE( void arch_monitor, (void) );
|
|
_PROTOTYPE( void arch_get_aout_headers, (int i, struct exec *h) );
|
|
_PROTOTYPE( void restart, (void) );
|
|
_PROTOTYPE( void read_tsc, (unsigned long *high, unsigned long *low) );
|
|
_PROTOTYPE( int arch_init_profile_clock, (u32_t freq) );
|
|
_PROTOTYPE( void arch_stop_profile_clock, (void) );
|
|
_PROTOTYPE( void arch_ack_profile_clock, (void) );
|
|
_PROTOTYPE( void do_ser_debug, (void) );
|
|
_PROTOTYPE( int arch_get_params, (char *parm, int max));
|
|
_PROTOTYPE( int arch_set_params, (char *parm, int max));
|
|
_PROTOTYPE( void arch_pre_exec, (struct proc *pr, u32_t, u32_t));
|
|
_PROTOTYPE( int arch_umap, (struct proc *pr, vir_bytes, vir_bytes,
|
|
int, phys_bytes *));
|
|
_PROTOTYPE( int arch_do_vmctl, (message *m_ptr, struct proc *p));
|
|
_PROTOTYPE( int vm_contiguous, (struct proc *targetproc, u32_t vir_buf, size_t count));
|
|
_PROTOTYPE( void proc_stacktrace, (struct proc *proc) );
|
|
_PROTOTYPE( int vm_lookup, (const struct proc *proc, vir_bytes virtual, vir_bytes *result, u32_t *ptent));
|
|
_PROTOTYPE( int delivermsg, (struct proc *target));
|
|
_PROTOTYPE( void arch_do_syscall, (struct proc *proc) );
|
|
_PROTOTYPE( int arch_phys_map, (int index, phys_bytes *addr,
|
|
phys_bytes *len, int *flags));
|
|
_PROTOTYPE( int arch_phys_map_reply, (int index, vir_bytes addr));
|
|
_PROTOTYPE( int arch_enable_paging, (struct proc * caller, const message * m_ptr));
|
|
|
|
_PROTOTYPE( int copy_msg_from_user, (struct proc * p, message * user_mbuf,
|
|
message * dst));
|
|
_PROTOTYPE( int copy_msg_to_user, (struct proc * p, message * src,
|
|
message * user_mbuf));
|
|
_PROTOTYPE(void switch_address_space, (struct proc * p));
|
|
#endif /* PROTO_H */
|