Index: kernel/generic/src/proc/scheduler.c
===================================================================
--- kernel/generic/src/proc/scheduler.c	(revision 3ce7f082ff5b6347e9379564c41ac66808180ade)
+++ 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 3ce7f082ff5b6347e9379564c41ac66808180ade)
+++ 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 3ce7f082ff5b6347e9379564c41ac66808180ade)
+++ 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));
 }
 
