Subversion Repositories HelenOS

Rev

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

Rev 2268 Rev 2436
Line 297... Line 297...
297
    spinlock_unlock(&t->task->lock);   
297
    spinlock_unlock(&t->task->lock);   
298
   
298
   
299
    if (destroy_task)
299
    if (destroy_task)
300
        task_destroy(t->task);
300
        task_destroy(t->task);
301
   
301
   
-
 
302
    /*
-
 
303
     * If the thread had a userspace context, free up its kernel_uarg
-
 
304
     * structure.
-
 
305
     */
-
 
306
    if (t->flags & THREAD_FLAG_USPACE) {
-
 
307
        ASSERT(t->thread_arg);
-
 
308
        free(t->thread_arg);
-
 
309
    }
-
 
310
 
302
    slab_free(thread_slab, t);
311
    slab_free(thread_slab, t);
303
}
312
}
304
 
313
 
305
/** Create new thread
314
/** Create new thread
306
 *
315
 *
Line 310... Line 319...
310
 * @param arg       Thread's implementing function argument.
319
 * @param arg       Thread's implementing function argument.
311
 * @param task      Task to which the thread belongs.
320
 * @param task      Task to which the thread belongs.
312
 * @param flags     Thread flags.
321
 * @param flags     Thread flags.
313
 * @param name      Symbolic name.
322
 * @param name      Symbolic name.
314
 * @param uncounted Thread's accounting doesn't affect accumulated task
323
 * @param uncounted Thread's accounting doesn't affect accumulated task
315
 *   accounting.
324
 *          accounting.
316
 *
325
 *
317
 * @return New thread's structure on success, NULL on failure.
326
 * @return New thread's structure on success, NULL on failure.
318
 *
327
 *
319
 */
328
 */
320
thread_t *thread_create(void (* func)(void *), void *arg, task_t *task,
329
thread_t *thread_create(void (* func)(void *), void *arg, task_t *task,
321
    int flags, char *name, bool uncounted)
330
    int flags, char *name, bool uncounted)
322
{
331
{
323
    thread_t *t;
332
    thread_t *t;
324
    ipl_t ipl;
333
    ipl_t ipl;
325
   
334
   
326
    t = (thread_t *) slab_alloc(thread_slab, 0);
335
    t = (thread_t *) slab_alloc(thread_slab, 0);
Line 635... Line 644...
635
}
644
}
636
 
645
 
637
/** Process syscall to create new thread.
646
/** Process syscall to create new thread.
638
 *
647
 *
639
 */
648
 */
640
unative_t sys_thread_create(uspace_arg_t *uspace_uarg, char *uspace_name, thread_id_t *uspace_thread_id)
649
unative_t sys_thread_create(uspace_arg_t *uspace_uarg, char *uspace_name,
-
 
650
    thread_id_t *uspace_thread_id)
641
{
651
{
642
    thread_t *t;
652
    thread_t *t;
643
    char namebuf[THREAD_NAME_BUFLEN];
653
    char namebuf[THREAD_NAME_BUFLEN];
644
    uspace_arg_t *kernel_uarg;
654
    uspace_arg_t *kernel_uarg;
645
    int rc;
655
    int rc;
Line 658... Line 668...
658
    t = thread_create(uinit, kernel_uarg, TASK, THREAD_FLAG_USPACE, namebuf,
668
    t = thread_create(uinit, kernel_uarg, TASK, THREAD_FLAG_USPACE, namebuf,
659
        false);
669
        false);
660
    if (t) {
670
    if (t) {
661
        thread_ready(t);
671
        thread_ready(t);
662
        if (uspace_thread_id != NULL)
672
        if (uspace_thread_id != NULL)
663
            return (unative_t) copy_to_uspace(uspace_thread_id, &t->tid,
673
            return (unative_t) copy_to_uspace(uspace_thread_id,
664
                sizeof(t->tid));
674
                &t->tid, sizeof(t->tid));
665
        else
675
        else
666
            return 0;
676
            return 0;
667
    } else
677
    } else
668
        free(kernel_uarg);
678
        free(kernel_uarg);
669
 
679