Changeset 0182a665 in mainline


Ignore:
Timestamp:
2006-06-10T13:40:53Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8060a24c
Parents:
971cf31f
Message:

Fix double thread_join() in ktaskgc.
In thread_create(), lock TASK with interrupts disabled again.
thread_join_timeout() can use ordinary waitq_sleep_timeout().

Location:
generic/src/proc
Files:
2 edited

Legend:

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

    r971cf31f r0182a665  
    301301
    302302        /*
    303          * Interrupt all threads except this one.
     303         * Interrupt all threads except ktaskclnp.
    304304         */     
    305305        for (cur = ta->th_head.next; cur != &ta->th_head; cur = cur->next) {
     
    468468                        thr = list_get_instance(cur, thread_t, th_link);
    469469                        spinlock_lock(&thr->lock);
    470                         if (thr->state == Undead && thr->join_type == None) {
     470                        if (thr != t && thr->state == Undead && thr->join_type == None) {
    471471                                thr->join_type = TaskGC;
    472472                                spinlock_unlock(&thr->lock);
  • generic/src/proc/thread.c

    r971cf31f r0182a665  
    351351         * Attach to the containing task.
    352352         */
     353        ipl = interrupts_disable();     
    353354        spinlock_lock(&task->lock);
    354355        if (!task->accept_new_threads) {
    355356                spinlock_unlock(&task->lock);
    356357                slab_free(thread_slab, t);
     358                interrupts_restore(ipl);
    357359                return NULL;
    358360        }
     
    365367         * Register this thread in the system-wide list.
    366368         */
    367         ipl = interrupts_disable();
    368369        spinlock_lock(&threads_lock);
    369370        btree_insert(&threads_btree, (btree_key_t) ((__address) t), (void *) t, NULL);
     
    375376}
    376377
    377 /** Make thread exiting
     378/** Terminate thread.
    378379 *
    379380 * End current thread execution and switch it to the exiting
     
    438439        ipl = interrupts_disable();
    439440        spinlock_lock(&t->lock);
    440 
    441441        ASSERT(!t->detached);
    442        
    443         (void) waitq_sleep_prepare(&t->join_wq);
    444442        spinlock_unlock(&t->lock);
    445        
    446         rc = waitq_sleep_timeout_unsafe(&t->join_wq, usec, flags);
    447        
    448         waitq_sleep_finish(&t->join_wq, rc, ipl);
    449         interrupts_restore(ipl);
     443        interrupts_restore(ipl);
     444       
     445        rc = waitq_sleep_timeout(&t->join_wq, usec, flags);
    450446       
    451447        return rc;     
     
    467463         * pointer to it must be still valid.
    468464         */
    469        
    470465        ipl = interrupts_disable();
    471466        spinlock_lock(&t->lock);
Note: See TracChangeset for help on using the changeset viewer.