/* Create a thread and add it to Active Threads and set it to state READY.  */
osThreadId svcThreadCreate(osThreadDef_t *thread_def, void *argument)
/* Create a thread and add it to Active Threads and set it to state READY.  */
osThreadId svcThreadCreate(osThreadDef_t *thread_def, void *argument)
{
    sysThreadError(osErrorParameter); 
    return NULL; 
  }
  U8 priority = thread_def->tpriority - osPriorityIdle + 1;
  P_TCB task_context = &thread_def->tcb;
  task_context->stack      = (U32*)thread_def->stack_pointer;
  task_context->priv_stack = thread_def->stacksize;
  task_context->msg = argument;
  rt_init_context (task_context, priority, (FUNCP)thread_def->pthread);
  OS_TID tsk = rt_get_TID ();
  os_active_TCB[tsk-1] = task_context;
  task_context->task_id = tsk;
  DBG_TASK_NOTIFY(task_context, __TRUE);
  rt_dispatch (task_context);
  ptcb = (P_TCB)os_active_TCB[tsk - 1];
  *((uint32_t *)ptcb->tsk_stack + 13) = (uint32_t)osThreadExit;
  return ptcb;
}