Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/interrupt/interrupt.c

    r8f4f444 r181a746  
    5050#include <panic.h>
    5151#include <print.h>
    52 #include <stdarg.h>
    5352#include <symtab.h>
    5453#include <proc/thread.h>
     
    111110        }
    112111       
    113         /* Account CPU usage if it has waked up from sleep */
    114         if (CPU) {
     112        /* Account CPU usage if it woke up from sleep */
     113        if (CPU && CPU->idle) {
    115114                irq_spinlock_lock(&CPU->lock, false);
    116                 if (CPU->idle) {
    117                         uint64_t now = get_cycle();
    118                         CPU->idle_cycles += now - CPU->last_cycle;
    119                         CPU->last_cycle = now;
    120                         CPU->idle = false;
    121                 }
     115                uint64_t now = get_cycle();
     116                CPU->idle_cycles += now - CPU->last_cycle;
     117                CPU->last_cycle = now;
     118                CPU->idle = false;
    122119                irq_spinlock_unlock(&CPU->lock, false);
    123120        }
     
    166163}
    167164
    168 static NO_TRACE void fault_from_uspace_core(istate_t *istate, const char *fmt, va_list args)
    169 {
     165/** Terminate thread and task if exception came from userspace.
     166 *
     167 */
     168NO_TRACE void fault_if_from_uspace(istate_t *istate, const char *fmt, ...)
     169{
     170        if (!istate_from_uspace(istate))
     171                return;
     172       
    170173        printf("Task %s (%" PRIu64 ") killed due to an exception at "
    171174            "program counter %p.\n", TASK->name, TASK->taskid,
     
    176179       
    177180        printf("Kill message: ");
    178         vprintf(fmt, args);
    179         printf("\n");
    180        
    181         task_kill_self(true);
    182 }
    183 
    184 /** Terminate thread and task after the exception came from userspace.
    185  *
    186  */
    187 NO_TRACE void fault_from_uspace(istate_t *istate, const char *fmt, ...)
    188 {
    189         va_list args;
    190 
    191         va_start(args, fmt);
    192         fault_from_uspace_core(istate, fmt, args);
    193         va_end(args);
    194 }
    195 
    196 /** Terminate thread and task if exception came from userspace.
    197  *
    198  */
    199 NO_TRACE void fault_if_from_uspace(istate_t *istate, const char *fmt, ...)
    200 {
    201         if (!istate_from_uspace(istate))
    202                 return;
    203181       
    204182        va_list args;
    205183        va_start(args, fmt);
    206         fault_from_uspace_core(istate, fmt, args);
     184        vprintf(fmt, args);
    207185        va_end(args);
     186        printf("\n");
     187       
     188        task_kill_self(true);
    208189}
    209190
Note: See TracChangeset for help on using the changeset viewer.