Age | Commit message (Collapse) | Author |
|
Add a processor bitmap per physical map to determine processors on which
a pmap is loaded, so that only those processors receive update IPIs. In
addition, implement lazy TLB invalidation by not loading page tables
when switching to a kernel thread. To finish with, the thread module now
calls pmap_load unconditionally without making assumptions about pmap
optimizations.
|
|
Move scheduling interrupt functions from the tcb module to the cpu module.
In addition, rename the related trap and functions to avoid mentioning
"rescheduling", as it just makes descriptions more confusing. Instead,
include the name of the module that makes use of this interrupt.
|
|
|
|
Make passing attributes and passing a thread name mandatory.
|
|
Rename THREAD_RESCHEDULE to THREAD_YIELD and thread_reschedule to
thread_yield for better clarity, and add the thread_schedule inline
function that checks for the THREAD_YIELD flag before calling
thread_yield (yielding only checks if preemption is enabled).
|
|
Refer to scheduling class data instead of context.
|
|
|
|
Processor affinity can be set before a thread is created, but currently not
changed afterwards.
|
|
|
|
This change increases clarity.
|
|
Not a necessary change, but done for consistency.
|
|
The correct type for run queue or processor identifiers is unsigned int.
The signed variant was used because of the bitmap interface, but there will
never be enough processors to trigger a problem with it, while using signed
integers can quickly mess things up.
|
|
Balancer threads use their own version of thread_sleep because they have to
keep the run queue locked after pulling threads, otherwise remote balancers
might pull threads from a run queue right before a scheduling decision is
made, possibly putting the run queue in a state where only expired threads
remain.
Although this might be relaxed in the future, this is how it's currently
done, and a clear note in the main balancer function definitely helps against
breaking that part.
|
|
Not required nor used, but done for consistency.
|
|
This module provides lockless synchronization so that reads can safely occur
during updates, without holding a lock. It is based on passive serialization
as described in US patent 4809168, and achieves a goal similar to Linux RCU
(Read-Copy Update).
|
|
The upcoming lockless synchronization implementation requires the idle loop
to report when it's about to enter/leave the idle state. Preemption must be
disabled to accomplish that.
|
|
|
|
|
|
|
|
Rename sched_policy to policy.
|
|
|
|
|
|
|
|
The memory barrier semantics of locks already provide all the required
ordering when checking for pinned threads.
|
|
|
|
Because of the way balancer threads lock their run queue, active threads could
be stolen by remote balancer threads after the local one had determined there
were still active threads on its run queue. If all active threads were pulled
away, the scheduler would run the idle thread whereas there would still be
runnable (expired) threads on the run queue. This change makes balancer threads
keep their run queue locked after checking for active threads and until the
next scheduling decision.
|
|
In order to implement synchronization primitives, the thread_sleep and
thread_wakeup functions are changed so that a thread waiting for an event
can be reliably awaken, without ever missing a wakeup request.
|
|
Instead of using idler threads to provide thread context during bootstrap,
use a fake "booter" thread. This makes the creation of idler threads easier
because they're not (even partially) used while being initialized when
interrupts occur.
|
|
|
|
|
|
Change the name for consistency, move it for better alignment.
|
|
|
|
|
|
This prevents switching from one round to the next (and in turn round
balancing) happening too frequently (or infrequently) when the timer
frequency is increased (or decreased).
|
|
|
|
|
|
Instead of arbitrarily pulling half of the threads of a run queue, take run
queue weights into account.
|
|
The header is actually not used by the thread module.
|
|
It simplifies the logic by not having to keep in mind the variable is volatile.
The balancing algorithm should still work as expected despite using a slightly
expired value.
|
|
|
|
Since initialization takes place with all processors receiving interrupts,
it's completely illegal to access the preemption counter of a remote idler
thread. Create a separate thread_init_common function that doesn't set the
preemption counter to avoid such errors.
|
|
|
|
Make cpu_count() available on kernel entry so that modules (and in particular
the thread module) can allocate per-CPU resources from the BSP. This makes
the initial state stable and simplifies code (no need to check for a transient
early initialization state).
|
|
|
|
|
|
|
|
Instead of maintaining two separate round values, one of which is always the
other plus one, maintain a single integer for both the active and expired
run queues. In addition, improve overflow handling by using signed
subtraction when comparing round values.
|
|
|
|
|
|
This change introduces per run queue balancer threads which regularly scan
remote run queues to balance threads among processors, using a variant of
the distributed weighted round-robin (DWRR) algorithm that directly uses
GR3 instead of WRR as the local scheduling algorithm. In addition, the
thread_wakeup function has been extended to dispatch threads on remote
processors too.
Note that real-time threads are not concerned by this modification.
|