MCPcopy Create free account
hub / github.com/HelenOS/helenos / cushion

Function cushion

kernel/generic/src/proc/thread.c:119–150  ·  view source on GitHub ↗

Thread wrapper. * * This wrapper is provided to ensure that every thread makes a call to * thread_exit() when its implementing function returns. * * interrupts_disable() is assumed. * */

Source from the content-addressed store, hash-verified

117 *
118 */
119static void cushion(void)
120{
121 void (*f)(void *) = THREAD->thread_code;
122 void *arg = THREAD->thread_arg;
123 THREAD->last_cycle = get_cycle();
124
125 /* This is where each thread wakes up after its creation */
126 irq_spinlock_unlock(&THREAD->lock, false);
127 interrupts_enable();
128
129 f(arg);
130
131 /* Accumulate accounting to the task */
132 irq_spinlock_lock(&THREAD->lock, true);
133 if (!THREAD->uncounted) {
134 thread_update_accounting(true);
135 uint64_t ucycles = THREAD->ucycles;
136 THREAD->ucycles = 0;
137 uint64_t kcycles = THREAD->kcycles;
138 THREAD->kcycles = 0;
139
140 irq_spinlock_pass(&THREAD->lock, &TASK->lock);
141 TASK->ucycles += ucycles;
142 TASK->kcycles += kcycles;
143 irq_spinlock_unlock(&TASK->lock, true);
144 } else
145 irq_spinlock_unlock(&THREAD->lock, true);
146
147 thread_exit();
148
149 /* Not reached */
150}
151
152/** Initialization and allocation for thread_t structure
153 *

Callers

nothing calls this directly

Calls 7

irq_spinlock_unlockFunction · 0.85
irq_spinlock_lockFunction · 0.85
thread_update_accountingFunction · 0.85
irq_spinlock_passFunction · 0.85
thread_exitFunction · 0.70
get_cycleFunction · 0.50
interrupts_enableFunction · 0.50

Tested by

no test coverage detected