Changeset fe19611 in mainline for generic/src/proc/scheduler.c


Ignore:
Timestamp:
2006-06-04T17:15:27Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c4e4507
Parents:
8adafa0
Message:

thread_join_timeout() and thread_detach() implementation.
Needs more thorough testing.

File:
1 edited

Legend:

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

    r8adafa0 rfe19611  
    4141#include <mm/page.h>
    4242#include <mm/as.h>
     43#include <time/delay.h>
    4344#include <arch/asm.h>
    4445#include <arch/faddr.h>
     
    375376
    376377                    case Exiting:
    377                         thread_destroy(THREAD);
     378repeat:
     379                        if (THREAD->detached) {
     380                                thread_destroy(THREAD);
     381                        } else {
     382                                /*
     383                                 * The thread structure is kept allocated until somebody
     384                                 * calls thread_detach() on it.
     385                                 */
     386                                if (!spinlock_trylock(&THREAD->join_wq.lock)) {
     387                                        /*
     388                                         * Avoid deadlock.
     389                                         */
     390                                        spinlock_unlock(&THREAD->lock);
     391                                        delay(10);
     392                                        spinlock_lock(&THREAD->lock);
     393                                        goto repeat;
     394                                }
     395                                _waitq_wakeup_unsafe(&THREAD->join_wq, false);
     396                                spinlock_unlock(&THREAD->join_wq.lock);
     397                               
     398                                THREAD->state = Undead;
     399                                spinlock_unlock(&THREAD->lock);
     400                        }
    378401                        break;
    379402                       
Note: See TracChangeset for help on using the changeset viewer.