[riot-users] Thread Yielding problem

Burak Karaduman bburakkaraduman at gmail.com
Thu Jul 25 16:41:37 CEST 2019


I have the following simple problem. I am trying to auto initialize and run
these threads. Even they can work one by one periodically. However, i am
even if i am trying to switch to ccc thread from rcv thread using
sched_run() or thread_yield(); it never runs the ccc thread. I tried to
thread_sleep, but it is just another overhead and overload to run multiple
threads  sequentially.

Where am i wrong ? Thanks for your help.





#include "thread.h"
#include "stdio.h"
#include "msg.h"
char rcv_thread_stack[THREAD_STACKSIZE_MAIN];
char ccc_thread_stack[THREAD_STACKSIZE_MAIN];

void *rcv_thread(void *arg)
{
thread_yield();
    (void) arg;
  //  msg_t m;
    while (1) {
       printf("!!!!!!!!!!");
  -> // sched_run() or thread_yield();

    }
    return NULL;
}
void *ccc_thread(void *arg)
{
    (void) arg;
  //  msg_t m;
    while (1) {
       printf("*******************");
    }
    return NULL;
}
int main(void)
{
    thread_create(rcv_thread_stack, sizeof(rcv_thread_stack),
                  THREAD_PRIORITY_MAIN - 1, THREAD_CREATE_STACKTEST,
                  rcv_thread, NULL, "rcv_thread");


    thread_create(ccc_thread_stack, sizeof(ccc_thread_stack),
                  THREAD_PRIORITY_MAIN - 1, THREAD_CREATE_STACKTEST,
                  ccc_thread, NULL, "ccc_thread");

while(1){
printf("****");
}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/users/attachments/20190725/92de9494/attachment.htm>


More information about the users mailing list