Index: kernel/arch/amd64/include/types.h
===================================================================
--- kernel/arch/amd64/include/types.h	(revision 6adbe3c2c208fc6a1a2f4a5f8fc1436d383025dc)
+++ kernel/arch/amd64/include/types.h	(revision 201abde2f6d30f23f1aab2b46d1a55da556278f1)
@@ -63,4 +63,5 @@
 
 typedef uint8_t bool;
+typedef uint64_t thread_id_t;
 typedef uint64_t task_id_t;
 typedef uint32_t context_id_t;
Index: kernel/arch/arm32/include/types.h
===================================================================
--- kernel/arch/arm32/include/types.h	(revision 6adbe3c2c208fc6a1a2f4a5f8fc1436d383025dc)
+++ kernel/arch/arm32/include/types.h	(revision 201abde2f6d30f23f1aab2b46d1a55da556278f1)
@@ -63,4 +63,5 @@
 
 typedef uint8_t bool;
+typedef uint64_t thread_id_t;
 typedef uint64_t task_id_t;
 typedef uint32_t context_id_t;
Index: kernel/arch/ia32/include/types.h
===================================================================
--- kernel/arch/ia32/include/types.h	(revision 6adbe3c2c208fc6a1a2f4a5f8fc1436d383025dc)
+++ kernel/arch/ia32/include/types.h	(revision 201abde2f6d30f23f1aab2b46d1a55da556278f1)
@@ -63,4 +63,5 @@
 
 typedef uint8_t bool;
+typedef uint64_t thread_id_t;
 typedef uint64_t task_id_t;
 typedef uint32_t context_id_t;
Index: kernel/arch/ia32xen/include/types.h
===================================================================
--- kernel/arch/ia32xen/include/types.h	(revision 6adbe3c2c208fc6a1a2f4a5f8fc1436d383025dc)
+++ kernel/arch/ia32xen/include/types.h	(revision 201abde2f6d30f23f1aab2b46d1a55da556278f1)
@@ -63,4 +63,5 @@
 
 typedef uint8_t bool;
+typedef uint64_t thread_id_t;
 typedef uint64_t task_id_t;
 typedef uint32_t context_id_t;
Index: kernel/arch/ia64/include/types.h
===================================================================
--- kernel/arch/ia64/include/types.h	(revision 6adbe3c2c208fc6a1a2f4a5f8fc1436d383025dc)
+++ kernel/arch/ia64/include/types.h	(revision 201abde2f6d30f23f1aab2b46d1a55da556278f1)
@@ -71,4 +71,5 @@
 
 typedef uint8_t bool;
+typedef uint64_t thread_id_t;
 typedef uint64_t task_id_t;
 typedef uint32_t context_id_t;
Index: kernel/arch/mips32/include/types.h
===================================================================
--- kernel/arch/mips32/include/types.h	(revision 6adbe3c2c208fc6a1a2f4a5f8fc1436d383025dc)
+++ kernel/arch/mips32/include/types.h	(revision 201abde2f6d30f23f1aab2b46d1a55da556278f1)
@@ -63,4 +63,5 @@
 
 typedef uint8_t bool;
+typedef uint64_t thread_id_t;
 typedef uint64_t task_id_t;
 typedef uint32_t context_id_t;
Index: kernel/arch/ppc32/include/types.h
===================================================================
--- kernel/arch/ppc32/include/types.h	(revision 6adbe3c2c208fc6a1a2f4a5f8fc1436d383025dc)
+++ kernel/arch/ppc32/include/types.h	(revision 201abde2f6d30f23f1aab2b46d1a55da556278f1)
@@ -63,4 +63,5 @@
 
 typedef uint8_t bool;
+typedef uint64_t thread_id_t;
 typedef uint64_t task_id_t;
 typedef uint32_t context_id_t;
Index: kernel/arch/ppc64/include/types.h
===================================================================
--- kernel/arch/ppc64/include/types.h	(revision 6adbe3c2c208fc6a1a2f4a5f8fc1436d383025dc)
+++ kernel/arch/ppc64/include/types.h	(revision 201abde2f6d30f23f1aab2b46d1a55da556278f1)
@@ -63,4 +63,5 @@
 
 typedef uint8_t bool;
+typedef uint64_t thread_id_t;
 typedef uint64_t task_id_t;
 typedef uint32_t context_id_t;
Index: kernel/arch/sparc64/include/types.h
===================================================================
--- kernel/arch/sparc64/include/types.h	(revision 6adbe3c2c208fc6a1a2f4a5f8fc1436d383025dc)
+++ kernel/arch/sparc64/include/types.h	(revision 201abde2f6d30f23f1aab2b46d1a55da556278f1)
@@ -63,4 +63,5 @@
 
 typedef uint8_t bool;
+typedef uint64_t thread_id_t;
 typedef uint64_t task_id_t;
 typedef uint32_t context_id_t;
Index: kernel/generic/include/interrupt.h
===================================================================
--- kernel/generic/include/interrupt.h	(revision 6adbe3c2c208fc6a1a2f4a5f8fc1436d383025dc)
+++ kernel/generic/include/interrupt.h	(revision 201abde2f6d30f23f1aab2b46d1a55da556278f1)
@@ -49,5 +49,5 @@
 { \
 	if (istate_from_uspace(istate)) { \
-		klog_printf("Task %lld killed due to an exception at %p.", TASK->taskid, istate_get_pc(istate)); \
+		klog_printf("Task %llu killed due to an exception at %p.", TASK->taskid, istate_get_pc(istate)); \
 		klog_printf("  " cmd, ##__VA_ARGS__); \
 		task_kill(TASK->taskid); \
Index: kernel/generic/include/proc/task.h
===================================================================
--- kernel/generic/include/proc/task.h	(revision 6adbe3c2c208fc6a1a2f4a5f8fc1436d383025dc)
+++ kernel/generic/include/proc/task.h	(revision 201abde2f6d30f23f1aab2b46d1a55da556278f1)
@@ -91,8 +91,8 @@
 	 * certain extent.
 	 */
-	atomic_t active_calls;  
+	atomic_t active_calls;
 	
 	/** Architecture specific task data. */
-	task_arch_t arch;	
+	task_arch_t arch;
 	
 	/**
Index: kernel/generic/include/proc/thread.h
===================================================================
--- kernel/generic/include/proc/thread.h	(revision 6adbe3c2c208fc6a1a2f4a5f8fc1436d383025dc)
+++ kernel/generic/include/proc/thread.h	(revision 201abde2f6d30f23f1aab2b46d1a55da556278f1)
@@ -194,5 +194,5 @@
 	int priority;
 	/** Thread ID. */
-	uint32_t tid;
+	thread_id_t tid;
 	
 	/** Architecture-specific data. */
@@ -249,7 +249,7 @@
 
 /* Thread syscall prototypes. */
-unative_t sys_thread_create(uspace_arg_t *uspace_uarg, char *uspace_name);
-unative_t sys_thread_exit(int uspace_status);
-unative_t sys_thread_get_id(void);
+extern unative_t sys_thread_create(uspace_arg_t *uspace_uarg, char *uspace_name, thread_id_t *uspace_thread_id);
+extern unative_t sys_thread_exit(int uspace_status);
+extern unative_t sys_thread_get_id(thread_id_t *uspace_thread_id);
 
 #endif
Index: kernel/generic/src/adt/btree.c
===================================================================
--- kernel/generic/src/adt/btree.c	(revision 6adbe3c2c208fc6a1a2f4a5f8fc1436d383025dc)
+++ kernel/generic/src/adt/btree.c	(revision 201abde2f6d30f23f1aab2b46d1a55da556278f1)
@@ -971,5 +971,5 @@
 		printf("(");
 		for (i = 0; i < node->keys; i++) {
-			printf("%lld%s", node->key[i], i < node->keys - 1 ? "," : "");
+			printf("%llu%s", node->key[i], i < node->keys - 1 ? "," : "");
 			if (node->depth && node->subtree[i]) {
 				list_append(&node->subtree[i]->bfs_link, &head);
@@ -993,5 +993,5 @@
 		printf("(");
 		for (i = 0; i < node->keys; i++)
-			printf("%lld%s", node->key[i], i < node->keys - 1 ? "," : "");
+			printf("%llu%s", node->key[i], i < node->keys - 1 ? "," : "");
 		printf(")");
 	}
Index: kernel/generic/src/console/cmd.c
===================================================================
--- kernel/generic/src/console/cmd.c	(revision 6adbe3c2c208fc6a1a2f4a5f8fc1436d383025dc)
+++ kernel/generic/src/console/cmd.c	(revision 201abde2f6d30f23f1aab2b46d1a55da556278f1)
@@ -714,5 +714,5 @@
 int cmd_set4(cmd_arg_t *argv)
 {
-	uint32_t *addr ;
+	uint32_t *addr;
 	uint32_t arg1 = argv[1].intval;
 	bool pointer = false;
Index: kernel/generic/src/ipc/ipc.c
===================================================================
--- kernel/generic/src/ipc/ipc.c	(revision 6adbe3c2c208fc6a1a2f4a5f8fc1436d383025dc)
+++ kernel/generic/src/ipc/ipc.c	(revision 201abde2f6d30f23f1aab2b46d1a55da556278f1)
@@ -503,5 +503,5 @@
 	for (tmp=task->answerbox.calls.next; tmp != &task->answerbox.calls;tmp = tmp->next) {
 		call = list_get_instance(tmp, call_t, link);
-		printf("Callid: %p Srctask:%lld M:%d A1:%d A2:%d A3:%d Flags:%x\n",call,
+		printf("Callid: %p Srctask:%llu M:%d A1:%d A2:%d A3:%d Flags:%x\n",call,
 		       call->sender->taskid, IPC_GET_METHOD(call->data), IPC_GET_ARG1(call->data),
 		       IPC_GET_ARG2(call->data), IPC_GET_ARG3(call->data), call->flags);
@@ -513,5 +513,5 @@
 	     tmp = tmp->next) {
 		call = list_get_instance(tmp, call_t, link);
-		printf("Callid: %p Srctask:%lld M:%d A1:%d A2:%d A3:%d Flags:%x\n",call,
+		printf("Callid: %p Srctask:%llu M:%d A1:%d A2:%d A3:%d Flags:%x\n",call,
 		       call->sender->taskid, IPC_GET_METHOD(call->data), IPC_GET_ARG1(call->data),
 		       IPC_GET_ARG2(call->data), IPC_GET_ARG3(call->data), call->flags);
Index: kernel/generic/src/proc/scheduler.c
===================================================================
--- kernel/generic/src/proc/scheduler.c	(revision 6adbe3c2c208fc6a1a2f4a5f8fc1436d383025dc)
+++ kernel/generic/src/proc/scheduler.c	(revision 201abde2f6d30f23f1aab2b46d1a55da556278f1)
@@ -451,5 +451,5 @@
 			 * Entering state is unexpected.
 			 */
-			panic("tid%d: unexpected state %s\n", THREAD->tid,
+			panic("tid%llu: unexpected state %s\n", THREAD->tid,
 				thread_states[THREAD->state]);
 			break;
@@ -504,5 +504,5 @@
 
 #ifdef SCHEDULER_VERBOSE
-	printf("cpu%d: tid %d (priority=%d, ticks=%lld, nrdy=%ld)\n",
+	printf("cpu%d: tid %llu (priority=%d, ticks=%llu, nrdy=%ld)\n",
 	    CPU->id, THREAD->tid, THREAD->priority, THREAD->ticks,
 	    atomic_get(&CPU->nrdy));
@@ -640,5 +640,5 @@
 				spinlock_lock(&t->lock);
 #ifdef KCPULB_VERBOSE
-				printf("kcpulb%d: TID %d -> cpu%d, nrdy=%ld, "
+				printf("kcpulb%d: TID %llu -> cpu%d, nrdy=%ld, "
 				    "avg=%nd\n", CPU->id, t->tid, CPU->id,
 				    atomic_get(&CPU->nrdy),
@@ -723,5 +723,5 @@
 				cur = cur->next) {
 				t = list_get_instance(cur, thread_t, rq_link);
-				printf("%d(%s) ", t->tid,
+				printf("%llu(%s) ", t->tid,
 				    thread_states[t->state]);
 			}
Index: kernel/generic/src/proc/task.c
===================================================================
--- kernel/generic/src/proc/task.c	(revision 6adbe3c2c208fc6a1a2f4a5f8fc1436d383025dc)
+++ kernel/generic/src/proc/task.c	(revision 201abde2f6d30f23f1aab2b46d1a55da556278f1)
@@ -400,5 +400,5 @@
 			order(task_get_accounting(t), &cycles, &suffix);
 			
-			printf("%-6lld %-10s %-3ld %#10zx %#10zx %9llu%c %7zd "
+			printf("%-6llu %-10s %-3ld %#10zx %#10zx %9llu%c %7zd "
 			    "%6zd", t->taskid, t->name, t->context, t, t->as,
 			    cycles, suffix, t->refcount,
@@ -487,5 +487,5 @@
 	ipc_cleanup();
 	futex_cleanup();
-	klog_printf("Cleanup of task %lld completed.", TASK->taskid);
+	klog_printf("Cleanup of task %llu completed.", TASK->taskid);
 }
 
Index: kernel/generic/src/proc/thread.c
===================================================================
--- kernel/generic/src/proc/thread.c	(revision 6adbe3c2c208fc6a1a2f4a5f8fc1436d383025dc)
+++ kernel/generic/src/proc/thread.c	(revision 201abde2f6d30f23f1aab2b46d1a55da556278f1)
@@ -95,5 +95,5 @@
 
 SPINLOCK_INITIALIZE(tidlock);
-uint32_t last_tid = 0;
+thread_id_t last_tid = 0;
 
 static slab_cache_t *thread_slab;
@@ -581,5 +581,5 @@
 			order(t->cycles, &cycles, &suffix);
 			
-			printf("%-6zd %-10s %#10zx %-8s %#10zx %-3ld %#10zx "
+			printf("%-6llu %-10s %#10zx %-8s %#10zx %-3ld %#10zx "
 			    "%#10zx %9llu%c ", t->tid, t->name, t,
 			    thread_states[t->state], t->task, t->task->context,
@@ -637,10 +637,9 @@
  *
  */
-unative_t sys_thread_create(uspace_arg_t *uspace_uarg, char *uspace_name)
+unative_t sys_thread_create(uspace_arg_t *uspace_uarg, char *uspace_name, thread_id_t *uspace_thread_id)
 {
 	thread_t *t;
 	char namebuf[THREAD_NAME_BUFLEN];
 	uspace_arg_t *kernel_uarg;
-	uint32_t tid;
 	int rc;
 
@@ -659,10 +658,12 @@
 	    false);
 	if (t) {
-		tid = t->tid;
 		thread_ready(t);
-		return (unative_t) tid; 
-	} else {
+		if (uspace_thread_id != NULL)
+			return (unative_t) copy_to_uspace(uspace_thread_id, &t->tid,
+		    	sizeof(t->tid));
+		else
+			return 0;
+	} else
 		free(kernel_uarg);
-	}
 
 	return (unative_t) ENOMEM;
@@ -681,7 +682,10 @@
 /** Syscall for getting TID.
  *
- * @return Thread ID.
- */
-unative_t sys_thread_get_id(void)
+ * @param uspace_thread_id Userspace address of 8-byte buffer where to store
+ * current thread ID.
+ *
+ * @return 0 on success or an error code from @ref errno.h.
+ */
+unative_t sys_thread_get_id(thread_id_t *uspace_thread_id)
 {
 	/*
@@ -689,5 +693,6 @@
 	 * remains constant for the lifespan of the thread.
 	 */
-	return THREAD->tid;
+	return (unative_t) copy_to_uspace(uspace_thread_id, &THREAD->tid,
+	    sizeof(THREAD->tid));
 }
 
Index: kernel/generic/src/syscall/syscall.c
===================================================================
--- kernel/generic/src/syscall/syscall.c	(revision 6adbe3c2c208fc6a1a2f4a5f8fc1436d383025dc)
+++ kernel/generic/src/syscall/syscall.c	(revision 201abde2f6d30f23f1aab2b46d1a55da556278f1)
@@ -101,5 +101,5 @@
 		rc = syscall_table[id](a1, a2, a3, a4);
 	else {
-		klog_printf("TASK %lld: Unknown syscall id %d",TASK->taskid,id);
+		klog_printf("TASK %llu: Unknown syscall id %d",TASK->taskid,id);
 		task_kill(TASK->taskid);
 		thread_exit();
Index: kernel/test/fpu/fpu1.c
===================================================================
--- kernel/test/fpu/fpu1.c	(revision 6adbe3c2c208fc6a1a2f4a5f8fc1436d383025dc)
+++ kernel/test/fpu/fpu1.c	(revision 201abde2f6d30f23f1aab2b46d1a55da556278f1)
@@ -127,5 +127,5 @@
 		if ((int) (100000000 * e) != E_10e8) {
 			if (!sh_quiet)
-				printf("tid%d: e*10e8=%zd should be %zd\n", THREAD->tid, (unative_t) (100000000 * e), (unative_t) E_10e8);
+				printf("tid%llu: e*10e8=%zd should be %zd\n", THREAD->tid, (unative_t) (100000000 * e), (unative_t) E_10e8);
 			atomic_inc(&threads_fault);
 			break;
@@ -162,5 +162,5 @@
 		if ((int) (1000000 * pi) != PI_10e8) {
 			if (!sh_quiet)
-				printf("tid%d: pi*10e8=%zd should be %zd\n", THREAD->tid, (unative_t) (1000000 * pi), (unative_t) (PI_10e8 / 100));
+				printf("tid%llu: pi*10e8=%zd should be %zd\n", THREAD->tid, (unative_t) (1000000 * pi), (unative_t) (PI_10e8 / 100));
 			atomic_inc(&threads_fault);
 			break;
@@ -169,5 +169,5 @@
 		if ((int) (100000000 * pi) != PI_10e8) {
 			if (!sh_quiet)
-				printf("tid%d: pi*10e8=%zd should be %zd\n", THREAD->tid, (unative_t) (100000000 * pi), (unative_t) PI_10e8);
+				printf("tid%llu: pi*10e8=%zd should be %zd\n", THREAD->tid, (unative_t) (100000000 * pi), (unative_t) PI_10e8);
 			atomic_inc(&threads_fault);
 			break;
Index: kernel/test/fpu/mips2.c
===================================================================
--- kernel/test/fpu/mips2.c	(revision 6adbe3c2c208fc6a1a2f4a5f8fc1436d383025dc)
+++ kernel/test/fpu/mips2.c	(revision 201abde2f6d30f23f1aab2b46d1a55da556278f1)
@@ -73,5 +73,5 @@
 		if (arg != after_arg) {
 			if (!sh_quiet)
-				printf("General reg tid%d: arg(%d) != %d\n", THREAD->tid, arg, after_arg);
+				printf("General reg tid%llu: arg(%d) != %d\n", THREAD->tid, arg, after_arg);
 			atomic_inc(&threads_fault);
 			break;
@@ -105,5 +105,5 @@
 		if (arg != after_arg) {
 			if (!sh_quiet)
-				printf("General reg tid%d: arg(%d) != %d\n", THREAD->tid, arg, after_arg);
+				printf("General reg tid%llu: arg(%d) != %d\n", THREAD->tid, arg, after_arg);
 			atomic_inc(&threads_fault);
 			break;
Index: kernel/test/fpu/sse1.c
===================================================================
--- kernel/test/fpu/sse1.c	(revision 6adbe3c2c208fc6a1a2f4a5f8fc1436d383025dc)
+++ kernel/test/fpu/sse1.c	(revision 201abde2f6d30f23f1aab2b46d1a55da556278f1)
@@ -73,5 +73,5 @@
 		if (arg != after_arg) {
 			if (!sh_quiet)
-				printf("tid%d: arg(%d) != %d\n", THREAD->tid, arg, after_arg);
+				printf("tid%llu: arg(%d) != %d\n", THREAD->tid, arg, after_arg);
 			atomic_inc(&threads_fault);
 			break;
@@ -105,5 +105,5 @@
 		if (arg != after_arg) {
 			if (!sh_quiet)
-				printf("tid%d: arg(%d) != %d\n", THREAD->tid, arg, after_arg);
+				printf("tid%llu: arg(%d) != %d\n", THREAD->tid, arg, after_arg);
 			atomic_inc(&threads_fault);
 			break;
Index: kernel/test/mm/falloc2.c
===================================================================
--- kernel/test/mm/falloc2.c	(revision 6adbe3c2c208fc6a1a2f4a5f8fc1436d383025dc)
+++ kernel/test/mm/falloc2.c	(revision 201abde2f6d30f23f1aab2b46d1a55da556278f1)
@@ -59,5 +59,5 @@
 	if (frames == NULL) {
 		if (!sh_quiet)
-			printf("Thread #%d (cpu%d): Unable to allocate frames\n", THREAD->tid, CPU->id);
+			printf("Thread #%llu (cpu%d): Unable to allocate frames\n", THREAD->tid, CPU->id);
 		atomic_inc(&thread_fail);
 		atomic_dec(&thread_count);
@@ -70,5 +70,5 @@
 		for (order = 0; order <= MAX_ORDER; order++) {
 			if (!sh_quiet)
-				printf("Thread #%d (cpu%d): Allocating %d frames blocks ... \n", THREAD->tid, CPU->id, 1 << order);
+				printf("Thread #%llu (cpu%d): Allocating %d frames blocks ... \n", THREAD->tid, CPU->id, 1 << order);
 			
 			allocated = 0;
@@ -83,8 +83,8 @@
 			
 			if (!sh_quiet)
-				printf("Thread #%d (cpu%d): %d blocks allocated.\n", THREAD->tid, CPU->id, allocated);
+				printf("Thread #%llu (cpu%d): %d blocks allocated.\n", THREAD->tid, CPU->id, allocated);
 			
 			if (!sh_quiet)
-				printf("Thread #%d (cpu%d): Deallocating ... \n", THREAD->tid, CPU->id);
+				printf("Thread #%llu (cpu%d): Deallocating ... \n", THREAD->tid, CPU->id);
 			
 			for (i = 0; i < allocated; i++) {
@@ -92,5 +92,5 @@
 					if (((uint8_t *) frames[i])[k] != val) {
 						if (!sh_quiet)
-							printf("Thread #%d (cpu%d): Unexpected data (%d) in block %p offset %#zx\n", THREAD->tid, CPU->id, ((char *) frames[i])[k], frames[i], k);
+							printf("Thread #%llu (cpu%d): Unexpected data (%d) in block %p offset %#zx\n", THREAD->tid, CPU->id, ((char *) frames[i])[k], frames[i], k);
 						atomic_inc(&thread_fail);
 						goto cleanup;
@@ -101,5 +101,5 @@
 			
 			if (!sh_quiet)
-				printf("Thread #%d (cpu%d): Finished run.\n", THREAD->tid, CPU->id);
+				printf("Thread #%llu (cpu%d): Finished run.\n", THREAD->tid, CPU->id);
 		}
 	}
@@ -109,5 +109,5 @@
 	
 	if (!sh_quiet)
-		printf("Thread #%d (cpu%d): Exiting\n", THREAD->tid, CPU->id);
+		printf("Thread #%llu (cpu%d): Exiting\n", THREAD->tid, CPU->id);
 	atomic_dec(&thread_count);
 }
Index: kernel/test/mm/slab1.c
===================================================================
--- kernel/test/mm/slab1.c	(revision 6adbe3c2c208fc6a1a2f4a5f8fc1436d383025dc)
+++ kernel/test/mm/slab1.c	(revision 201abde2f6d30f23f1aab2b46d1a55da556278f1)
@@ -138,5 +138,5 @@
 	
 	if (!sh_quiet)
-		printf("Starting thread #%d...\n", THREAD->tid);
+		printf("Starting thread #%llu...\n", THREAD->tid);
 	
 	for (j = 0; j < 10; j++) {
@@ -152,5 +152,5 @@
 	
 	if (!sh_quiet)
-		printf("Thread #%d finished\n", THREAD->tid);
+		printf("Thread #%llu finished\n", THREAD->tid);
 	
 	semaphore_up(&thr_sem);
Index: kernel/test/mm/slab2.c
===================================================================
--- kernel/test/mm/slab2.c	(revision 6adbe3c2c208fc6a1a2f4a5f8fc1436d383025dc)
+++ kernel/test/mm/slab2.c	(revision 201abde2f6d30f23f1aab2b46d1a55da556278f1)
@@ -151,9 +151,9 @@
 	
 	if (!sh_quiet)
-		printf("Starting thread #%d...\n",THREAD->tid);
+		printf("Starting thread #%llu...\n",THREAD->tid);
 
 	/* Alloc all */
 	if (!sh_quiet)
-		printf("Thread #%d allocating...\n", THREAD->tid);
+		printf("Thread #%llu allocating...\n", THREAD->tid);
 	
 	while (1) {
@@ -167,5 +167,5 @@
 	
 	if (!sh_quiet)
-		printf("Thread #%d releasing...\n", THREAD->tid);
+		printf("Thread #%llu releasing...\n", THREAD->tid);
 	
 	while (data) {
@@ -177,5 +177,5 @@
 	
 	if (!sh_quiet)
-		printf("Thread #%d allocating...\n", THREAD->tid);
+		printf("Thread #%llu allocating...\n", THREAD->tid);
 	
 	while (1) {
@@ -189,5 +189,5 @@
 	
 	if (!sh_quiet)
-		printf("Thread #%d releasing...\n", THREAD->tid);
+		printf("Thread #%llu releasing...\n", THREAD->tid);
 	
 	while (data) {
@@ -199,5 +199,5 @@
 	
 	if (!sh_quiet)
-		printf("Thread #%d finished\n", THREAD->tid);
+		printf("Thread #%llu finished\n", THREAD->tid);
 	
 	slab_print_list();
Index: kernel/test/synch/rwlock3.c
===================================================================
--- kernel/test/synch/rwlock3.c	(revision 6adbe3c2c208fc6a1a2f4a5f8fc1436d383025dc)
+++ kernel/test/synch/rwlock3.c	(revision 201abde2f6d30f23f1aab2b46d1a55da556278f1)
@@ -46,5 +46,5 @@
 	
 	if (!sh_quiet)
-		printf("cpu%d, tid %d: trying to lock rwlock for reading....\n", CPU->id, THREAD->tid);
+		printf("cpu%d, tid %llu: trying to lock rwlock for reading....\n", CPU->id, THREAD->tid);
 	
 	rwlock_read_lock(&rwlock);
@@ -52,6 +52,6 @@
 	
 	if (!sh_quiet) {
-		printf("cpu%d, tid %d: success\n", CPU->id, THREAD->tid);    		
-		printf("cpu%d, tid %d: trying to lock rwlock for writing....\n", CPU->id, THREAD->tid);    	
+		printf("cpu%d, tid %llu: success\n", CPU->id, THREAD->tid);    		
+		printf("cpu%d, tid %llu: trying to lock rwlock for writing....\n", CPU->id, THREAD->tid);    	
 	}
 
@@ -60,5 +60,5 @@
 	
 	if (!sh_quiet)
-		printf("cpu%d, tid %d: success\n", CPU->id, THREAD->tid);
+		printf("cpu%d, tid %llu: success\n", CPU->id, THREAD->tid);
 	
 	atomic_dec(&thread_count);
Index: kernel/test/synch/rwlock4.c
===================================================================
--- kernel/test/synch/rwlock4.c	(revision 6adbe3c2c208fc6a1a2f4a5f8fc1436d383025dc)
+++ kernel/test/synch/rwlock4.c	(revision 201abde2f6d30f23f1aab2b46d1a55da556278f1)
@@ -75,10 +75,10 @@
 	
 	if (!sh_quiet)
-		printf("cpu%d, tid %d w+ (%d)\n", CPU->id, THREAD->tid, to);
+		printf("cpu%d, tid %llu w+ (%d)\n", CPU->id, THREAD->tid, to);
 	
 	rc = rwlock_write_lock_timeout(&rwlock, to);
 	if (SYNCH_FAILED(rc)) {
 		if (!sh_quiet)
-			printf("cpu%d, tid %d w!\n", CPU->id, THREAD->tid);
+			printf("cpu%d, tid %llu w!\n", CPU->id, THREAD->tid);
 		atomic_dec(&thread_count);
 		return;
@@ -86,5 +86,5 @@
 	
 	if (!sh_quiet)
-		printf("cpu%d, tid %d w=\n", CPU->id, THREAD->tid);
+		printf("cpu%d, tid %llu w=\n", CPU->id, THREAD->tid);
 
 	if (rwlock.readers_in) {
@@ -107,5 +107,5 @@
 	
 	if (!sh_quiet)
-		printf("cpu%d, tid %d w-\n", CPU->id, THREAD->tid);
+		printf("cpu%d, tid %llu w-\n", CPU->id, THREAD->tid);
 	atomic_dec(&thread_count);
 }
@@ -120,10 +120,10 @@
 	
 	if (!sh_quiet)
-		printf("cpu%d, tid %d r+ (%d)\n", CPU->id, THREAD->tid, to);
+		printf("cpu%d, tid %llu r+ (%d)\n", CPU->id, THREAD->tid, to);
 	
 	rc = rwlock_read_lock_timeout(&rwlock, to);
 	if (SYNCH_FAILED(rc)) {
 		if (!sh_quiet)
-			printf("cpu%d, tid %d r!\n", CPU->id, THREAD->tid);
+			printf("cpu%d, tid %llu r!\n", CPU->id, THREAD->tid);
 		atomic_dec(&thread_count);
 		return;
@@ -131,5 +131,5 @@
 	
 	if (!sh_quiet)
-		printf("cpu%d, tid %d r=\n", CPU->id, THREAD->tid);
+		printf("cpu%d, tid %llu r=\n", CPU->id, THREAD->tid);
 	
 	thread_usleep(30000);
@@ -137,5 +137,5 @@
 	
 	if (!sh_quiet)
-		printf("cpu%d, tid %d r-\n", CPU->id, THREAD->tid);
+		printf("cpu%d, tid %llu r-\n", CPU->id, THREAD->tid);
 	atomic_dec(&thread_count);
 }
Index: kernel/test/synch/semaphore2.c
===================================================================
--- kernel/test/synch/semaphore2.c	(revision 6adbe3c2c208fc6a1a2f4a5f8fc1436d383025dc)
+++ kernel/test/synch/semaphore2.c	(revision 201abde2f6d30f23f1aab2b46d1a55da556278f1)
@@ -68,16 +68,16 @@
 	
 	to = random(20000);
-	printf("cpu%d, tid %d down+ (%d)\n", CPU->id, THREAD->tid, to);
+	printf("cpu%d, tid %llu down+ (%d)\n", CPU->id, THREAD->tid, to);
 	rc = semaphore_down_timeout(&sem, to);
 	if (SYNCH_FAILED(rc)) {
-		printf("cpu%d, tid %d down!\n", CPU->id, THREAD->tid);
+		printf("cpu%d, tid %llu down!\n", CPU->id, THREAD->tid);
 		return;
 	}
 	
-	printf("cpu%d, tid %d down=\n", CPU->id, THREAD->tid);	
+	printf("cpu%d, tid %llu down=\n", CPU->id, THREAD->tid);	
 	thread_usleep(random(30000));
 	
 	semaphore_up(&sem);
-	printf("cpu%d, tid %d up\n", CPU->id, THREAD->tid);
+	printf("cpu%d, tid %llu up\n", CPU->id, THREAD->tid);
 }
 
Index: kernel/test/thread/thread1.c
===================================================================
--- kernel/test/thread/thread1.c	(revision 6adbe3c2c208fc6a1a2f4a5f8fc1436d383025dc)
+++ kernel/test/thread/thread1.c	(revision 201abde2f6d30f23f1aab2b46d1a55da556278f1)
@@ -49,5 +49,5 @@
 	while (atomic_get(&finish)) {
 		if (!sh_quiet)
-			printf("%d ", (int) (THREAD->tid));
+			printf("%llu ", THREAD->tid);
 		thread_usleep(100000);
 	}
