summaryrefslogtreecommitdiffstats
path: root/sys/kern/sched_4bsd.c
Commit message (Collapse)AuthorAgeFilesLines
* Quick fix for scaling of statclock ticks in the SMP case. As explainedbde2003-11-091-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | in the log message for kern_sched.c 1.83 (which should have been repo-copied to preserve history for this file), the (4BSD) scheduler algorithm only works right if stathz is nearly 128 Hz. The old commit lock said 64 Hz; the scheduler actually wants nearly 16 Hz but there was a scale factor of 4 to give the requirement of 64 Hz, and rev.1.83 changed the scale factor so that the requirement became 128 Hz. The change of the scale factor was incomplete in the SMP case. Then scheduling ticks are provided by smp_ncpu CPUs, and the scheduler cannot tell the difference between this and 1 CPU providing scheduling ticks smp_ncpu times faster, so we need another scale factor of smp_ncp or an algorithm change. This quick fix uses the scale factor without even trying to optimize the runtime divisions required for this as is done for the other scale factor. The main algorithmic problem is the clamp on the scheduling tick counts. This was 295; it is now approximately 295 * smp_ncpu. When the limit is reached, threads get free timeslices and scheduling becomes very unfair to the threads that don't hit the limit. The limit can be reached and maintained in the worst case if the load average is larger than (limit / effective_stathz - 1) / 2 = 0.65 now (was just 0.08 with 2 CPUs before this change), so there are algorithmic problems even for a load average of 1. Fortunately, the worst case isn't common enough for the problem to be very noticeable (it is mainly for niced CPU hogs competing with less nice CPU hogs).
* Return a reasonable number for top or ps to display for M:N thread,davidxu2003-11-081-0/+2
| | | | | | | since there is no direct association between M:N thread and kse, sometimes, a thread does not have a kse, in that case, return a pctcpu from its last kse, it is not perfect, but gives a good number to be displayed.
* Removed sched_nest variable in sched_switch(). Context switches alwaysbde2003-10-291-3/+0
| | | | | | | | | | | | | | | | | begin with sched_lock held but not recursed, so this variable was always 0. Removed fixup of sched_lock.mtx_recurse after context switches in sched_switch(). Context switches always end with this variable in the same state that it began in, so there is no need to fix it up. Only sched_lock.mtx_lock really needs a fixup. Replaced fixup of sched_lock.mtx_recurse in fork_exit() by an assertion that sched_lock is owned and not recursed after it is fixed up. This assertion much match the one in mi_switch(), and if sched_lock were recursed then a non-null fixup of sched_lock.mtx_recurse would probably be needed again, unlike in sched_switch(), since fork_exit() doesn't return to its caller in the normal way.
* - The kse may be null in sched_pctcpu().jeff2003-10-161-1/+7
| | | | Reported by: kris
* - Collapse sched_switchin() and sched_switchout() into sched_switch(). Nowjeff2003-10-161-9/+10
| | | | | mi_switch() calls sched_switch() which calls cpu_switch(). This is actually one less function call than it had been.
* - Update the sched api. sched_{add,rem,clock,pctcpu} now all accept a tdjeff2003-10-161-8/+14
| | | | argument rather than a kse.
* Change instances of callout_init that specify MPSAFE behaviour tosam2003-08-191-1/+1
| | | | | use CALLOUT_MPSAFE instead of "1" for the second parameter. This does not change the behaviour; it just makes the intent more clear.
* - Various style fixes in both code and comments.jhb2003-08-151-26/+31
| | | | | | | | | - Update some stale comments. - Sort a couple of includes. - Only set 'newcpu' in updatepri() if we use it. - No functional changes. Obtained from: bde (via an old diff I got a long time ago)
* Rename P_THREADED to P_SA. P_SA means a process is using schedulerdavidxu2003-06-151-1/+1
| | | | activations.
* Use __FBSDID().obrien2003-06-111-2/+3
|
* Fix some easy, global, lint warnings. In most cases, this meansmarkm2003-04-301-1/+1
| | | | | making some local variables static. In a couple of cases, this means removing an unused variable.
* Add lock assertions for various proc/thread/kse/ksegroup fields to thejhb2003-04-231-0/+12
| | | | scheduler functions.
* - Assert that the proc lock and sched_lock are held in sched_nice().jhb2003-04-221-2/+3
| | | | | | - For the 4BSD scheduler, this means that all callers of the static function resetpriority() now always hold sched_lock, so don't lock sched_lock explicitly in that function.
* - Catch up with sched api changes.jeff2003-04-111-15/+48
|
* Move the _oncpu entry from the KSE to the thread.julian2003-04-101-3/+3
| | | | | The entry in the KSE still exists but it's purpose will change a bit when we add the ability to lock a KSE to a cpu.
* Remove a trailing semicolon in SCHED_QUANTUM definition.mux2003-03-241-1/+1
| | | | | | Luckily this didn't cause any bugs. Spotted by: Samy Al Bahra <samy@kerneled.com>
* Change the process flags P_KSES to be P_THREADED.julian2003-02-271-1/+1
| | | | This is just a cosmetic change but I've been meaning to do it for about a year.
* Update comments to reflect new KSE code.davidxu2003-02-191-1/+0
|
* Move a bunch of flags from the KSE to the thread.julian2003-02-171-2/+2
| | | | | | | | I was in two minds as to where to put them in the first case.. I should have listenned to the other mind. Submitted by: parts by davidxu@ Reviewed by: jeff@ mini@
* - Unbreak world. I did not notice that libkvm was still used in some placesjeff2003-01-131-7/+5
| | | | | | to access the pctcpu. This will have to be sorted out more later as the new scheduler requires a procedural interface for this data. A more complete solution will follow.
* - Move ke_pctcpu and ke_cpticks into the scheduler specific datastructure.jeff2003-01-121-15/+30
| | | | | This will prevent access through mechanisms other than the published interfaces.
* Add code to ddb to allow backtracing an arbitrary thread.julian2002-12-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | (show thread {address}) Remove the IDLE kse state and replace it with a change in the way threads sahre KSEs. Every KSE now has a thread, which is considered its "owner" however a KSE may also be lent to other threads in the same group to allow completion of in-kernel work. n this case the owner remains the same and the KSE will revert to the owner when the other work has been completed. All creations of upcalls etc. is now done from kse_reassign() which in turn is called from mi_switch or thread_exit(). This means that special code can be removed from msleep() and cv_wait(). kse_release() does not leave a KSE with no thread any more but converts the existing thread into teh KSE's owner, and sets it up for doing an upcall. It is just inhibitted from being scheduled until there is some reason to do an upcall. Remove all trace of the kse_idle queue since it is no-longer needed. "Idle" KSEs are now on the loanable queue.
* - Add the new sched_pctcpu() function to the sched_* api.jeff2002-11-211-0/+6
| | | | | | | | - Provide a routine in sched_4bsd to add this functionality. - Use sched_pctcpu() in kern_proc, which is the one place outside of sched_4bsd where the old pctcpu value was accessed directly. Approved by: re
* - Move scheduler specific macros and defines out of proc.hjeff2002-11-211-0/+10
| | | | Approved by: re
* - Move FSCALE back to kern_sync. This is not scheduler specific.jeff2002-11-211-5/+0
| | | | | | | - Create a new callout for lbolt and move it out of schedcpu(). This is not scheduler specific either. Approved by: re
* - Implement a mechanism for allowing schedulers to place scheduler dependantjeff2002-11-211-0/+25
| | | | | | | | | data in the scheduler independant structures (proc, ksegrp, kse, thread). - Implement unused stubs for this mechanism in sched_4bsd. Approved by: re Reviewed by: luigi, trb Tested on: x86, alpha
* Tidy up the scheduler's code for changing the priority of a thread.julian2002-10-141-26/+11
| | | | Logically pretty much a NOP.
* - Create a new scheduler api that is defined in sys/sched.hjeff2002-10-121-0/+635
- Begin moving scheduler specific functionality into sched_4bsd.c - Replace direct manipulation of scheduler data with hooks provided by the new api. - Remove KSE specific state modifications and single runq assumptions from kern_switch.c Reviewed by: -arch
OpenPOWER on IntegriCloud