Subversion Repositories HelenOS

Rev

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

Rev 3431 Rev 3597
Line 277... Line 277...
277
 * @param arg       Thread's implementing function argument.
277
 * @param arg       Thread's implementing function argument.
278
 * @param task      Task to which the thread belongs. The caller must
278
 * @param task      Task to which the thread belongs. The caller must
279
 *          guarantee that the task won't cease to exist during the
279
 *          guarantee that the task won't cease to exist during the
280
 *          call. The task's lock may not be held.
280
 *          call. The task's lock may not be held.
281
 * @param flags     Thread flags.
281
 * @param flags     Thread flags.
282
 * @param name      Symbolic name.
282
 * @param name      Symbolic name (a copy is made).
283
 * @param uncounted Thread's accounting doesn't affect accumulated task
283
 * @param uncounted Thread's accounting doesn't affect accumulated task
284
 *          accounting.
284
 *          accounting.
285
 *
285
 *
286
 * @return      New thread's structure on success, NULL on failure.
286
 * @return      New thread's structure on success, NULL on failure.
287
 *
287
 *
Line 314... Line 314...
314
    ipl = interrupts_disable();
314
    ipl = interrupts_disable();
315
    t->saved_context.ipl = interrupts_read();
315
    t->saved_context.ipl = interrupts_read();
316
    interrupts_restore(ipl);
316
    interrupts_restore(ipl);
317
   
317
   
318
    memcpy(t->name, name, THREAD_NAME_BUFLEN);
318
    memcpy(t->name, name, THREAD_NAME_BUFLEN);
-
 
319
    t->name[THREAD_NAME_BUFLEN - 1] = '\0';
319
   
320
   
320
    t->thread_code = func;
321
    t->thread_code = func;
321
    t->thread_arg = arg;
322
    t->thread_arg = arg;
322
    t->ticks = -1;
323
    t->ticks = -1;
323
    t->cycles = 0;
324
    t->cycles = 0;
Line 706... Line 707...
706
 
707
 
707
/** Process syscall to create new thread.
708
/** Process syscall to create new thread.
708
 *
709
 *
709
 */
710
 */
710
unative_t sys_thread_create(uspace_arg_t *uspace_uarg, char *uspace_name,
711
unative_t sys_thread_create(uspace_arg_t *uspace_uarg, char *uspace_name,
711
    thread_id_t *uspace_thread_id)
712
    size_t name_len, thread_id_t *uspace_thread_id)
712
{
713
{
713
    thread_t *t;
714
    thread_t *t;
714
    char namebuf[THREAD_NAME_BUFLEN];
715
    char namebuf[THREAD_NAME_BUFLEN];
715
    uspace_arg_t *kernel_uarg;
716
    uspace_arg_t *kernel_uarg;
716
    int rc;
717
    int rc;
717
 
718
 
-
 
719
    if (name_len > THREAD_NAME_BUFLEN - 1)
-
 
720
        name_len = THREAD_NAME_BUFLEN - 1;
-
 
721
 
718
    rc = copy_from_uspace(namebuf, uspace_name, THREAD_NAME_BUFLEN);
722
    rc = copy_from_uspace(namebuf, uspace_name, name_len);
719
    if (rc != 0)
723
    if (rc != 0)
720
        return (unative_t) rc;
724
        return (unative_t) rc;
721
 
725
 
-
 
726
    namebuf[name_len] = '\0';
-
 
727
 
722
    /*
728
    /*
723
     * In case of failure, kernel_uarg will be deallocated in this function.
729
     * In case of failure, kernel_uarg will be deallocated in this function.
724
     * In case of success, kernel_uarg will be freed in uinit().
730
     * In case of success, kernel_uarg will be freed in uinit().
725
     */
731
     */
726
    kernel_uarg = (uspace_arg_t *) malloc(sizeof(uspace_arg_t), 0);
732
    kernel_uarg = (uspace_arg_t *) malloc(sizeof(uspace_arg_t), 0);