Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/proc/thread.c

    rae0300b5 ree42e43  
    239239 * Switch thread to the ready state.
    240240 *
    241  * @param thread Thread to make ready.
     241 * @param t Thread to make ready.
    242242 *
    243243 */
     
    246246        irq_spinlock_lock(&thread->lock, true);
    247247       
    248         ASSERT(thread->state != Ready);
     248        ASSERT(!(thread->state == Ready));
    249249       
    250250        int i = (thread->priority < RQ_COUNT - 1)
     
    350350       
    351351#ifdef CONFIG_UDEBUG
    352         /* Initialize debugging stuff */
    353         thread->btrace = false;
     352        /* Init debugging stuff */
    354353        udebug_thread_initialize(&thread->udebug);
    355354#endif
     
    536535/** Detach thread.
    537536 *
    538  * Mark the thread as detached. If the thread is already
    539  * in the Lingering state, deallocate its resources.
     537 * Mark the thread as detached, if the thread is already in the Lingering
     538 * state, deallocate its resources.
    540539 *
    541540 * @param thread Thread to be detached.
     
    591590        order_suffix(thread->kcycles, &kcycles, &ksuffix);
    592591       
    593         char *name;
    594         if (str_cmp(thread->name, "uinit") == 0)
    595                 name = thread->task->name;
    596         else
    597                 name = thread->name;
    598        
    599592#ifdef __32_BITS__
    600593        if (*additional)
    601                 printf("%-8" PRIu64 " %10p %10p %9" PRIu64 "%c %9" PRIu64 "%c ",
    602                     thread->tid, thread->thread_code, thread->kstack,
    603                     ucycles, usuffix, kcycles, ksuffix);
     594                printf("%-8" PRIu64" %10p %9" PRIu64 "%c %9" PRIu64 "%c ",
     595                    thread->tid, thread->kstack, ucycles, usuffix,
     596                    kcycles, ksuffix);
    604597        else
    605                 printf("%-8" PRIu64 " %-14s %10p %-8s %10p %-5" PRIu32 "\n",
    606                     thread->tid, name, thread, thread_states[thread->state],
    607                     thread->task, thread->task->context);
     598                printf("%-8" PRIu64" %-14s %10p %-8s %10p %-5" PRIu32 " %10p\n",
     599                    thread->tid, thread->name, thread, thread_states[thread->state],
     600                    thread->task, thread->task->context, thread->thread_code);
    608601#endif
    609602       
    610603#ifdef __64_BITS__
    611604        if (*additional)
    612                 printf("%-8" PRIu64 " %18p %18p\n"
     605                printf("%-8" PRIu64" %18p %18p\n"
    613606                    "         %9" PRIu64 "%c %9" PRIu64 "%c ",
    614607                    thread->tid, thread->thread_code, thread->kstack,
    615608                    ucycles, usuffix, kcycles, ksuffix);
    616609        else
    617                 printf("%-8" PRIu64 " %-14s %18p %-8s %18p %-5" PRIu32 "\n",
    618                     thread->tid, name, thread, thread_states[thread->state],
     610                printf("%-8" PRIu64" %-14s %18p %-8s %18p %-5" PRIu32 "\n",
     611                    thread->tid, thread->name, thread, thread_states[thread->state],
    619612                    thread->task, thread->task->context);
    620613#endif
     
    654647#ifdef __32_BITS__
    655648        if (additional)
    656                 printf("[id    ] [code    ] [stack   ] [ucycles ] [kcycles ]"
    657                     " [cpu] [waitqueue]\n");
     649                printf("[id    ] [stack   ] [ucycles ] [kcycles ] [cpu]"
     650                    " [waitqueue]\n");
    658651        else
    659652                printf("[id    ] [name        ] [address ] [state ] [task    ]"
    660                     " [ctx]\n");
     653                    " [ctx] [code    ]\n");
    661654#endif
    662655       
     
    747740        ASSERT(interrupts_disabled());
    748741        ASSERT(irq_spinlock_locked(&threads_lock));
    749        
     742
    750743        thread_iterator_t iterator;
    751744       
     
    758751}
    759752
    760 #ifdef CONFIG_UDEBUG
    761 
    762 void thread_stack_trace(thread_id_t thread_id)
    763 {
    764         irq_spinlock_lock(&threads_lock, true);
    765        
    766         thread_t *thread = thread_find_by_id(thread_id);
    767         if (thread == NULL) {
    768                 printf("No such thread.\n");
    769                 irq_spinlock_unlock(&threads_lock, true);
    770                 return;
    771         }
    772        
    773         irq_spinlock_lock(&thread->lock, false);
    774        
    775         /*
    776          * Schedule a stack trace to be printed
    777          * just before the thread is scheduled next.
    778          *
    779          * If the thread is sleeping then try to interrupt
    780          * the sleep. Any request for printing an uspace stack
    781          * trace from within the kernel should be always
    782          * considered a last resort debugging means, therefore
    783          * forcing the thread's sleep to be interrupted
    784          * is probably justifiable.
    785          */
    786        
    787         bool sleeping = false;
    788         istate_t *istate = thread->udebug.uspace_state;
    789         if (istate != NULL) {
    790                 printf("Scheduling thread stack trace.\n");
    791                 thread->btrace = true;
    792                 if (thread->state == Sleeping)
    793                         sleeping = true;
    794         } else
    795                 printf("Thread interrupt state not available.\n");
    796        
    797         irq_spinlock_unlock(&thread->lock, false);
    798        
    799         if (sleeping)
    800                 waitq_interrupt_sleep(thread);
    801        
    802         irq_spinlock_unlock(&threads_lock, true);
    803 }
    804 
    805 #endif /* CONFIG_UDEBUG */
    806753
    807754/** Process syscall to create new thread.
    808755 *
    809756 */
    810 sysarg_t sys_thread_create(uspace_arg_t *uspace_uarg, char *uspace_name,
     757unative_t sys_thread_create(uspace_arg_t *uspace_uarg, char *uspace_name,
    811758    size_t name_len, thread_id_t *uspace_thread_id)
    812759{
     
    817764        int rc = copy_from_uspace(namebuf, uspace_name, name_len);
    818765        if (rc != 0)
    819                 return (sysarg_t) rc;
     766                return (unative_t) rc;
    820767       
    821768        namebuf[name_len] = 0;
     
    832779        if (rc != 0) {
    833780                free(kernel_uarg);
    834                 return (sysarg_t) rc;
     781                return (unative_t) rc;
    835782        }
    836783       
     
    846793                                 * has already been created. We need to undo its
    847794                                 * creation now.
     795                                 *
    848796                                 */
    849797                               
     
    856804                                free(kernel_uarg);
    857805                               
    858                                 return (sysarg_t) rc;
     806                                return (unative_t) rc;
    859807                         }
    860808                }
     
    867815                 * THREAD_B events for threads that already existed
    868816                 * and could be detected with THREAD_READ before.
     817                 *
    869818                 */
    870819                udebug_thread_b_event_attach(thread, TASK);
     
    878827                free(kernel_uarg);
    879828       
    880         return (sysarg_t) ENOMEM;
     829        return (unative_t) ENOMEM;
    881830}
    882831
     
    884833 *
    885834 */
    886 sysarg_t sys_thread_exit(int uspace_status)
     835unative_t sys_thread_exit(int uspace_status)
    887836{
    888837        thread_exit();
     
    900849 *
    901850 */
    902 sysarg_t sys_thread_get_id(thread_id_t *uspace_thread_id)
     851unative_t sys_thread_get_id(thread_id_t *uspace_thread_id)
    903852{
    904853        /*
     
    907856         *
    908857         */
    909         return (sysarg_t) copy_to_uspace(uspace_thread_id, &THREAD->tid,
     858        return (unative_t) copy_to_uspace(uspace_thread_id, &THREAD->tid,
    910859            sizeof(THREAD->tid));
    911860}
    912861
    913862/** Syscall wrapper for sleeping. */
    914 sysarg_t sys_thread_usleep(uint32_t usec)
     863unative_t sys_thread_usleep(uint32_t usec)
    915864{
    916865        thread_usleep(usec);
Note: See TracChangeset for help on using the changeset viewer.