This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

RTX5 osThreadJoin() return value

Greetings,

The osThreadJoin() documentation indicates osOK should be returned if the identified "thread has already been terminated and joined or once the thread has been terminated and the join operations succeeds".  I'm trying to follow the code in rtx_thread.c::svcRtxThreadJoin() (from GitHub):

...
  if (thread->state == osRtxThreadTerminated) {
    osRtxThreadListUnlink(&osRtxInfo.thread.terminate_list, thread);
    osRtxThreadFree(thread);
    EvrRtxThreadJoined(thread);
    status = osOK;
  } else {
    // Suspend current Thread                                                                                                        
    if (osRtxThreadWaitEnter(osRtxThreadWaitingJoin, osWaitForever)) {
      thread_running = osRtxThreadGetRunning();
      thread_running->thread_next = thread;
      thread->thread_join = thread_running;
      thread->attr &= ~osThreadJoinable;
      EvrRtxThreadJoinPending(thread);
    } else {
      EvrRtxThreadError(thread, (int32_t)osErrorResource);
    }
    status = osErrorResource;
  }

  return status;

In the else clause where the calling thread must wait for the identified thread to join, how does the calling thread get osOK?  What did I miss?

Thanks very much!