Subversion Repositories HelenOS

Rev

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

Rev 2446 Rev 2451
Line 76... Line 76...
76
    "Running",
76
    "Running",
77
    "Sleeping",
77
    "Sleeping",
78
    "Ready",
78
    "Ready",
79
    "Entering",
79
    "Entering",
80
    "Exiting",
80
    "Exiting",
81
    "JoinMe"
81
    "Lingering"
82
};
82
};
83
 
83
 
84
/** Lock protecting the threads_btree B+tree.
84
/** Lock protecting the threads_btree B+tree.
85
 *
85
 *
86
 * For locking rules, see declaration thereof.
86
 * For locking rules, see declaration thereof.
Line 354... Line 354...
354
 *
354
 *
355
 * Assume thread->lock is held!!
355
 * Assume thread->lock is held!!
356
 */
356
 */
357
void thread_destroy(thread_t *t)
357
void thread_destroy(thread_t *t)
358
{
358
{
359
    ASSERT(t->state == Exiting || t->state == JoinMe);
359
    ASSERT(t->state == Exiting || t->state == Lingering);
360
    ASSERT(t->task);
360
    ASSERT(t->task);
361
    ASSERT(t->cpu);
361
    ASSERT(t->cpu);
362
 
362
 
363
    spinlock_lock(&t->cpu->lock);
363
    spinlock_lock(&t->cpu->lock);
364
    if (t->cpu->fpu_owner == t)
364
    if (t->cpu->fpu_owner == t)
Line 518... Line 518...
518
    return rc; 
518
    return rc; 
519
}
519
}
520
 
520
 
521
/** Detach thread.
521
/** Detach thread.
522
 *
522
 *
523
 * Mark the thread as detached, if the thread is already in the JoinMe state,
523
 * Mark the thread as detached, if the thread is already in the Lingering
524
 * deallocate its resources.
524
 * state, deallocate its resources.
525
 *
525
 *
526
 * @param t Thread to be detached.
526
 * @param t Thread to be detached.
527
 */
527
 */
528
void thread_detach(thread_t *t)
528
void thread_detach(thread_t *t)
529
{
529
{
Line 534... Line 534...
534
     * pointer to it must be still valid.
534
     * pointer to it must be still valid.
535
     */
535
     */
536
    ipl = interrupts_disable();
536
    ipl = interrupts_disable();
537
    spinlock_lock(&t->lock);
537
    spinlock_lock(&t->lock);
538
    ASSERT(!t->detached);
538
    ASSERT(!t->detached);
539
    if (t->state == JoinMe) {
539
    if (t->state == Lingering) {
540
        thread_destroy(t);  /* unlocks &t->lock */
540
        thread_destroy(t);  /* unlocks &t->lock */
541
        interrupts_restore(ipl);
541
        interrupts_restore(ipl);
542
        return;
542
        return;
543
    } else {
543
    } else {
544
        t->detached = true;
544
        t->detached = true;