rem: int state;
add: cpu_status state;
context: thread_wait_on_thread(thread_id id, int *retcode){	sem_id sem;	int state;	struct thread *t;	int rc;	rc = send_signal_etc(id, SIGCONT, 0);	if (rc != B_OK)		return rc;		state = disable_interrupts();	GRAB_THREAD_LOCK();	t = thread_get_thread_struct_locked(id);	if (t != NULL) {		sem = t->return_code_sem;	} else {		sem = B_BAD_THREAD_ID;	}	RELEASE_THREAD_LOCK();	restore_interrupts(state);	rc = acquire_sem(sem);	/* This thread died the way it should, dont ripple a non-error up */	if (rc == B_BAD_SEM_ID) {		rc = B_NO_ERROR;				if (retcode) {			t = thread_get_current_thread();			dprintf("thread_wait_on_thread: thread %ld got return code 0x%x\n",				t->id, t->sem_deleted_retcode);			*retcode = t->sem_deleted_retcode;		}	}	return rc;}