Skip to content

feature_cmsis5 and osThreadNew problem #4024

@gerhil

Description

@gerhil

Description

  • Type: Bug (perhaps) / Question
  • Priority: Major

Bug

Target
K64F

Toolchain:
GCC_ARM

Toolchain version:
6.3.1

mbed-cli version:
1.0


Question

Hello. I am using the "feature_cmsis5" branch because it has improved thread support. But I am having trouble starting threads.

The following example suppose to spawns runMethod(). For some reason, the osThreadNew() method fails and returns NULL. I have tried two different forms (example 1 and example 2) without success. See code below.

#include <cmsis_os2.h>

#define example 1

void runMethod(void *parameter) {
      printf("runMethod\r\n");
}

int main() {

#if example == 1
    os_thread_t cb_thread;
    memset(&cb_thread, 0, sizeof(cb_thread));
    osThreadAttr_t thread_attr;
    memset(&thread_attr, 0, sizeof(thread_attr));
    thread_attr.name = "thread";
    thread_attr.stack_mem = new uint8_t[100];
    thread_attr.stack_size = 100;
    thread_attr.priority = osPriorityNormal;
    thread_attr.cb_mem = &cb_thread;
    thread_attr.cb_size = sizeof(os_thread_t);
    osThreadId_t id = osThreadNew((osThreadFunc_t)runMethod, NULL, &thread_attr);
#endif

#if example == 2
    osThreadId_t id = osThreadNew((osThreadFunc_t)runMethod, NULL, NULL);
#endif

    if (id == NULL) {
        printf("Thread not created!\r\n");
    }
   return 0;
}

The result is the output "Thread not created!". Any suggestion what may go wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions