Index: kernel/arch/ppc32/include/interrupt.h
===================================================================
--- kernel/arch/ppc32/include/interrupt.h	(revision 3193c0558f847619377280b6f87fde226e0479e1)
+++ kernel/arch/ppc32/include/interrupt.h	(revision 538780736253a52c38332ffe3f75d60f64190f4e)
@@ -48,5 +48,5 @@
 extern void start_decrementer(void);
 extern void interrupt_init(void);
-extern void extint_handler(int, istate_t *);
+extern void extint_handler(unsigned int, istate_t *);
 
 #endif
Index: kernel/arch/ppc32/include/mm/tlb.h
===================================================================
--- kernel/arch/ppc32/include/mm/tlb.h	(revision 3193c0558f847619377280b6f87fde226e0479e1)
+++ kernel/arch/ppc32/include/mm/tlb.h	(revision 538780736253a52c38332ffe3f75d60f64190f4e)
@@ -76,10 +76,10 @@
 
 extern void pht_init(void);
-extern void pht_refill(int, istate_t *);
+extern void pht_refill(unsigned int, istate_t *);
 
-extern bool pht_refill_real(int, istate_t *)
+extern bool pht_refill_real(unsigned int, istate_t *)
     __attribute__ ((section("K_UNMAPPED_TEXT_START")));
-extern void tlb_refill_real(int, uint32_t, ptehi_t, ptelo_t, istate_t *)
-    __attribute__ ((section("K_UNMAPPED_TEXT_START")));
+extern void tlb_refill_real(unsigned int, uint32_t, ptehi_t, ptelo_t,
+    istate_t *) __attribute__ ((section("K_UNMAPPED_TEXT_START")));
 
 #endif
Index: kernel/arch/ppc32/src/interrupt.c
===================================================================
--- kernel/arch/ppc32/src/interrupt.c	(revision 3193c0558f847619377280b6f87fde226e0479e1)
+++ kernel/arch/ppc32/src/interrupt.c	(revision 538780736253a52c38332ffe3f75d60f64190f4e)
@@ -55,5 +55,5 @@
  *
  */
-static void exception_external(int n, istate_t *istate)
+static void exception_external(unsigned int n, istate_t *istate)
 {
 	uint8_t inum;
@@ -92,5 +92,5 @@
 }
 
-static void exception_decrementer(int n, istate_t *istate)
+static void exception_decrementer(unsigned int n, istate_t *istate)
 {
 	start_decrementer();
Index: kernel/arch/ppc32/src/mm/tlb.c
===================================================================
--- kernel/arch/ppc32/src/mm/tlb.c	(revision 3193c0558f847619377280b6f87fde226e0479e1)
+++ kernel/arch/ppc32/src/mm/tlb.c	(revision 538780736253a52c38332ffe3f75d60f64190f4e)
@@ -209,5 +209,5 @@
  *
  */
-void pht_refill(int n, istate_t *istate)
+void pht_refill(unsigned int n, istate_t *istate)
 {
 	as_t *as = (AS == NULL) ? AS_KERNEL : AS;
@@ -260,5 +260,5 @@
  *
  */
-bool pht_refill_real(int n, istate_t *istate)
+bool pht_refill_real(unsigned int n, istate_t *istate)
 {
 	uintptr_t badvaddr;
@@ -366,5 +366,6 @@
  *
  */
-void tlb_refill_real(int n, uint32_t tlbmiss, ptehi_t ptehi, ptelo_t ptelo, istate_t *istate)
+void tlb_refill_real(unsigned int n, uint32_t tlbmiss, ptehi_t ptehi,
+    ptelo_t ptelo, istate_t *istate)
 {
 	uint32_t badvaddr = tlbmiss & 0xfffffffc;
Index: kernel/arch/sparc64/include/drivers/tick.h
===================================================================
--- kernel/arch/sparc64/include/drivers/tick.h	(revision 3193c0558f847619377280b6f87fde226e0479e1)
+++ kernel/arch/sparc64/include/drivers/tick.h	(revision 538780736253a52c38332ffe3f75d60f64190f4e)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup sparc64	
+/** @addtogroup sparc64
  * @{
  */
@@ -40,8 +40,8 @@
 
 /* mask of the "counter" field of the Tick register */
-#define TICK_COUNTER_MASK	(~(1l << 63))
+#define TICK_COUNTER_MASK  (~(1l << 63))
 
 extern void tick_init(void);
-extern void tick_interrupt(int n, istate_t *istate);
+extern void tick_interrupt(unsigned int, istate_t *);
 
 /**
Index: kernel/arch/sparc64/src/drivers/tick.c
===================================================================
--- kernel/arch/sparc64/src/drivers/tick.c	(revision 3193c0558f847619377280b6f87fde226e0479e1)
+++ kernel/arch/sparc64/src/drivers/tick.c	(revision 538780736253a52c38332ffe3f75d60f64190f4e)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup sparc64	
+/** @addtogroup sparc64
  * @{
  */
@@ -77,8 +77,9 @@
 /** Process tick interrupt.
  *
- * @param n Interrupt Level, 14,  (can be ignored)
+ * @param n      Interrupt Level (14, can be ignored)
  * @param istate Interrupted state.
+ *
  */
-void tick_interrupt(int n, istate_t *istate)
+void tick_interrupt(unsigned int n, istate_t *istate)
 {
 	softint_reg_t softint, clear;
Index: kernel/generic/include/cpu.h
===================================================================
--- kernel/generic/include/cpu.h	(revision 3193c0558f847619377280b6f87fde226e0479e1)
+++ kernel/generic/include/cpu.h	(revision 538780736253a52c38332ffe3f75d60f64190f4e)
@@ -72,7 +72,11 @@
 	size_t missed_clock_ticks;
 	
+	/**
+	 * Processor cycle accounting.
+	 */
 	bool idle;
-	uint64_t idle_ticks;
-	uint64_t busy_ticks;
+	uint64_t last_cycle;
+	uint64_t idle_cycles;
+	uint64_t busy_cycles;
 	
 	/**
Index: kernel/generic/include/sysinfo/abi.h
===================================================================
--- kernel/generic/include/sysinfo/abi.h	(revision 3193c0558f847619377280b6f87fde226e0479e1)
+++ kernel/generic/include/sysinfo/abi.h	(revision 538780736253a52c38332ffe3f75d60f64190f4e)
@@ -69,6 +69,6 @@
 	bool active;             /**< CPU is activate */
 	uint16_t frequency_mhz;  /**< Frequency in MHz */
-	uint64_t idle_ticks;     /**< Number of idle kernel quanta */
-	uint64_t busy_ticks;     /**< Number of busy kernel quanta */
+	uint64_t idle_cycles;    /**< Number of idle cycles */
+	uint64_t busy_cycles;    /**< Number of busy cycles */
 } stats_cpu_t;
 
Index: kernel/generic/src/cpu/cpu.c
===================================================================
--- kernel/generic/src/cpu/cpu.c	(revision 3193c0558f847619377280b6f87fde226e0479e1)
+++ kernel/generic/src/cpu/cpu.c	(revision 538780736253a52c38332ffe3f75d60f64190f4e)
@@ -49,4 +49,5 @@
 #include <print.h>
 #include <sysinfo/sysinfo.h>
+#include <arch/cycle.h>
 
 cpu_t *cpus;
@@ -94,4 +95,9 @@
 	CPU->tlb_active = true;
 	
+	CPU->idle = false;
+	CPU->last_cycle = get_cycle();
+	CPU->idle_cycles = 0;
+	CPU->busy_cycles = 0;
+	
 	cpu_identify();
 	cpu_arch_init();
Index: kernel/generic/src/interrupt/interrupt.c
===================================================================
--- kernel/generic/src/interrupt/interrupt.c	(revision 3193c0558f847619377280b6f87fde226e0479e1)
+++ kernel/generic/src/interrupt/interrupt.c	(revision 538780736253a52c38332ffe3f75d60f64190f4e)
@@ -99,4 +99,6 @@
 void exc_dispatch(unsigned int n, istate_t *istate)
 {
+	ASSERT(CPU);
+	
 #if (IVT_ITEMS > 0)
 	ASSERT(n < IVT_ITEMS);
@@ -109,4 +111,14 @@
 		irq_spinlock_unlock(&THREAD->lock, false);
 	}
+	
+	/* Account CPU usage if it has waked up from sleep */
+	irq_spinlock_lock(&CPU->lock, false);
+	if (CPU->idle) {
+		uint64_t now = get_cycle();
+		CPU->idle_cycles += now - CPU->last_cycle;
+		CPU->last_cycle = now;
+		CPU->idle = false;
+	}
+	irq_spinlock_unlock(&CPU->lock, false);
 	
 	uint64_t begin_cycle = get_cycle();
Index: kernel/generic/src/main/kinit.c
===================================================================
--- kernel/generic/src/main/kinit.c	(revision 3193c0558f847619377280b6f87fde226e0479e1)
+++ kernel/generic/src/main/kinit.c	(revision 538780736253a52c38332ffe3f75d60f64190f4e)
@@ -181,4 +181,5 @@
 		if (init.tasks[i].addr % FRAME_SIZE) {
 			printf("init[%" PRIs "].addr is not frame aligned\n", i);
+			programs[i].task = NULL;
 			continue;
 		}
Index: kernel/generic/src/proc/scheduler.c
===================================================================
--- kernel/generic/src/proc/scheduler.c	(revision 3193c0558f847619377280b6f87fde226e0479e1)
+++ kernel/generic/src/proc/scheduler.c	(revision 538780736253a52c38332ffe3f75d60f64190f4e)
@@ -193,11 +193,9 @@
 		 * This improves energy saving and hyperthreading.
 		 */
-		
-		 /* Mark CPU as it was idle this clock tick */
 		irq_spinlock_lock(&CPU->lock, false);
 		CPU->idle = true;
 		irq_spinlock_unlock(&CPU->lock, false);
-		
 		interrupts_enable();
+		
 		/*
 		 * An interrupt might occur right now and wake up a thread.
@@ -386,5 +384,5 @@
 	as_t *old_as = AS;
 	
-	ASSERT(!THREAD || irq_spinlock_locked(&THREAD->lock));
+	ASSERT((!THREAD) || (irq_spinlock_locked(&THREAD->lock)));
 	ASSERT(CPU != NULL);
 	
Index: kernel/generic/src/sysinfo/stats.c
===================================================================
--- kernel/generic/src/sysinfo/stats.c	(revision 3193c0558f847619377280b6f87fde226e0479e1)
+++ kernel/generic/src/sysinfo/stats.c	(revision 538780736253a52c38332ffe3f75d60f64190f4e)
@@ -124,6 +124,6 @@
 		stats_cpus[i].active = cpus[i].active;
 		stats_cpus[i].frequency_mhz = cpus[i].frequency_mhz;
-		stats_cpus[i].busy_ticks = cpus[i].busy_ticks;
-		stats_cpus[i].idle_ticks = cpus[i].idle_ticks;
+		stats_cpus[i].busy_cycles = cpus[i].busy_cycles;
+		stats_cpus[i].idle_cycles = cpus[i].idle_cycles;
 		
 		irq_spinlock_unlock(&cpus[i].lock, true);
Index: kernel/generic/src/time/clock.c
===================================================================
--- kernel/generic/src/time/clock.c	(revision 3193c0558f847619377280b6f87fde226e0479e1)
+++ kernel/generic/src/time/clock.c	(revision 538780736253a52c38332ffe3f75d60f64190f4e)
@@ -57,4 +57,5 @@
 #include <mm/frame.h>
 #include <ddi/ddi.h>
+#include <arch/cycle.h>
 
 /* Pointer to variable with uptime */
@@ -125,4 +126,13 @@
 }
 
+static void cpu_update_accounting(void)
+{
+	irq_spinlock_lock(&CPU->lock, false);
+	uint64_t now = get_cycle();
+	CPU->busy_cycles += now - CPU->last_cycle;
+	CPU->last_cycle = now;
+	irq_spinlock_unlock(&CPU->lock, false);
+}
+
 /** Clock routine
  *
@@ -136,11 +146,6 @@
 	size_t missed_clock_ticks = CPU->missed_clock_ticks;
 	
-	/* Account lost ticks to CPU usage */
-	if (CPU->idle)
-		CPU->idle_ticks += missed_clock_ticks + 1;
-	else
-		CPU->busy_ticks += missed_clock_ticks + 1;
-	
-	CPU->idle = false;
+	/* Account CPU usage */
+	cpu_update_accounting();
 	
 	/*
@@ -151,5 +156,8 @@
 	size_t i;
 	for (i = 0; i <= missed_clock_ticks; i++) {
+		/* Update counters and accounting */
 		clock_update_counters();
+		cpu_update_accounting();
+		
 		irq_spinlock_lock(&CPU->timeoutlock, false);
 		
Index: tools/checkers/howto.txt
===================================================================
--- tools/checkers/howto.txt	(revision 538780736253a52c38332ffe3f75d60f64190f4e)
+++ tools/checkers/howto.txt	(revision 538780736253a52c38332ffe3f75d60f64190f4e)
@@ -0,0 +1,28 @@
+Basic instructions
+------------------
+This is a very brief and preliminary description of the usage of source
+code checkers and verifiers located in this directory. It is not intended
+to be perfect since the formal verification is still work-in-progress, but
+it should at least give you some basic hints.
+
+If you want to try, say, the Clang static analyzer, follow the steps:
+
+1. Go to the root directory of HelenOS source tree.
+
+2. Run
+
+      make precheck
+
+   Configure the kernel according to your preferences. Remember that many
+   checkers have specific limitation on the target platform. They might
+   require the abstract platform abs32le or they might be suitable only
+   for platforms supported by some toolchain (e.g. ia32 and amd64 in the
+   case of Clang).
+
+3. As HelenOS compiles, Jobfiles (e.g. kernel/kernel.job) are created.
+
+4. Execute the checker while still in the source tree root directory. Do
+   not forget the argument "." which indicates the path to the source tree
+   root directory.
+
+      ./tools/checkers/clang.py .
Index: uspace/app/tasks/tasks.c
===================================================================
--- uspace/app/tasks/tasks.c	(revision 3193c0558f847619377280b6f87fde226e0479e1)
+++ uspace/app/tasks/tasks.c	(revision 538780736253a52c38332ffe3f75d60f64190f4e)
@@ -165,8 +165,8 @@
 	for (i = 0; i < count; i++) {
 		if (cpus[i].active) {
-			printf("cpu%u: %" PRIu16 " MHz, busy ticks: "
-			    "%" PRIu64 ", idle ticks: %" PRIu64 "\n",
-			    cpus[i].id, cpus[i].frequency_mhz, cpus[i].busy_ticks,
-			    cpus[i].idle_ticks);
+			printf("cpu%u: %" PRIu16 " MHz, busy cycles: "
+			    "%" PRIu64 ", idle cycles: %" PRIu64 "\n",
+			    cpus[i].id, cpus[i].frequency_mhz, cpus[i].busy_cycles,
+			    cpus[i].idle_cycles);
 		} else {
 			printf("cpu%u: inactive\n", cpus[i].id);
Index: uspace/app/top/screen.c
===================================================================
--- uspace/app/top/screen.c	(revision 3193c0558f847619377280b6f87fde226e0479e1)
+++ uspace/app/top/screen.c	(revision 538780736253a52c38332ffe3f75d60f64190f4e)
@@ -222,8 +222,16 @@
 	for (i = 0; i < data->cpus_count; i++) {
 		if (data->cpus[i].active) {
-			printf("cpu%u (%4" PRIu16 " MHz): busy ticks: "
-			    "%" PRIu64 ", idle ticks: %" PRIu64,
+			uint64_t busy;
+			uint64_t idle;
+			char busy_suffix;
+			char idle_suffix;
+			
+			order_suffix(data->cpus[i].busy_cycles, &busy, &busy_suffix);
+			order_suffix(data->cpus[i].idle_cycles, &idle, &idle_suffix);
+			
+			printf("cpu%u (%4" PRIu16 " MHz): busy cycles: "
+			    "%" PRIu64 "%c, idle cycles: %" PRIu64 "%c",
 			    data->cpus[i].id, data->cpus[i].frequency_mhz,
-			    data->cpus[i].busy_ticks, data->cpus[i].idle_ticks);
+			    busy, busy_suffix, idle, idle_suffix);
 			puts(", idle: ");
 			print_percent(data->cpus_perc[i].idle, 2);
Index: uspace/app/top/top.c
===================================================================
--- uspace/app/top/top.c	(revision 3193c0558f847619377280b6f87fde226e0479e1)
+++ uspace/app/top/top.c	(revision 538780736253a52c38332ffe3f75d60f64190f4e)
@@ -175,5 +175,5 @@
 	}
 	
-	/* For each CPU: Compute total ticks and divide it between
+	/* For each CPU: Compute total cycles and divide it between
 	   user and kernel */
 	
@@ -181,7 +181,7 @@
 	for (i = 0; i < new_data->cpus_count; i++) {
 		uint64_t idle =
-		    new_data->cpus[i].idle_ticks - old_data->cpus[i].idle_ticks;
+		    new_data->cpus[i].idle_cycles - old_data->cpus[i].idle_cycles;
 		uint64_t busy =
-		    new_data->cpus[i].busy_ticks - old_data->cpus[i].busy_ticks;
+		    new_data->cpus[i].busy_cycles - old_data->cpus[i].busy_cycles;
 		uint64_t sum = idle + busy;
 		
