Changeset 97f1691 in mainline for generic/src/proc/scheduler.c


Ignore:
Timestamp:
2006-02-28T00:02:39Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7d6ec87
Parents:
d87c3f3
Message:

sparc64 work.
Fix KBD_VIRT_ADDRESS.
Call before_thread_runs() prior to the switch to the thread's stack. Add comment why this is crucial.
Add after_thread_ran() to the scheduler.
Add before_thread_runs_arch() and after_thread_ran_arch() for sparc64, mapping/demapping thread's kernel stack.
Add dummy after_thread_ran_arch() to all other architectures.
Add dtlb_insert_mapping() to promote code reuse.

File:
1 edited

Legend:

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

    rd87c3f3 r97f1691  
    5050atomic_t nrdy;
    5151
    52 /** Take actions before new thread runs
     52/** Take actions before new thread runs.
    5353 *
    5454 * Perform actions that need to be
     
    7676        }
    7777#endif
     78}
     79
     80/** Take actions after old thread ran.
     81 *
     82 * Perform actions that need to be
     83 * taken after the running thread
     84 * was preempted by the scheduler.
     85 *
     86 * THREAD->lock is locked on entry
     87 *
     88 */
     89void after_thread_ran(void)
     90{
     91        after_thread_ran_arch();
    7892}
    7993
     
    258272
    259273        if (THREAD) {
     274                /* must be run after switch to scheduler stack */
     275                after_thread_ran();
     276
    260277                switch (THREAD->state) {
    261278                    case Running:
     
    301318                        break;
    302319                }
     320
    303321                THREAD = NULL;
    304322        }
     
    350368        printf("cpu%d: tid %d (priority=%d,ticks=%d,nrdy=%d)\n", CPU->id, THREAD->tid, THREAD->priority, THREAD->ticks, atomic_get(&CPU->nrdy));
    351369        #endif 
     370
     371        /*
     372         * Some architectures provide late kernel PA2KA(identity)
     373         * mapping in a page fault handler. However, the page fault
     374         * handler uses the kernel stack of the running thread and
     375         * therefore cannot be used to map it. The kernel stack, if
     376         * necessary, is to be mapped in before_thread_runs(). This
     377         * function must be executed before the switch to the new stack.
     378         */
     379        before_thread_runs();
    352380
    353381        /*
     
    388416                         * This is the place where threads leave scheduler();
    389417                         */
    390                         before_thread_runs();
    391418                        spinlock_unlock(&THREAD->lock);
    392419                        interrupts_restore(THREAD->saved_context.ipl);
Note: See TracChangeset for help on using the changeset viewer.