+ async command error_t ThreadScheduler.joinThread(thread_id_t id) {
+ thread_t* t = call ThreadInfo.get[id]();
+ atomic {
+ if(current_thread == tos_thread)
+ return FAIL;
+ if (t->state != TOSTHREAD_STATE_INACTIVE) {
+ call BitArrayUtils.setBit(t->joinedOnMe, current_thread->id);
+ call ThreadScheduler.suspendCurrentThread();
+ return SUCCESS;
+ }
+ }
+ return EALREADY;
+ }
+