Index: kernel/generic/include/arch.h
===================================================================
--- kernel/generic/include/arch.h	(revision 42d3be37f381c85c99f60de83e4acaeff812d699)
+++ kernel/generic/include/arch.h	(revision 764c302a6272fd5764d4e38c8b741894512c5c2a)
@@ -61,4 +61,5 @@
 	cpu_t *cpu;			/**< Executing cpu. */
 	as_t *as;			/**< Current address space. */
+	context_id_t context;	/**< Current security context. */
 };
 
Index: kernel/generic/include/proc/scheduler.h
===================================================================
--- kernel/generic/include/proc/scheduler.h	(revision 42d3be37f381c85c99f60de83e4acaeff812d699)
+++ kernel/generic/include/proc/scheduler.h	(revision 764c302a6272fd5764d4e38c8b741894512c5c2a)
@@ -27,5 +27,5 @@
  */
 
- /** @addtogroup genericproc
+/** @addtogroup genericproc
  * @{
  */
@@ -70,5 +70,4 @@
 #endif
 
- /** @}
+/** @}
  */
-
Index: kernel/generic/include/proc/task.h
===================================================================
--- kernel/generic/include/proc/task.h	(revision 42d3be37f381c85c99f60de83e4acaeff812d699)
+++ kernel/generic/include/proc/task.h	(revision 764c302a6272fd5764d4e38c8b741894512c5c2a)
@@ -27,5 +27,5 @@
  */
 
- /** @addtogroup genericproc
+/** @addtogroup genericproc
  * @{
  */
@@ -59,4 +59,5 @@
 	as_t *as;		/**< Address space. */
 	task_id_t taskid;	/**< Unique identity of task */
+	context_id_t context;	/**< Task security context */
 
 	/** If this is true, new threads can become part of the task. */
Index: kernel/generic/include/proc/thread.h
===================================================================
--- kernel/generic/include/proc/thread.h	(revision 42d3be37f381c85c99f60de83e4acaeff812d699)
+++ kernel/generic/include/proc/thread.h	(revision 764c302a6272fd5764d4e38c8b741894512c5c2a)
@@ -27,5 +27,5 @@
  */
 
- /** @addtogroup genericproc
+/** @addtogroup genericproc
  * @{
  */
@@ -147,4 +147,5 @@
 	int priority;				/**< Thread's priority. Implemented as index to CPU->rq */
 	uint32_t tid;				/**< Thread ID. */
+	context_id_t context;		/**< Thread security context */
 	
 	thread_arch_t arch;			/**< Architecture-specific data. */
@@ -193,5 +194,4 @@
 #endif
 
- /** @}
+/** @}
  */
-
Index: kernel/generic/include/proc/uarg.h
===================================================================
--- kernel/generic/include/proc/uarg.h	(revision 42d3be37f381c85c99f60de83e4acaeff812d699)
+++ kernel/generic/include/proc/uarg.h	(revision 764c302a6272fd5764d4e38c8b741894512c5c2a)
@@ -27,5 +27,5 @@
  */
 
- /** @addtogroup genericproc
+/** @addtogroup genericproc
  * @{
  */
@@ -49,5 +49,4 @@
 #endif
 
- /** @}
+/** @}
  */
-
Index: kernel/generic/include/typedefs.h
===================================================================
--- kernel/generic/include/typedefs.h	(revision 42d3be37f381c85c99f60de83e4acaeff812d699)
+++ kernel/generic/include/typedefs.h	(revision 764c302a6272fd5764d4e38c8b741894512c5c2a)
@@ -46,4 +46,5 @@
 
 typedef unsigned long long task_id_t;
+typedef unsigned long context_id_t;
 
 typedef struct cpu_info cpu_info_t;
Index: kernel/generic/src/proc/task.c
===================================================================
--- kernel/generic/src/proc/task.c	(revision 42d3be37f381c85c99f60de83e4acaeff812d699)
+++ kernel/generic/src/proc/task.c	(revision 764c302a6272fd5764d4e38c8b741894512c5c2a)
@@ -116,4 +116,5 @@
 	ta->main_thread = NULL;
 	ta->refcount = 0;
+	ta->context = THE->context;
 
 	ta->capabilities = 0;
@@ -356,6 +357,6 @@
 		
 			spinlock_lock(&t->lock);
-			printf("%s(%lld): address=%#zx, as=%#zx, ActiveCalls: %zd",
-				t->name, t->taskid, t, t->as, atomic_get(&t->active_calls));
+			printf("%s(%lld): context=%ld, address=%#zx, as=%#zx, ActiveCalls: %zd",
+				t->name, t->taskid, t->context, t, t->as, atomic_get(&t->active_calls));
 			for (j=0; j < IPC_MAX_PHONES; j++) {
 				if (t->phones[j].callee)
Index: kernel/generic/src/proc/the.c
===================================================================
--- kernel/generic/src/proc/the.c	(revision 42d3be37f381c85c99f60de83e4acaeff812d699)
+++ kernel/generic/src/proc/the.c	(revision 764c302a6272fd5764d4e38c8b741894512c5c2a)
@@ -59,4 +59,5 @@
 	the->task = NULL;
 	the->as = NULL;
+	the->context = 0;
 }
 
Index: kernel/generic/src/proc/thread.c
===================================================================
--- kernel/generic/src/proc/thread.c	(revision 42d3be37f381c85c99f60de83e4acaeff812d699)
+++ kernel/generic/src/proc/thread.c	(revision 764c302a6272fd5764d4e38c8b741894512c5c2a)
@@ -124,5 +124,5 @@
 static int thr_constructor(void *obj, int kmflags)
 {
-	thread_t *t = (thread_t *)obj;
+	thread_t *t = (thread_t *) obj;
 
 	spinlock_initialize(&t->lock, "thread_t_lock");
@@ -156,5 +156,5 @@
 static int thr_destructor(void *obj)
 {
-	thread_t *t = (thread_t *)obj;
+	thread_t *t = (thread_t *) obj;
 
 	frame_free(KA2PA(t->kstack));
@@ -300,5 +300,5 @@
 	
 	/* Not needed, but good for debugging */
-	memsetb((uintptr_t)t->kstack, THREAD_STACK_SIZE * 1<<STACK_FRAMES, 0);
+	memsetb((uintptr_t) t->kstack, THREAD_STACK_SIZE * 1 << STACK_FRAMES, 0);
 	
 	ipl = interrupts_disable();
@@ -319,4 +319,5 @@
 	memcpy(t->name, name, THREAD_NAME_BUFLEN);
 	
+	t->context = THE->context;
 	t->thread_code = func;
 	t->thread_arg = arg;
@@ -534,6 +535,6 @@
 		
 			t = (thread_t *) node->value[i];
-			printf("%s: address=%#zx, tid=%zd, state=%s, task=%#zx, code=%#zx, stack=%#zx, cpu=",
-				t->name, t, t->tid, thread_states[t->state], t->task, t->thread_code, t->kstack);
+			printf("%s: address=%#zx, tid=%zd, context=%ld, state=%s, task=%#zx, code=%#zx, stack=%#zx, cpu=",
+				t->name, t, t->tid, t->context, thread_states[t->state], t->task, t->thread_code, t->kstack);
 			if (t->cpu)
 				printf("cpu%zd", t->cpu->id);
