Index: src/libcfa/concurrency/preemption.c
===================================================================
--- src/libcfa/concurrency/preemption.c	(revision 47ecf2b292dc674c395437d675839124283948b3)
+++ src/libcfa/concurrency/preemption.c	(revision cd17862cca0dd2992a5f5a031b06b60cff940efb)
@@ -52,30 +52,16 @@
 
 static void __kernel_sigaction( int sig, void (*handler)(__CFA_SIGPARMS__), int flags );
+LIB_DEBUG_DO( bool validate( alarm_list_t * this ); )
+
+#ifdef __x86_64__
+#define CFA_REG_IP REG_RIP
+#else
+#define CFA_REG_IP REG_EIP
+#endif
+
 
 //=============================================================================================
 // Kernel Preemption logic
 //=============================================================================================
-
-void kernel_start_preemption() {
-	LIB_DEBUG_PRINT_SAFE("Kernel : Starting preemption\n");
-	__kernel_sigaction( SIGUSR1, sigHandler_ctxSwitch, SA_SIGINFO );
-	__kernel_sigaction( SIGALRM, sigHandler_alarm    , SA_SIGINFO );
-	__kernel_sigaction( SIGSEGV, sigHandler_segv     , SA_SIGINFO );
-	__kernel_sigaction( SIGBUS , sigHandler_segv     , SA_SIGINFO );
-	// __kernel_sigaction( SIGABRT, sigHandler_abort    , SA_SIGINFO );
-}
-
-void kernel_stop_preemption() {
-	//Block all signals, we are no longer in a position to handle them
-	sigset_t mask;
-	sigfillset( &mask );
-	sigprocmask( SIG_BLOCK, &mask, NULL );
-	LIB_DEBUG_PRINT_SAFE("Kernel : Preemption stopped\n");
-
-	// assert( !systemProcessor->alarms.head );
-	// assert( systemProcessor->alarms.tail == &systemProcessor->alarms.head );
-}
-
-LIB_DEBUG_DO( bool validate( alarm_list_t * this ); )
 
 void tick_preemption() {
@@ -141,19 +127,6 @@
 }
 
-void ?{}( preemption_scope * this, processor * proc ) {
-	(&this->alarm){ proc };
-	this->proc = proc;
-	this->proc->preemption_alarm = &this->alarm;
-	update_preemption( this->proc, this->proc->preemption );
-}
-
-void ^?{}( preemption_scope * this ) {
-	disable_interrupts();
-
-	update_preemption( this->proc, 0 );
-}
-
-//=============================================================================================
-// Kernel Signal logic
+//=============================================================================================
+// Kernel Signal Tools
 //=============================================================================================
 
@@ -187,6 +160,4 @@
 
 static inline void signal_unblock( int sig ) {
-	LIB_DEBUG_PRINT_BUFFER_DECL( STDERR_FILENO, "Unblock %d on %p\n", sig, this_processor );
-
 	sigset_t mask;
 	sigemptyset( &mask );
@@ -195,16 +166,16 @@
 	if ( pthread_sigmask( SIG_UNBLOCK, &mask, NULL ) == -1 ) {
 	    abortf( "internal error, pthread_sigmask" );
-	} // if
-}
-
-// static inline void signal_block( int sig ) {
-// 	sigset_t mask;
-// 	sigemptyset( &mask );
-// 	sigaddset( &mask, sig );
-
-// 	if ( pthread_sigmask( SIG_BLOCK, &mask, NULL ) == -1 ) {
-// 	    abortf( "internal error, pthread_sigmask" );
-// 	} // if
-// }
+	}
+}
+
+static inline void signal_block( int sig ) {
+	sigset_t mask;
+	sigemptyset( &mask );
+	sigaddset( &mask, sig );
+
+	if ( pthread_sigmask( SIG_BLOCK, &mask, NULL ) == -1 ) {
+	    abortf( "internal error, pthread_sigmask" );
+	}
+}
 
 static inline bool preemption_ready() {
@@ -220,20 +191,59 @@
 }
 
-extern "C" {
-	__attribute__((noinline)) void __debug_break() {
-		pthread_kill( pthread_self(), SIGTRAP );
-	}
-}
-
-#ifdef __x86_64__
-#define CFA_REG_IP REG_RIP
-#else
-#define CFA_REG_IP REG_EIP
-#endif
+static void preempt( processor * this ) {
+	pthread_kill( this->kernel_thread, SIGUSR1 );
+}
+
+static void timeout( thread_desc * this ) {
+	//TODO : implement waking threads
+}
+
+//=============================================================================================
+// Kernel Signal Startup/Shutdown logic
+//=============================================================================================
+
+static pthread_t alarm_thread;
+void * alarm_loop( __attribute__((unused)) void * args );
+
+void kernel_start_preemption() {
+	LIB_DEBUG_PRINT_SAFE("Kernel : Starting preemption\n");
+	__kernel_sigaction( SIGUSR1, sigHandler_ctxSwitch, SA_SIGINFO );
+	__kernel_sigaction( SIGSEGV, sigHandler_segv     , SA_SIGINFO );
+	__kernel_sigaction( SIGBUS , sigHandler_segv     , SA_SIGINFO );
+
+	signal_block( SIGALRM );
+
+	pthread_create( &alarm_thread, NULL, alarm_loop, NULL );
+}
+
+void kernel_stop_preemption() {
+	sigset_t mask;
+	sigfillset( &mask );
+	sigprocmask( SIG_BLOCK, &mask, NULL );
+
+	pthread_kill( alarm_thread, SIGINT );
+	pthread_join( alarm_thread, NULL );
+	LIB_DEBUG_PRINT_SAFE("Kernel : Preemption stopped\n");
+}
+
+void ?{}( preemption_scope * this, processor * proc ) {
+	(&this->alarm){ proc };
+	this->proc = proc;
+	this->proc->preemption_alarm = &this->alarm;
+	update_preemption( this->proc, this->proc->preemption );
+}
+
+void ^?{}( preemption_scope * this ) {
+	disable_interrupts();
+
+	update_preemption( this->proc, 0 );
+}
+
+//=============================================================================================
+// Kernel Signal Handlers
+//=============================================================================================
 
 void sigHandler_ctxSwitch( __CFA_SIGPARMS__ ) {
 	LIB_DEBUG_DO( last_interrupt = (void *)(cxt->uc_mcontext.gregs[CFA_REG_IP]); )
-	verify( this_processor != systemProcessor );
-
 	if( preemption_ready() ) {
 		signal_unblock( SIGUSR1 );
@@ -245,37 +255,61 @@
 }
 
-void sigHandler_alarm( __CFA_SIGPARMS__ ) {
-	LIB_DEBUG_DO( last_interrupt = (void *)(cxt->uc_mcontext.gregs[CFA_REG_IP]); )
-	verify( this_processor == systemProcessor );
-
-	if( try_lock( &systemProcessor->alarm_lock DEBUG_CTX2 ) ) {
-		tick_preemption();
-		systemProcessor->pending_alarm = false;
-		unlock( &systemProcessor->alarm_lock );
-	}
-	else {
-		defer_alarm();
-	}
-
-	signal_unblock( SIGALRM );
-
-	if( preemption_ready() && this_processor->pending_preemption ) {
-
-		this_processor->pending_preemption = false;
-		BlockInternal( (thread_desc*)this_thread );
-	}
-}
-
-static void preempt( processor * this ) {
-	if( this != systemProcessor ) {
-		pthread_kill( this->kernel_thread, SIGUSR1 );
-	}
-	else {
-		defer_ctxSwitch();
-	}
-}
-
-static void timeout( thread_desc * this ) {
-	//TODO : implement waking threads
+// void sigHandler_alarm( __CFA_SIGPARMS__ ) {
+// 	LIB_DEBUG_DO( last_interrupt = (void *)(cxt->uc_mcontext.gregs[CFA_REG_IP]); )
+// 	verify( this_processor == systemProcessor );
+
+// 	if( try_lock( &systemProcessor->alarm_lock DEBUG_CTX2 ) ) {
+// 		tick_preemption();
+// 		systemProcessor->pending_alarm = false;
+// 		unlock( &systemProcessor->alarm_lock );
+// 	}
+// 	else {
+// 		defer_alarm();
+// 	}
+
+// 	signal_unblock( SIGALRM );
+
+// 	if( preemption_ready() && this_processor->pending_preemption ) {
+
+// 		this_processor->pending_preemption = false;
+// 		BlockInternal( (thread_desc*)this_thread );
+// 	}
+// }
+
+void * alarm_loop( __attribute__((unused)) void * args ) {
+	sigset_t mask;
+	sigemptyset( &mask );
+	sigaddset( &mask, SIGALRM );
+	sigaddset( &mask, SIGUSR2 );
+	sigaddset( &mask, SIGINT  );
+
+	if ( pthread_sigmask( SIG_BLOCK, &mask, NULL ) == -1 ) {
+	    abortf( "internal error, pthread_sigmask" );
+	}
+
+	while( true ) {
+		int sig;
+		if( sigwait( &mask, &sig ) != 0  ) {
+			abortf( "internal error, sigwait" );
+		}
+
+		switch( sig) {
+			case SIGALRM:
+				LIB_DEBUG_PRINT_SAFE("Kernel : Preemption thread tick\n");
+				lock( &systemProcessor->alarm_lock DEBUG_CTX2 );
+				tick_preemption();
+				unlock( &systemProcessor->alarm_lock );
+				break;
+			case SIGUSR2:
+				//TODO other actions
+				break;
+			case SIGINT:
+				LIB_DEBUG_PRINT_SAFE("Kernel : Preemption thread stopping\n");
+				return NULL;
+			default:
+				abortf( "internal error, sigwait returned sig %d", sig );
+				break;
+		}
+	}
 }
 
