Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/proc/scheduler.c

    r7e752b2 rdf58e44  
    6262#include <print.h>
    6363#include <debug.h>
    64 
    65 static void before_task_runs(void);
    66 static void before_thread_runs(void);
    67 static void after_thread_ran(void);
     64#include <stacktrace.h>
     65
    6866static void scheduler_separated_stack(void);
    6967
     
    7169
    7270/** Carry out actions before new task runs. */
    73 void before_task_runs(void)
     71static void before_task_runs(void)
    7472{
    7573        before_task_runs_arch();
     
    8078 * Perform actions that need to be
    8179 * taken before the newly selected
    82  * tread is passed control.
     80 * thread is passed control.
    8381 *
    8482 * THREAD->lock is locked on entry
    8583 *
    8684 */
    87 void before_thread_runs(void)
     85static void before_thread_runs(void)
    8886{
    8987        before_thread_runs_arch();
     88       
    9089#ifdef CONFIG_FPU_LAZY
    91         if(THREAD == CPU->fpu_owner)
     90        if (THREAD == CPU->fpu_owner)
    9291                fpu_enable();
    9392        else
     
    102101        }
    103102#endif
     103       
     104        if (THREAD->btrace) {
     105                istate_t *istate = THREAD->udebug.uspace_state;
     106                if (istate != NULL) {
     107                        printf("Thread %" PRIu64 " stack trace:\n", THREAD->tid);
     108                        stack_trace_istate(istate);
     109                }
     110               
     111                THREAD->btrace = false;
     112        }
    104113}
    105114
     
    113122 *
    114123 */
    115 void after_thread_ran(void)
     124static void after_thread_ran(void)
    116125{
    117126        after_thread_ran_arch();
     
    391400         * possible destruction should thread_destroy() be called on this or any
    392401         * other processor while the scheduler is still using them.
    393          *
    394402         */
    395403        if (old_task)
     
    417425                                 * The thread structure is kept allocated until
    418426                                 * somebody calls thread_detach() on it.
    419                                  *
    420427                                 */
    421428                                if (!irq_spinlock_trylock(&THREAD->join_wq.lock)) {
    422429                                        /*
    423430                                         * Avoid deadlock.
    424                                          *
    425431                                         */
    426432                                        irq_spinlock_unlock(&THREAD->lock, false);
     
    443449                        /*
    444450                         * Prefer the thread after it's woken up.
    445                          *
    446451                         */
    447452                        THREAD->priority = -1;
     
    451456                         * waitq_sleep(). Address of wq->lock is kept in
    452457                         * THREAD->sleep_queue.
    453                          *
    454458                         */
    455459                        irq_spinlock_unlock(&THREAD->sleep_queue->lock, false);
     
    461465                        /*
    462466                         * Entering state is unexpected.
    463                          *
    464467                         */
    465468                        panic("tid%" PRIu64 ": unexpected state %s.",
     
    480483       
    481484        /*
    482          * If both the old and the new task are the same, lots of work is
    483          * avoided.
    484          *
     485         * If both the old and the new task are the same,
     486         * lots of work is avoided.
    485487         */
    486488        if (TASK != THREAD->task) {
     
    488490               
    489491                /*
    490                  * Note that it is possible for two tasks to share one address
    491                  * space.
    492                  (
     492                 * Note that it is possible for two tasks
     493                 * to share one address space.
    493494                 */
    494495                if (old_as != new_as) {
     
    496497                         * Both tasks and address spaces are different.
    497498                         * Replace the old one with the new one.
    498                          *
    499499                         */
    500500                        as_switch(old_as, new_as);
     
    527527         * necessary, is to be mapped in before_thread_runs(). This
    528528         * function must be executed before the switch to the new stack.
    529          *
    530529         */
    531530        before_thread_runs();
     
    534533         * Copy the knowledge of CPU, TASK, THREAD and preemption counter to
    535534         * thread's stack.
    536          *
    537535         */
    538536        the_copy(THE, (the_t *) THREAD->kstack);
     
    658656                                /*
    659657                                 * Ready thread on local CPU
    660                                  *
    661658                                 */
    662659                               
Note: See TracChangeset for help on using the changeset viewer.