summaryrefslogtreecommitdiff
path: root/kern/thread.c
AgeCommit message (Collapse)Author
2013-07-01x86/pmap: improve TLB invalidationRichard Braun
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.
2013-06-04x86/{cpu,tcb}: move scheduling interrupts handlingRichard Braun
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.
2013-06-03kern/thread: fix thread creationRichard Braun
2013-06-01kern/thread: update creation attributes handlingRichard Braun
Make passing attributes and passing a thread name mandatory.
2013-06-01kern/thread: slightly rework scheduler invocationRichard Braun
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).
2013-06-01kern/thread: minor naming changeRichard Braun
Refer to scheduling class data instead of context.
2013-05-25kern/thread: make more extensive use of cpumapsRichard Braun
2013-05-19kern/thread: implement processor affinityRichard Braun
Processor affinity can be set before a thread is created, but currently not changed afterwards.
2013-05-16kern/thread: fix wakeup with respect to pinningRichard Braun
2013-05-15kern/list: rename list_insert to list_insert_headRichard Braun
This change increases clarity.
2013-05-15x86/cpu: pass flags by address to cpu_intr_saveRichard Braun
Not a necessary change, but done for consistency.
2013-05-15kern/thread: return unsigned run queue identifiersRichard Braun
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.
2013-05-15kern/thread: add comment about balancer threadsRichard Braun
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.
2013-05-15kern/thread: set the runq member for idler threadsRichard Braun
Not required nor used, but done for consistency.
2013-05-15kern/llsync: new moduleRichard Braun
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).
2013-05-15kern/thread: rework idle loopRichard Braun
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.
2013-05-13kern/thread: make thread_active_runqs privateRichard Braun
2013-05-13kern/thread: fix thread waking on remote run queueRichard Braun
2013-05-12kern/thread: update kernel thread naming rulesRichard Braun
2013-05-12kern/thread: minor name change in struct thread_attrRichard Braun
Rename sched_policy to policy.
2013-05-12kern/thread: fix getting caller task during bootstrapRichard Braun
2013-05-12kern/thread: fix balancer threads policyRichard Braun
2013-05-12kern/thread: fix reaper thread policyRichard Braun
2013-05-09kern/thread: remove an unneeded memory barrierRichard Braun
The memory barrier semantics of locks already provide all the required ordering when checking for pinned threads.
2013-04-15kern/thread: thread destructionRichard Braun
2013-04-13kern/thread: fix inter-processor load balancingRichard Braun
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.
2013-04-08kern/thread: rework thread state handlingRichard Braun
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.
2013-04-08kern/thread: rework bootstrappingRichard Braun
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.
2013-03-18kern/thread: minor comment changesRichard Braun
2013-03-17kern/thread: document schedulingRichard Braun
2013-03-16kern/thread: rename and move the on_rq thread memberRichard Braun
Change the name for consistency, move it for better alignment.
2013-03-16kern/thread: simplify remote wakeupsRichard Braun
2013-03-16kern/thread: don't migrate pinned threadsRichard Braun
2013-03-16kern/thread: scale thread weights on timer frequencyRichard Braun
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).
2013-03-16kern/thread: make thread_schedule privateRichard Braun
2013-03-16kern/thread: regularly attempt to balance when idlingRichard Braun
2013-03-15kern/thread: revised balancing strategyRichard Braun
Instead of arbitrarily pulling half of the threads of a run queue, take run queue weights into account.
2013-03-15kern/thread: don't include kern/printk.hRichard Braun
The header is actually not used by the thread module.
2013-03-15kern/thread: use a stable highest round value when balancingRichard Braun
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.
2013-03-15kern/thread: fix deadlock on inter-processor balancingRichard Braun
2013-03-15kern/thread: fix idler thread initializationRichard Braun
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.
2013-03-15kern/thread: remove the unused cpu thread memberRichard Braun
2013-03-14kern/{kernel,thread}: rework initializationRichard Braun
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).
2013-03-12kern/thread: fix balancer initialization and wakeupRichard Braun
2013-03-12kern/thread: fix and improve round balancingRichard Braun
2013-03-11kern/thread: fix and improve run queue selection on wakeupRichard Braun
2013-03-11kern/thread: optimize round trackingRichard Braun
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.
2013-03-11kern/thread: minor change about kernel thread namingRichard Braun
2013-03-11kern/thread: handle round overflowsRichard Braun
2013-03-11kern/thread: inter-processor load balancingRichard Braun
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.