Official mbed Real Time Operating System based on the RTX implementation of the CMSIS-RTOS API open standard.

Dependents:   denki-yohou_b TestY201 Network-RTOS NTPClient_HelloWorld ... more

Issue: Declare variables at beginning of block

After exporting code to uVision my program no longer compiled. One of the reasons for this was that rt_CMSIS.c does not declare it's variables first in function svcThreadCreate (osThreadDef_t *thread_def, void *argument); The beginning of the function should look like this...

rt_CMSIS.c

/// Create a thread and add it to Active Threads and set it to state READY
osThreadId svcThreadCreate (osThreadDef_t *thread_def, void *argument) {
  P_TCB  ptcb;
	U8 priority;
  P_TCB task_context;
	OS_TID tsk;
	
  if ((thread_def == NULL) ||
      (thread_def->pthread == NULL) ||
      (thread_def->tpriority < osPriorityIdle) ||
      (thread_def->tpriority > osPriorityRealtime) ||
      (thread_def->stacksize == 0) ||
      (thread_def->stack_pointer == NULL) ) {
    sysThreadError(osErrorParameter); 
    return NULL; 
  }
  
  priority = thread_def->tpriority - osPriorityIdle + 1;
  task_context = &thread_def->tcb;
  
  /* If "size != 0" use a private user provided stack. */
  task_context->stack      = (U32*)thread_def->stack_pointer;
  task_context->priv_stack = thread_def->stacksize;
  /* Pass parameter 'argv' to 'rt_init_context' */
  task_context->msg = argument;
  /* For 'size == 0' system allocates the user stack from the memory pool. */
  rt_init_context (task_context, priority, (FUNCP)thread_def->pthread);

  /* Find a free entry in 'os_active_TCB' table. */
  tsk = rt_get_TID ();