Changeset 4e33b6b in mainline for kernel/generic/src/proc/thread.c


Ignore:
Timestamp:
2007-01-07T14:44:33Z (18 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d78d603
Parents:
c109dd0
Message:

More formatting changes.

File:
1 edited

Legend:

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

    rc109dd0 r4e33b6b  
    8181};
    8282
    83 /** Lock protecting the threads_btree B+tree. For locking rules, see declaration thereof. */
     83/** Lock protecting the threads_btree B+tree.
     84 *
     85 * For locking rules, see declaration thereof.
     86 */
    8487SPINLOCK_INITIALIZE(threads_lock);
    8588
    8689/** B+tree of all threads.
    8790 *
    88  * When a thread is found in the threads_btree B+tree, it is guaranteed to exist as long
    89  * as the threads_lock is held.
     91 * When a thread is found in the threads_btree B+tree, it is guaranteed to
     92 * exist as long as the threads_lock is held.
    9093 */
    9194btree_t threads_btree;         
     
    99102#endif
    100103
    101 /** Thread wrapper
    102  *
    103  * This wrapper is provided to ensure that every thread
    104  * makes a call to thread_exit() when its implementing
    105  * function returns.
     104/** Thread wrapper.
     105 *
     106 * This wrapper is provided to ensure that every thread makes a call to
     107 * thread_exit() when its implementing function returns.
    106108 *
    107109 * interrupts_disable() is assumed.
     
    202204        THREAD = NULL;
    203205        atomic_set(&nrdy,0);
    204         thread_slab = slab_cache_create("thread_slab",
    205                                         sizeof(thread_t),0,
    206                                         thr_constructor, thr_destructor, 0);
     206        thread_slab = slab_cache_create("thread_slab", sizeof(thread_t), 0,
     207                thr_constructor, thr_destructor, 0);
     208
    207209#ifdef ARCH_HAS_FPU
    208         fpu_context_slab = slab_cache_create("fpu_slab",
    209                                              sizeof(fpu_context_t),
    210                                              FPU_CONTEXT_ALIGN,
    211                                              NULL, NULL, 0);
     210        fpu_context_slab = slab_cache_create("fpu_slab", sizeof(fpu_context_t),
     211                FPU_CONTEXT_ALIGN, NULL, NULL, 0);
    212212#endif
    213213
     
    235235        ASSERT(! (t->state == Ready));
    236236
    237         i = (t->priority < RQ_COUNT -1) ? ++t->priority : t->priority;
     237        i = (t->priority < RQ_COUNT - 1) ? ++t->priority : t->priority;
    238238       
    239239        cpu = CPU;
     
    268268void thread_destroy(thread_t *t)
    269269{
    270         bool destroy_task = false;     
     270        bool destroy_task = false;
    271271
    272272        ASSERT(t->state == Exiting || t->state == Undead);
     
    275275
    276276        spinlock_lock(&t->cpu->lock);
    277         if(t->cpu->fpu_owner==t)
    278                 t->cpu->fpu_owner=NULL;
     277        if(t->cpu->fpu_owner == t)
     278                t->cpu->fpu_owner = NULL;
    279279        spinlock_unlock(&t->cpu->lock);
    280280
     
    311311 * @param flags     Thread flags.
    312312 * @param name      Symbolic name.
    313  * @param uncounted Thread's accounting doesn't affect accumulated task accounting.
     313 * @param uncounted Thread's accounting doesn't affect accumulated task
     314 *       accounting.
    314315 *
    315316 * @return New thread's structure on success, NULL on failure.
    316317 *
    317318 */
    318 thread_t *thread_create(void (* func)(void *), void *arg, task_t *task, int flags, char *name, bool uncounted)
     319thread_t *thread_create(void (* func)(void *), void *arg, task_t *task,
     320        int flags, char *name, bool uncounted)
    319321{
    320322        thread_t *t;
     
    326328       
    327329        /* Not needed, but good for debugging */
    328         memsetb((uintptr_t) t->kstack, THREAD_STACK_SIZE * 1 << STACK_FRAMES, 0);
     330        memsetb((uintptr_t) t->kstack, THREAD_STACK_SIZE * 1 << STACK_FRAMES,
     331                0);
    329332       
    330333        ipl = interrupts_disable();
     
    335338       
    336339        context_save(&t->saved_context);
    337         context_set(&t->saved_context, FADDR(cushion), (uintptr_t) t->kstack, THREAD_STACK_SIZE);
     340        context_set(&t->saved_context, FADDR(cushion), (uintptr_t) t->kstack,
     341                THREAD_STACK_SIZE);
    338342       
    339343        the_initialize((the_t *) t->kstack);
     
    377381        t->fpu_context_engaged = 0;
    378382
    379         thread_create_arch(t);          /* might depend on previous initialization */
     383        /* might depend on previous initialization */
     384        thread_create_arch(t); 
    380385       
    381386        /*
     
    399404         */
    400405        spinlock_lock(&threads_lock);
    401         btree_insert(&threads_btree, (btree_key_t) ((uintptr_t) t), (void *) t, NULL);
     406        btree_insert(&threads_btree, (btree_key_t) ((uintptr_t) t), (void *) t,
     407                NULL);
    402408        spinlock_unlock(&threads_lock);
    403409       
     
    409415/** Terminate thread.
    410416 *
    411  * End current thread execution and switch it to the exiting
    412  * state. All pending timeouts are executed.
    413  *
     417 * End current thread execution and switch it to the exiting state. All pending
     418 * timeouts are executed.
    414419 */
    415420void thread_exit(void)
     
    420425        ipl = interrupts_disable();
    421426        spinlock_lock(&THREAD->lock);
    422         if (THREAD->timeout_pending) { /* busy waiting for timeouts in progress */
     427        if (THREAD->timeout_pending) {
     428                /* busy waiting for timeouts in progress */
    423429                spinlock_unlock(&THREAD->lock);
    424430                interrupts_restore(ipl);
     
    444450void thread_sleep(uint32_t sec)
    445451{
    446         thread_usleep(sec*1000000);
     452        thread_usleep(sec * 1000000);
    447453}
    448454
Note: See TracChangeset for help on using the changeset viewer.