Changeset 2569ec90 in mainline for generic/src/proc/task.c


Ignore:
Timestamp:
2006-06-05T18:15:30Z (18 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b65caba1
Parents:
31e8ddd
Message:

In task_kill(), remove the task from the tasks_btree before proceeding.
Thus, when the kernel finds the task in the tasks_btree and locks it before
releasing tasks_lock, it is guaranteed that the task will not be destroyed
until the lock is held. If the kernel needs to unlock the task, do some operation
and lock it again, it should increase its refcount before doing so. In that case,
when releasing the lock, it must decrement the refcount and if it reaches
zero, it must call task_destroy().

File:
1 edited

Legend:

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

    r31e8ddd r2569ec90  
    141141void task_destroy(task_t *t)
    142142{
    143         spinlock_lock(&tasks_lock);
    144         btree_remove(&tasks_btree, t->taskid, NULL);
    145         spinlock_unlock(&tasks_lock);
    146 
    147143        task_destroy_arch(t);
    148144        btree_destroy(&t->futexes);
     
    275271                return ENOENT;
    276272        }
    277        
     273
    278274        spinlock_lock(&ta->lock);
    279275        ta->refcount++;
    280276        spinlock_unlock(&ta->lock);
    281277
     278        btree_remove(&tasks_btree, ta->taskid, NULL);
    282279        spinlock_unlock(&tasks_lock);
    283280       
Note: See TracChangeset for help on using the changeset viewer.