How to write a new scheduler for FreeBSD

2009-05-13 05:45:45来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折

I found the patch about sched_core(written by davidxu) from mailing list. It may be helpful for somebody who wanna write his own scheduler.
From: "Stepan A. Baranov"
Subject: scheduler CORE for RELENG_6
Hello,
I prepared patch to port scheduler from HEAD to RELENG_6. I applied
this patch for my workstation and scheduler CORE works fine.
After applying patch you can say:
options         SCHED_CORE              # CORE scheduler
in your KERN CONF file and rebuild your kernel.
Please, test it and fix it.
Stepan Baranov.

Stepan Baranov.
-------------- next part --------------
Index: ./sys/sys/sched.h
===================================================================
RCS file: /home/ncvs/src/sys/sys/sched.h,v
retrieving revision 1.24
diff -u -r1.24 sched.h
--- ./sys/sys/sched.h 19 Apr 2005 04:01:25 -0000 1.24
+++ ./sys/sys/sched.h 24 Oct 2006 09:45:32 -0000
@@ -78,6 +78,8 @@
void sched_add(struct thread *td, int flags);
void sched_clock(struct thread *td);
void sched_rem(struct thread *td);
+void sched_tick(void);
+void sched_relinquish(struct thread *td);
/*
* Binding makes cpu affinity permanent while pinning is used to temporarily
Index: ./sys/sys/systm.h
===================================================================
RCS file: /home/ncvs/src/sys/sys/systm.h,v
retrieving revision 1.234.2.5
diff -u -r1.234.2.5 systm.h
--- ./sys/sys/systm.h 6 Jul 2006 08:32:50 -0000 1.234.2.5
+++ ./sys/sys/systm.h 24 Oct 2006 09:45:35 -0000
@@ -239,6 +239,12 @@
int unsetenv(const char *name);
int testenv(const char *name);
+typedef uint64_t (cpu_tick_f)(void);
+void set_cputicker(cpu_tick_f *func, uint64_t freq, unsigned var);
+extern cpu_tick_f *cpu_ticks;
+uint64_t cpu_tickrate(void);
+uint64_t cputick2usec(uint64_t tick);
+
#ifdef APM_FIXUP_CALLTODO
struct timeval;
void adjust_timeout_calltodo(struct timeval *time_change);
Index: ./sys/kern/sched_ule.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/sched_ule.c,v
retrieving revision 1.153.2.3
diff -u -r1.153.2.3 sched_ule.c
--- ./sys/kern/sched_ule.c 27 Sep 2005 12:00:31 -0000 1.153.2.3
+++ ./sys/kern/sched_ule.c 24 Oct 2006 09:45:38 -0000
@@ -1962,6 +1962,19 @@
       return (td->td_kse->ke_flags & KEF_BOUND);
}
+void
+sched_relinquish(struct thread *td)
+{
+ struct ksegrp *kg;
+
+ kg = td->td_ksegrp;
+ mtx_lock_spin(&sched_lock);
+ if (kg->kg_pri_class == PRI_TIMESHARE)
+ sched_prio(td, PRI_MAX_TIMESHARE);
+ mi_switch(SW_VOL, NULL);
+ mtx_unlock_spin(&sched_lock);
+}
+

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:FreeBSD\BIND平台智能DNS服务器架构

下一篇:operation amplifier 和 power amplifier