+ return i;
+}
+
+struct thread*
+alloc_thread(struct proc_info* process) {
+ if (process->thread_count >= MAX_THREAD_PP) {
+ return NULL;
+ }
+
+ struct thread* th = cake_grab(thread_pile);
+
+ th->process = process;
+ th->created = clock_systime();
+
+ // FIXME we need a better tid allocation method!
+ th->tid = th->created;
+ th->tid = (th->created ^ ((ptr_t)th)) % MAX_THREAD_PP;
+
+ th->state = PS_CREATED;
+
+ llist_init_head(&th->sleep.sleepers);
+ llist_init_head(&th->sched_sibs);
+ llist_init_head(&th->proc_sibs);
+ waitq_init(&th->waitqueue);
+
+ return th;
+}
+
+struct proc_info*
+alloc_process()
+{
+ pid_t i = get_free_pid();
+