|
Definition at line 59 of file task.c. Referenced by task_run_program(). |
|
Definition at line 45 of file scheduler.h. Referenced by relink_rq(). |
|
Definition at line 44 of file scheduler.h. Referenced by cpu_init(), find_best_thread(), kcpulb(), relink_rq(), sched_print_list(), and thread_ready(). |
|
Definition at line 177 of file thread.h. Referenced by kinit(), ktaskclnp(), and ktaskgc(). |
|
Definition at line 78 of file thread.h. Referenced by sys_thread_create(), and thread_create(). |
|
Thread states. Definition at line 53 of file thread.h. Referenced by before_thread_runs_arch(), thread_create(), and userspace(). |
|
Definition at line 76 of file thread.h. Referenced by kcpulb(). |
|
Definition at line 75 of file thread.h. Referenced by kcpulb(), kinit(), and thread_ready(). |
|
Structure passed to uinit kernel thread as argument. |
|
|
|
|
|
Take actions after THREAD had run. Perform actions that need to be taken after the running thread had been preempted by the scheduler. THREAD->lock is locked on entry Definition at line 114 of file scheduler.c. References after_thread_ran_arch(). Referenced by scheduler_separated_stack(). Here is the call graph for this function: ![]() |
|
Definition at line 76 of file scheduler.c. Referenced by after_thread_ran(). |
|
Carry out actions before new task runs. Definition at line 72 of file scheduler.c. References before_task_runs_arch(). Referenced by scheduler_separated_stack(). Here is the call graph for this function: ![]() |
|
Perform ia32 specific tasks needed before the new task is run. Interrupts are disabled. Definition at line 50 of file scheduler.c. References io_perm_bitmap_install(). Referenced by before_task_runs(). Here is the call graph for this function: ![]() |
|
Take actions before new thread runs. Perform actions that need to be taken before the newly selected tread is passed control. THREAD->lock is locked on entry Definition at line 86 of file scheduler.c. References before_thread_runs_arch(), CPU, fpu_context_restore(), fpu_disable(), fpu_enable(), fpu_init(), and THREAD. Referenced by scheduler_separated_stack(). Here is the call graph for this function: ![]() |
|
Perform ia32 specific tasks needed before the new thread is scheduled. THREAD is locked and interrupts are disabled. Definition at line 59 of file scheduler.c. References CPU, KDATA_DES, selector, set_tls_desc(), SP_DELTA, THREAD, and THREAD_STACK_SIZE. Referenced by before_thread_runs(). Here is the call graph for this function: ![]() |
|
Thread wrapper This wrapper is provided to ensure that every thread makes a call to thread_exit() when its implementing function returns. interrupts_disable() is assumed. Definition at line 109 of file thread.c. References f, interrupts_enable(), spinlock_unlock(), THREAD, and thread_exit(). Referenced by thread_create(). Here is the call graph for this function: ![]() |
|
Get thread to be scheduled Get the optimal thread to be scheduled according to thread accounting and scheduler policy.
Definition at line 179 of file scheduler.c. References ASSERT, atomic_get(), CPU, cpu_sleep(), interrupts_disable(), interrupts_enable(), runq::n, NULL, RQ_COUNT, spinlock_lock, and spinlock_unlock(). Referenced by scheduler_separated_stack(). Here is the call graph for this function: ![]() |
|
Load balancing thread SMP load balancing thread, supervising thread supplies for the CPU it's wired to.
Definition at line 518 of file scheduler.c. References atomic_dec(), atomic_get(), config, count, CPU, config_t::cpu_active, cpus, Entering, thread::flags, thread::fpu_context_engaged, interrupts_disable(), interrupts_restore(), list_get_instance, list_remove(), runq::n, cpu::nrdy, nrdy, NULL, link::prev, printf(), cpu::rq, RQ_COUNT, runq::rq_head, thread::rq_link, spinlock_lock, spinlock_unlock(), thread::state, THREAD, thread_detach(), thread_ready(), thread_sleep(), thread::tid, X_STOLEN, and X_WIRED. Referenced by kinit(). Here is the call graph for this function: ![]() |
|
Kernel thread used to cleanup the task after it is killed. Definition at line 374 of file task.c. References ASSERT, futex_cleanup(), interrupts_disable(), interrupts_restore(), ipc_cleanup(), thread::join_type, klog_printf(), list_get_instance, link::next, None, NULL, scheduler(), spinlock_lock, spinlock_unlock(), TASK, TaskClnp, THREAD, thread_detach(), and thread_join. Referenced by task_kill(). Here is the call graph for this function: ![]() |
|
Kernel thread used to kill the userspace task when its main thread exits. This thread waits until the main userspace thread (i.e. uninit) exits. When this happens, the task is killed. In the meantime, exited threads are garbage collected.
Definition at line 451 of file task.c. References ESYNCH_TIMEOUT, interrupts_disable(), interrupts_restore(), thread::join_type, list_get_instance, link::next, None, NULL, scheduler(), spinlock_lock, spinlock_unlock(), thread::state, SYNCH_FLAGS_NONE, TASK, task_kill(), TaskGC, thread_detach(), thread_join, thread_join_timeout(), and Undead. Referenced by task_run_program(). Here is the call graph for this function: ![]() |
|
Prevent rq starvation Prevent low priority threads from starving in rq's. When the function decides to relink rq's, it reconnects respective pointers so that in result threads with 'pri' greater or equal start are moved to a higher-priority queue.
Definition at line 261 of file scheduler.c. References CPU, list_concat(), list_initialize(), runq::n, NEEDS_RELINK_MAX, RQ_COUNT, runq::rq_head, spinlock_lock, and spinlock_unlock(). Referenced by scheduler_separated_stack(). Here is the call graph for this function: ![]() |
|
Print information about threads & scheduler queues Definition at line 659 of file scheduler.c. References atomic_get(), config, config_t::cpu_count, cpus, interrupts_disable(), list_get_instance, runq::n, link::next, nrdy, printf(), RQ_COUNT, runq::rq_head, spinlock_lock, spinlock_unlock(), thread::state, thread_states, and thread::tid. Referenced by cmd_sched(). Here is the call graph for this function: ![]() |
|
The scheduler The thread scheduling procedure. Passes control directly to scheduler_separated_stack(). Definition at line 299 of file scheduler.c. References ASSERT, atomic_get(), context_restore(), context_save, context_set, CPU, CPU_STACK_SIZE, FADDR, fpu_context_save(), halt(), haltstate, interrupts_disable(), interrupts_restore(), NULL, scheduler_separated_stack(), spinlock_lock, spinlock_unlock(), THE, the_copy(), and THREAD. Referenced by ktaskclnp(), ktaskgc(), main_ap_separated_stack(), main_bsp_separated_stack(), thread_exit(), and waitq_sleep_timeout_unsafe(). Here is the call graph for this function: ![]() |
|
Referenced by nm_fault(). |
|
Initialize scheduler Initialize kernel scheduler. Definition at line 166 of file scheduler.c. Referenced by main_bsp_separated_stack(). |
|
Scheduler stack switch wrapper Second part of the scheduler() function using new stack. Handling the actual context switch to a new thread. Assume THREAD->lock is held. Definition at line 366 of file scheduler.c. References _waitq_wakeup_unsafe(), after_thread_ran(), as_switch(), ASSERT, atomic_get(), before_task_runs(), before_thread_runs(), context_restore(), CPU, delay(), Exiting, find_best_thread(), NULL, panic, printf(), relink_rq(), Running, Sleeping, spinlock_lock, spinlock_trylock(), spinlock_unlock(), TASK, THE, the_copy(), THREAD, thread_destroy(), thread_ready(), thread_states, and Undead. Referenced by scheduler(). Here is the call graph for this function: ![]() |
|
|
|
Lock protecting the threads_btree B+tree. For locking rules, see declaration thereof. |
|
Spinlock protecting the tasks_btree B+tree. |
|
Syscall for reading task ID from userspace.
Definition at line 243 of file task.c. References copy_to_uspace(), and TASK. Here is the call graph for this function: ![]() |
|
Process syscall to create new thread. Definition at line 576 of file thread.c. References copy_from_uspace(), ENOMEM, free(), malloc(), TASK, thread_create(), THREAD_NAME_BUFLEN, thread_ready(), thread::tid, and uinit(). Here is the call graph for this function: ![]() |
|
Process syscall to terminate thread. Definition at line 609 of file thread.c. References thread_exit(). Here is the call graph for this function: ![]() |
|
Create new task Create new task with no threads.
Definition at line 102 of file task.c. References task::accept_new_threads, task::active_calls, task::answerbox, task::as, atomic_set(), btree_create(), btree_insert(), task::capabilities, task::futexes, task::futexes_lock, interrupts_disable(), interrupts_restore(), ipc_answerbox_init(), ipc_phone_0, ipc_phone_connect(), ipc_phone_init(), list_initialize(), task::main_thread, malloc(), mutex_initialize(), mutex_lock, mutex_unlock(), task::name, NULL, task::phones, task::refcount, spinlock_initialize(), spinlock_lock, spinlock_unlock(), task_counter, task_create_arch(), task::taskid, tasks_btree, tasks_lock, and task::th_head. Referenced by main_bsp_separated_stack(), and task_run_program(). Here is the call graph for this function: ![]() |
|
Perform ia32 specific task initialization.
Definition at line 44 of file task.c. References task::arch, bitmap_initialize(), task_arch_t::iomap, task_arch_t::iomapver, and NULL. Referenced by task_create(). Here is the call graph for this function: ![]() |
|
Destroy task.
Definition at line 157 of file task.c. References task::as, as_destroy(), btree_destroy(), free(), task::futexes, mutex_lock_active, mutex_unlock(), NULL, TASK, and task_destroy_arch(). Referenced by thread_destroy(). Here is the call graph for this function: ![]() |
|
Perform ia32 specific task destruction.
Definition at line 54 of file task.c. References task::arch, free(), task_arch_t::iomap, and bitmap_t::map. Referenced by task_destroy(). Here is the call graph for this function: ![]() |
|
Find task structure corresponding to task ID. The tasks_lock must be already held by the caller of this function and interrupts must be disabled.
Definition at line 261 of file task.c. References btree_search(), and tasks_btree. Referenced by ddi_iospace_enable(), ipc_print_task(), sys_cap_grant(), sys_cap_revoke(), and task_kill(). Here is the call graph for this function: ![]() |
|
Initialize tasks Initialize kernel tasks support. Definition at line 85 of file task.c. References btree_create(), NULL, TASK, and tasks_btree. Referenced by main_bsp_separated_stack(). Here is the call graph for this function: ![]() |
|
Kill task.
Definition at line 274 of file task.c. References task::accept_new_threads, btree_remove(), ENOENT, EPERM, thread::interrupted, interrupts_disable(), interrupts_restore(), ktaskclnp(), list_get_instance, link::next, NULL, task::refcount, Sleeping, spinlock_lock, spinlock_unlock(), thread::state, task_find_by_id(), task::taskid, tasks_btree, tasks_lock, task::th_head, thread_create(), thread_ready(), and waitq_interrupt_sleep(). Referenced by ktaskgc(), and syscall_handler(). Here is the call graph for this function: ![]() |
|
Print task list Definition at line 337 of file task.c. References atomic_get(), interrupts_disable(), btree_node::keys, btree::leaf_head, list_get_instance, link::next, printf(), spinlock_lock, spinlock_unlock(), tasks_btree, tasks_lock, and btree_node::value. Referenced by cmd_tasks(). Here is the call graph for this function: ![]() |
|
Create new task with 1 thread and run it
Definition at line 184 of file task.c. References anon_backend, AS_AREA_CACHEABLE, as_area_create(), AS_AREA_READ, AS_AREA_WRITE, as_create(), as_destroy(), ASSERT, EE_OK, elf_load(), ktaskgc(), LOADED_PROG_STACK_PAGES_NO, malloc(), NULL, PAGE_SIZE, task_create(), thread_create(), thread_ready(), uinit(), uspace_arg::uspace_entry, uspace_arg::uspace_stack, uspace_arg::uspace_thread_arg, uspace_arg::uspace_thread_function, and uspace_arg::uspace_uarg. Here is the call graph for this function: ![]() |
|
Copy THE structure Copy the source THE structure to the destination THE structure.
Definition at line 70 of file the.c. Referenced by main_ap(), scheduler(), and scheduler_separated_stack(). |
|
Initialize THE structure Initialize THE structure passed as argument.
Definition at line 54 of file the.c. References the::as, the::cpu, NULL, the::preemption_disabled, the::task, and the::thread. Referenced by main_ap(), main_bsp_separated_stack(), and thread_create(). |
|
Initialization and allocation for thread_t structure Definition at line 124 of file thread.c. References fpu_context_slab, frame_alloc_rc, FRAME_KA, thread::kstack, link_initialize(), NULL, PFN2ADDR(), thread::rq_link, thread::saved_fpu_context, slab_alloc(), slab_free(), spinlock_initialize(), STACK_FRAMES, thread::th_link, and thread::wq_link. Referenced by thread_init(). Here is the call graph for this function: ![]() |
|
Destruction of thread_t object Definition at line 159 of file thread.c. References ADDR2PFN(), fpu_context_slab, frame_free(), thread::kstack, thread::saved_fpu_context, and slab_free(). Referenced by thread_init(). Here is the call graph for this function: ![]() |
|
|
Perform ia32 specific thread initialization.
Definition at line 41 of file thread.c. References thread::arch, and thread_arch_t::tls. Referenced by thread_create(). |
|
Destroy thread memory structure Detach thread from all queues, cpus etc. and destroy it. Assume thread->lock is held!! Definition at line 244 of file thread.c. References ASSERT, btree_remove(), thread::cpu, Exiting, cpu::fpu_owner, list_remove(), NULL, slab_free(), spinlock_lock, spinlock_unlock(), thread::state, thread::task, task_destroy(), thread_slab, threads_btree, threads_lock, and Undead. Referenced by scheduler_separated_stack(), and thread_detach(). Here is the call graph for this function: ![]() |
|
Detach thread. Mark the thread as detached, if the thread is already in the Undead state, deallocate its resources.
Definition at line 461 of file thread.c. References ASSERT, thread::detached, interrupts_disable(), interrupts_restore(), spinlock_lock, spinlock_unlock(), thread::state, thread_destroy(), and Undead. Referenced by kcpulb(), kinit(), ktaskclnp(), and ktaskgc(). Here is the call graph for this function: ![]() |
|
Check whether thread exists. Note that threads_lock must be already held and interrupts must be already disabled.
Definition at line 566 of file thread.c. References btree_search(), NULL, and threads_btree. Referenced by waitq_interrupt_sleep(), and waitq_timeouted_sleep(). Here is the call graph for this function: ![]() |
|
Terminate thread. End current thread execution and switch it to the exiting state. All pending timeouts are executed. Definition at line 388 of file thread.c. References Exiting, interrupts_disable(), interrupts_restore(), scheduler(), spinlock_lock, spinlock_unlock(), and THREAD. Referenced by cushion(), exc_dispatch(), sys_thread_exit(), and syscall_handler(). Here is the call graph for this function: ![]() |
|
Initialize threads Initialize kernel threads support. Definition at line 176 of file thread.c. References atomic_set(), btree_create(), FPU_CONTEXT_ALIGN, fpu_context_slab, nrdy, NULL, slab_cache_create(), thr_constructor(), thr_destructor(), THREAD, thread_slab, and threads_btree. Referenced by main_bsp_separated_stack(). Here is the call graph for this function: ![]() |
|
Wait for another thread to exit.
Definition at line 430 of file thread.c. References ASSERT, thread::detached, EINVAL, interrupts_disable(), interrupts_restore(), thread::join_wq, spinlock_lock, spinlock_unlock(), THREAD, and waitq_sleep_timeout(). Referenced by ktaskgc(). Here is the call graph for this function: ![]() |
|
Print list of threads debug info Definition at line 521 of file thread.c. References interrupts_disable(), btree_node::keys, btree::leaf_head, list_get_instance, link::next, printf(), Sleeping, spinlock_lock, thread_states, threads_btree, threads_lock, and btree_node::value. Referenced by cmd_threads(). Here is the call graph for this function: ![]() |
|
Make thread ready Switch thread t to the ready state.
Definition at line 200 of file thread.c. References ASSERT, atomic_get(), atomic_inc(), config, thread::cpu, CPU, config_t::cpu_active, thread::flags, interrupts_disable(), interrupts_restore(), list_append(), runq::n, cpu::nrdy, nrdy, thread::priority, Ready, cpu::rq, RQ_COUNT, runq::rq_head, thread::rq_link, spinlock_lock, spinlock_unlock(), thread::state, and X_WIRED. Referenced by _waitq_wakeup_unsafe(), kcpulb(), kinit(), main_bsp_separated_stack(), scheduler_separated_stack(), sys_thread_create(), task_kill(), task_run_program(), waitq_interrupt_sleep(), and waitq_timeouted_sleep(). Here is the call graph for this function: ![]() |
|
Register thread out-of-context invocation Register a function and its argument to be executed on next context switch to the current thread.
Definition at line 508 of file thread.c. References interrupts_disable(), interrupts_restore(), spinlock_lock, spinlock_unlock(), and THREAD. Referenced by _rwlock_read_lock_timeout(). Here is the call graph for this function: ![]() |
|
Thread sleep Suspend execution of the current thread.
Definition at line 417 of file thread.c. References thread_usleep(). Referenced by kcpulb(). Here is the call graph for this function: ![]() |
|
Thread usleep Suspend execution of the current thread.
Definition at line 490 of file thread.c. References SYNCH_FLAGS_NON_BLOCKING, waitq_initialize(), and waitq_sleep_timeout(). Referenced by thread_sleep(). Here is the call graph for this function: ![]() |
|
Referenced by thr_constructor(), thr_destructor(), and thread_init(). |
|
Definition at line 93 of file thread.c. Referenced by thread_create(). |
|
Number of ready threads in the system. Definition at line 69 of file scheduler.c. Referenced by kcpulb(), sched_print_list(), thread_init(), and thread_ready(). |
|
Number of ready threads in the system. Definition at line 69 of file scheduler.c. Referenced by kcpulb(), sched_print_list(), thread_init(), and thread_ready(). |
|
Definition at line 75 of file task.c. Referenced by task_create(). |
|
B+tree of active tasks. The task is guaranteed to exist after it was found in the tasks_btree as long as:
Definition at line 73 of file task.c. Referenced by task_create(), task_find_by_id(), task_init(), task_kill(), and task_print_list(). |
|
B+tree of active tasks. The task is guaranteed to exist after it was found in the tasks_btree as long as:
Definition at line 73 of file task.c. Referenced by task_create(), task_find_by_id(), task_init(), task_kill(), and task_print_list(). |
|
Referenced by ddi_iospace_enable(), ipc_print_task(), sys_cap_grant(), sys_cap_revoke(), task_create(), task_kill(), and task_print_list(). |
|
Definition at line 95 of file thread.c. Referenced by thread_create(), thread_destroy(), and thread_init(). |
|
Initial value: { "Invalid", "Running", "Sleeping", "Ready", "Entering", "Exiting", "Undead" } Definition at line 72 of file thread.c. Referenced by sched_print_list(), scheduler_separated_stack(), and thread_print_list(). |
|
Thread states Definition at line 72 of file thread.c. Referenced by sched_print_list(), scheduler_separated_stack(), and thread_print_list(). |
|
B+tree of all threads. When a thread is found in the threads_btree B+tree, it is guaranteed to exist as long as the threads_lock is held. Definition at line 90 of file thread.c. Referenced by thread_create(), thread_destroy(), thread_exists(), thread_init(), and thread_print_list(). |
|
B+tree of all threads. When a thread is found in the threads_btree B+tree, it is guaranteed to exist as long as the threads_lock is held. Definition at line 90 of file thread.c. Referenced by thread_create(), thread_destroy(), thread_exists(), thread_init(), and thread_print_list(). |
|
Thread list lock. This lock protects all link_t structures chained in threads_head. Must be acquired before T.lock for each T of type thread_t. Referenced by thread_create(), thread_destroy(), thread_print_list(), waitq_interrupt_sleep(), and waitq_timeouted_sleep(). |