Changeset 34dcd3f in mainline for generic/src/proc/task.c


Ignore:
Timestamp:
2006-06-05T07:47:45Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c778c1a
Parents:
7509ddc
Message:

Update for task_kill().

File:
1 edited

Legend:

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

    r7509ddc r34dcd3f  
    5959static task_id_t task_counter = 0;
    6060
    61 static void ktask_cleanup(void *);
     61static void ktaskclnp(void *);
    6262
    6363/** Initialize tasks
     
    248248        spinlock_unlock(&ta->lock);
    249249       
    250         t = thread_create(ktask_cleanup, NULL, ta, 0, "ktask_cleanup");
     250        t = thread_create(ktaskclnp, NULL, ta, 0, "ktaskclnp");
    251251       
    252252        spinlock_lock(&ta->lock);
     253        ta->accept_new_threads = false;
    253254        ta->refcount--;
    254255       
     
    271272        }
    272273       
    273         thread_ready(t);
    274        
     274        spinlock_unlock(&ta->lock);
     275        interrupts_restore(ipl);
     276       
     277        if (t)
     278                thread_ready(t);
     279
    275280        return 0;
    276281}
     
    314319
    315320/** Kernel thread used to cleanup the task. */
    316 void ktask_cleanup(void *arg)
    317 {
     321void ktaskclnp(void *arg)
     322{
     323        ipl_t ipl;
     324        thread_t *t = NULL;
     325        link_t *cur;
     326
     327        thread_detach(THREAD);
     328
     329loop:
     330        ipl = interrupts_disable();
     331        spinlock_lock(&TASK->lock);
     332       
     333        /*
     334         * Find a thread to join.
     335         */
     336        for (cur = TASK->th_head.next; cur != &TASK->th_head; cur = cur->next) {
     337                t = list_get_instance(cur, thread_t, th_link);
     338                if (t == THREAD)
     339                        continue;
     340                else
     341                        break;
     342        }
     343       
     344        spinlock_unlock(&TASK->lock);
     345        interrupts_restore(ipl);
     346       
     347        if (t != THREAD) {
     348                thread_join(t);
     349                thread_detach(t);
     350                goto loop;
     351        }
     352       
     353        /*
     354         * Now there are no other threads in this task
     355         * and no new threads can be created.
     356         */
     357       
    318358        /*
    319359         * TODO:
    320          * Wait until it is save to cleanup the task (i.e. all other threads exit)
    321          * and do the cleanup (e.g. close IPC communication and release used futexes).
     360         * Close IPC communication and release used futexes.
    322361         * When this thread exits, the task refcount drops to zero and the task structure is
    323362         * cleaned.
Note: See TracChangeset for help on using the changeset viewer.