generic
[Scheduling]


Files

file  scheduler.h
file  task.h
file  thread.h
file  uarg.h
file  scheduler.c
 Scheduler and load balancing.
file  task.c
 Task management.
file  the.c
 THE structure functions.
file  thread.c
 Thread management functions.

Data Structures

struct  runq
struct  task
struct  thread
struct  uspace_arg

Defines

#define RQ_COUNT   16
#define NEEDS_RELINK_MAX   (HZ)
#define THREAD_STACK_SIZE   STACK_SIZE
#define X_WIRED   (1<<0)
#define X_STOLEN   (1<<1)
#define THREAD_NAME_BUFLEN   20
#define thread_join(t)   thread_join_timeout((t), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE)
#define LOADED_PROG_STACK_PAGES_NO   1

Typedefs

typedef uspace_arg uspace_arg_t

Enumerations

enum  state {
  Invalid, Running, Sleeping, Ready,
  Entering, Exiting, Undead
}
enum  thread_join_type_t { None, TaskClnp, TaskGC }

Functions

void scheduler_init (void)
void scheduler_fpu_lazy_request (void)
void scheduler (void)
void kcpulb (void *arg)
void sched_print_list (void)
void before_task_runs_arch (void)
void before_thread_runs_arch (void)
void after_thread_ran_arch (void)
void task_init (void)
task_ttask_create (as_t *as, char *name)
void task_destroy (task_t *t)
task_ttask_run_program (void *program_addr, char *name)
task_ttask_find_by_id (task_id_t id)
int task_kill (task_id_t id)
void task_create_arch (task_t *t)
void task_destroy_arch (task_t *t)
__native sys_task_get_id (task_id_t *uspace_task_id)
void thread_init (void)
thread_tthread_create (void(*func)(void *), void *arg, task_t *task, int flags, char *name)
void thread_ready (thread_t *t)
void thread_exit (void) __attribute__((noreturn))
void thread_create_arch (thread_t *t)
void thread_sleep (__u32 sec)
void thread_usleep (__u32 usec)
int thread_join_timeout (thread_t *t, __u32 usec, int flags)
void thread_detach (thread_t *t)
void thread_register_call_me (void(*call_me)(void *), void *call_me_with)
void thread_print_list (void)
void thread_destroy (thread_t *t)
bool thread_exists (thread_t *t)
__native sys_thread_create (uspace_arg_t *uspace_uarg, char *uspace_name)
__native sys_thread_exit (int uspace_status)
static void before_task_runs (void)
static void before_thread_runs (void)
static void after_thread_ran (void)
static void scheduler_separated_stack (void)
static thread_tfind_best_thread (void)
static void relink_rq (int start)
 SPINLOCK_INITIALIZE (tasks_lock)
static void ktaskclnp (void *arg)
static void ktaskgc (void *arg)
void task_print_list (void)
void the_initialize (the_t *the)
void the_copy (the_t *src, the_t *dst)
 SPINLOCK_INITIALIZE (threads_lock)
 SPINLOCK_INITIALIZE (tidlock)
static void cushion (void)
static int thr_constructor (void *obj, int kmflags)
static int thr_destructor (void *obj)

Variables

atomic_t nrdy
spinlock_t tasks_lock
btree_t tasks_btree
char * thread_states []
spinlock_t threads_lock
btree_t threads_btree
slab_cache_tfpu_context_slab
atomic_t nrdy
btree_t tasks_btree
static task_id_t task_counter = 0
char * thread_states []
btree_t threads_btree
__u32 last_tid = 0
static slab_cache_tthread_slab

Define Documentation

#define LOADED_PROG_STACK_PAGES_NO   1
 

Definition at line 59 of file task.c.

Referenced by task_run_program().

#define NEEDS_RELINK_MAX   (HZ)
 

Definition at line 45 of file scheduler.h.

Referenced by relink_rq().

#define RQ_COUNT   16
 

Definition at line 44 of file scheduler.h.

Referenced by cpu_init(), find_best_thread(), kcpulb(), relink_rq(), sched_print_list(), and thread_ready().

#define thread_join  )     thread_join_timeout((t), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE)
 

Definition at line 177 of file thread.h.

Referenced by kinit(), ktaskclnp(), and ktaskgc().

#define THREAD_NAME_BUFLEN   20
 

Definition at line 78 of file thread.h.

Referenced by sys_thread_create(), and thread_create().

#define THREAD_STACK_SIZE   STACK_SIZE
 

Thread states.

Definition at line 53 of file thread.h.

Referenced by before_thread_runs_arch(), thread_create(), and userspace().

#define X_STOLEN   (1<<1)
 

Definition at line 76 of file thread.h.

Referenced by kcpulb().

#define X_WIRED   (1<<0)
 

Definition at line 75 of file thread.h.

Referenced by kcpulb(), kinit(), and thread_ready().


Typedef Documentation

typedef struct uspace_arg uspace_arg_t
 

Structure passed to uinit kernel thread as argument.


Enumeration Type Documentation

enum state
 

Enumerator:
Invalid  It is an error, if thread is found in this state.
Running  State of a thread that is currently executing on some CPU.
Sleeping  Thread in this state is waiting for an event.
Ready  State of threads in a run queue.
Entering  Threads are in this state before they are first readied.
Exiting  After a thread calls thread_exit(), it is put into Exiting state.
Undead  Threads that were not detached but exited are in the Undead state.

Definition at line 56 of file thread.h.

enum thread_join_type_t
 

Enumerator:
None 
TaskClnp  The thread will be joined by ktaskclnp thread.
TaskGC  The thread will be joined by ktaskgc thread.

Definition at line 69 of file thread.h.


Function Documentation

void after_thread_ran void   )  [static]
 

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:

void after_thread_ran_arch void   ) 
 

Definition at line 58 of file scheduler.c.

Referenced by after_thread_ran().

void before_task_runs void   )  [static]
 

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:

void before_task_runs_arch void   ) 
 

Perform ppc64 specific tasks needed before the new task is run.

Definition at line 42 of file scheduler.c.

Referenced by before_task_runs().

void before_thread_runs void   )  [static]
 

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:

void before_thread_runs_arch void   ) 
 

Perform ppc64 specific tasks needed before the new thread is scheduled.

Definition at line 47 of file scheduler.c.

References pht_init(), SP_DELTA, THREAD, THREAD_STACK_SIZE, and tlb_invalidate_all().

Referenced by before_thread_runs().

Here is the call graph for this function:

static void cushion void   )  [static]
 

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:

static thread_t* find_best_thread void   )  [static]
 

Get thread to be scheduled

Get the optimal thread to be scheduled according to thread accounting and scheduler policy.

Returns:
Thread to be scheduled.

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:

void kcpulb void *  arg  ) 
 

Load balancing thread

SMP load balancing thread, supervising thread supplies for the CPU it's wired to.

Parameters:
arg Generic thread argument (unused).

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:

void ktaskclnp void *  arg  )  [static]
 

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:

void ktaskgc void *  arg  )  [static]
 

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.

Parameters:
arg Pointer to the thread structure of the task's main thread.

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:

static void relink_rq int  start  )  [static]
 

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.

Parameters:
start Threshold priority.

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:

void sched_print_list void   ) 
 

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:

void scheduler void   ) 
 

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:

void scheduler_fpu_lazy_request void   ) 
 

void scheduler_init void   ) 
 

Initialize scheduler

Initialize kernel scheduler.

Definition at line 166 of file scheduler.c.

Referenced by main_bsp_separated_stack().

void scheduler_separated_stack void   )  [static]
 

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:

SPINLOCK_INITIALIZE tidlock   ) 
 

SPINLOCK_INITIALIZE threads_lock   ) 
 

Lock protecting the threads_btree B+tree. For locking rules, see declaration thereof.

SPINLOCK_INITIALIZE tasks_lock   ) 
 

Spinlock protecting the tasks_btree B+tree.

__native sys_task_get_id task_id_t uspace_task_id  ) 
 

Syscall for reading task ID from userspace.

Parameters:
uspace_task_id Userspace address of 8-byte buffer where to store current task ID.
Returns:
0 on success or an error code from errno.h.

Definition at line 243 of file task.c.

References copy_to_uspace(), and TASK.

Here is the call graph for this function:

__native sys_thread_create uspace_arg_t uspace_uarg,
char *  uspace_name
 

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:

__native sys_thread_exit int  uspace_status  ) 
 

Process syscall to terminate thread.

Definition at line 609 of file thread.c.

References thread_exit().

Here is the call graph for this function:

task_t * task_create as_t as,
char *  name
 

Create new task

Create new task with no threads.

Parameters:
as Task's address space.
name Symbolic name.
Returns:
New task's structure

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:

void task_create_arch task_t t  ) 
 

void task_destroy task_t t  ) 
 

Destroy task.

Parameters:
t Task to be destroyed.

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:

void task_destroy_arch task_t t  ) 
 

task_t * task_find_by_id task_id_t  id  ) 
 

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.

Parameters:
id Task ID.
Returns:
Task structure address or NULL if there is no such task ID.

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:

void task_init void   ) 
 

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:

int task_kill task_id_t  id  ) 
 

Kill task.

Parameters:
id ID of the task to be killed.
Returns:
0 on success or an error code from errno.h

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:

void task_print_list void   ) 
 

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:

task_t * task_run_program void *  program_addr,
char *  name
 

Create new task with 1 thread and run it

Parameters:
program_addr Address of program executable image.
name Program name.
Returns:
Task of the running program or NULL on error.

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:

void the_copy the_t src,
the_t dst
 

Copy THE structure

Copy the source THE structure to the destination THE structure.

Parameters:
src The source THE structure.
dst The destination THE structure.

Definition at line 70 of file the.c.

Referenced by main_ap(), scheduler(), and scheduler_separated_stack().

void the_initialize the_t the  ) 
 

Initialize THE structure

Initialize THE structure passed as argument.

Parameters:
the THE structure to be initialized.

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().

static int thr_constructor void *  obj,
int  kmflags
[static]
 

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:

static int thr_destructor void *  obj  )  [static]
 

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:

thread_t * thread_create void(*)(void *)  func,
void *  arg,
task_t task,
int  flags,
char *  name
 

Create new thread

Create a new thread.

Parameters:
func Thread's implementing function.
arg Thread's implementing function argument.
task Task to which the thread belongs.
flags Thread flags.
name Symbolic name.
Returns:
New thread's structure on success, NULL on failure.

Definition at line 293 of file thread.c.

References task::accept_new_threads, btree_insert(), thread::call_me, thread::call_me_with, context_save, context_set, thread::cpu, cushion(), thread::detached, Entering, FADDR, thread::flags, thread::fpu_context_engaged, thread::fpu_context_exists, thread::in_copy_from_uspace, thread::in_copy_to_uspace, thread::interrupted, interrupts_disable(), interrupts_read(), interrupts_restore(), context::ipl, thread::join_type, thread::join_wq, thread::kstack, last_tid, list_append(), task::main_thread, memcpy, memsetb(), thread::name, None, NULL, thread::priority, task::refcount, thread::rwlock_holder_type, RWLOCK_NONE, thread::saved_context, slab_alloc(), slab_free(), thread::sleep_interruptible, thread::sleep_queue, thread::sleep_timeout, spinlock_lock, spinlock_unlock(), STACK_FRAMES, thread::state, thread::task, task::th_head, thread::th_link, the_initialize(), thread::thread_arg, thread::thread_code, thread_create_arch, THREAD_NAME_BUFLEN, thread_slab, THREAD_STACK_SIZE, threads_btree, threads_lock, thread::ticks, thread::tid, timeout_initialize(), thread::timeout_pending, and waitq_initialize().

Referenced by kinit(), main_bsp_separated_stack(), sys_thread_create(), task_kill(), and task_run_program().

Here is the call graph for this function:

void thread_create_arch thread_t t  ) 
 

void thread_destroy thread_t t  ) 
 

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:

void thread_detach thread_t t  ) 
 

Detach thread.

Mark the thread as detached, if the thread is already in the Undead state, deallocate its resources.

Parameters:
t Thread to be detached.

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:

bool thread_exists thread_t t  ) 
 

Check whether thread exists.

Note that threads_lock must be already held and interrupts must be already disabled.

Parameters:
t Pointer to thread.
Returns:
True if thread t is known to the system, false otherwise.

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:

void thread_exit void   ) 
 

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:

void thread_init void   ) 
 

Initialize threads

Initialize kernel threads support.

Definition at line 176 of file thread.c.

References atomic_set(), btree_create(), 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:

int thread_join_timeout thread_t t,
__u32  usec,
int  flags
 

Wait for another thread to exit.

Parameters:
t Thread to join on exit.
usec Timeout in microseconds.
flags Mode of operation.
Returns:
An error code from errno.h or an error code from synch.h.

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:

void thread_print_list void   ) 
 

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:

void thread_ready thread_t t  ) 
 

Make thread ready

Switch thread t to the ready state.

Parameters:
t Thread to make ready.

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:

void thread_register_call_me void(*)(void *)  call_me,
void *  call_me_with
 

Register thread out-of-context invocation

Register a function and its argument to be executed on next context switch to the current thread.

Parameters:
call_me Out-of-context function.
call_me_with Out-of-context function argument.

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:

void thread_sleep __u32  sec  ) 
 

Thread sleep

Suspend execution of the current thread.

Parameters:
sec Number of seconds to sleep.

Definition at line 417 of file thread.c.

References thread_usleep().

Referenced by kcpulb().

Here is the call graph for this function:

void thread_usleep __u32  usec  ) 
 

Thread usleep

Suspend execution of the current thread.

Parameters:
usec Number of microseconds to sleep.

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:


Variable Documentation

slab_cache_t* fpu_context_slab
 

Referenced by thr_constructor(), thr_destructor(), and thread_init().

__u32 last_tid = 0
 

Definition at line 93 of file thread.c.

Referenced by thread_create().

atomic_t nrdy
 

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().

atomic_t nrdy
 

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().

task_id_t task_counter = 0 [static]
 

Definition at line 75 of file task.c.

Referenced by task_create().

btree_t tasks_btree
 

B+tree of active tasks.

The task is guaranteed to exist after it was found in the tasks_btree as long as:

  • the tasks_lock is held,
  • the task's lock is held when task's lock is acquired before releasing tasks_lock or
  • the task's refcount is grater than 0

Definition at line 73 of file task.c.

Referenced by task_create(), task_find_by_id(), task_init(), task_kill(), and task_print_list().

btree_t tasks_btree
 

B+tree of active tasks.

The task is guaranteed to exist after it was found in the tasks_btree as long as:

  • the tasks_lock is held,
  • the task's lock is held when task's lock is acquired before releasing tasks_lock or
  • the task's refcount is grater than 0

Definition at line 73 of file task.c.

Referenced by task_create(), task_find_by_id(), task_init(), task_kill(), and task_print_list().

spinlock_t tasks_lock
 

Referenced by ddi_iospace_enable(), ipc_print_task(), sys_cap_grant(), sys_cap_revoke(), task_create(), task_kill(), and task_print_list().

slab_cache_t* thread_slab [static]
 

Definition at line 95 of file thread.c.

Referenced by thread_create(), thread_destroy(), and thread_init().

char* thread_states[]
 

Initial value:

 {
        "Invalid",
        "Running",
        "Sleeping",
        "Ready",
        "Entering",
        "Exiting",
        "Undead"
}
Thread states

Definition at line 72 of file thread.c.

Referenced by sched_print_list(), scheduler_separated_stack(), and thread_print_list().

char* thread_states[]
 

Thread states

Definition at line 72 of file thread.c.

Referenced by sched_print_list(), scheduler_separated_stack(), and thread_print_list().

btree_t threads_btree
 

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().

btree_t threads_btree
 

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().

spinlock_t threads_lock
 

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().


Generated on Sun Jun 18 17:32:37 2006 for HelenOS Kernel (ppc64) by  doxygen 1.4.6