Subversion Repositories HelenOS-historic

Rev

Rev 675 | Rev 775 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 675 Rev 703
Line 30... Line 30...
30
#include <proc/thread.h>
30
#include <proc/thread.h>
31
#include <proc/task.h>
31
#include <proc/task.h>
32
#include <mm/heap.h>
32
#include <mm/heap.h>
33
#include <mm/frame.h>
33
#include <mm/frame.h>
34
#include <mm/page.h>
34
#include <mm/page.h>
35
#include <mm/vm.h>
35
#include <mm/as.h>
36
#include <arch/asm.h>
36
#include <arch/asm.h>
37
#include <arch/faddr.h>
37
#include <arch/faddr.h>
38
#include <arch/atomic.h>
38
#include <arch/atomic.h>
39
#include <synch/spinlock.h>
39
#include <synch/spinlock.h>
40
#include <config.h>
40
#include <config.h>
Line 350... Line 350...
350
 
350
 
351
    /*
351
    /*
352
     * If both the old and the new task are the same, lots of work is avoided.
352
     * If both the old and the new task are the same, lots of work is avoided.
353
     */
353
     */
354
    if (TASK != THREAD->task) {
354
    if (TASK != THREAD->task) {
355
        vm_t *m1 = NULL;
355
        as_t *as1 = NULL;
356
        vm_t *m2;
356
        as_t *as2;
357
 
357
 
358
        if (TASK) {
358
        if (TASK) {
359
            spinlock_lock(&TASK->lock);
359
            spinlock_lock(&TASK->lock);
360
            m1 = TASK->vm;
360
            as1 = TASK->as;
361
            spinlock_unlock(&TASK->lock);
361
            spinlock_unlock(&TASK->lock);
362
        }
362
        }
363
 
363
 
364
        spinlock_lock(&THREAD->task->lock);
364
        spinlock_lock(&THREAD->task->lock);
365
        m2 = THREAD->task->vm;
365
        as2 = THREAD->task->as;
366
        spinlock_unlock(&THREAD->task->lock);
366
        spinlock_unlock(&THREAD->task->lock);
367
       
367
       
368
        /*
368
        /*
369
         * Note that it is possible for two tasks to share one vm mapping.
369
         * Note that it is possible for two tasks to share one address space.
370
         */
370
         */
371
        if (m1 != m2) {
371
        if (as1 != as2) {
372
            /*
372
            /*
373
             * Both tasks and vm mappings are different.
373
             * Both tasks and address spaces are different.
374
             * Replace the old one with the new one.
374
             * Replace the old one with the new one.
375
             */
375
             */
376
            vm_install(m2);
376
            as_install(as2);
377
        }
377
        }
378
        TASK = THREAD->task;   
378
        TASK = THREAD->task;   
379
    }
379
    }
380
 
380
 
381
    THREAD->state = Running;
381
    THREAD->state = Running;