Tool/software: TI-RTOS
HI i'm trying to use multithread in CCS, but i can't find how do i do.
#include <ti/sysbios/posix/pthread.h>
#include <stdlib.h>
#include <xdc/std.h>
#include <xdc/runtime/System.h>
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
/* Drivers */
#include <ti/drivers/rf/RF.h>
#include <ti/drivers/PIN.h>
/* Board Header files */
#include "Board.h"
#include "smartrf_settings/smartrf_settings.h"
#include <xdc/std.h>
#include <ti/sysbios/knl/Clock.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/posix/unistd.h>
#include <ti/sysbios/posix/Settings.h>
#include <ti/sysbios/posix/types.h>
static Task_Params taskParams;
static pthread_attr_t *pAttr;
/* This is our thread function. It is like main(), but for a thread*/
void *threadFunc(void *arg)
{
char *str;
int i = 0;
str=(char*)arg;
while(i < 10)
{
usleep(1000*1000);
System_printf("threadFunc says: %s\n",str);
i++;
}
return 0;
}
int main(void)
{
pthread_t pth; // this is our thread identifier
int i = 0;
Task_Params_init(&taskParams);
taskParams.priority = pAttr->priority;
taskParams.stack = pAttr->stack;
taskParams.stackSize = pAttr->stacksize + pAttr->guardsize;
pthread_create(&pth,NULL,threadFunc,"foo");
while(i < 10)
{
usleep(1000*1000);
System_printf("main is running...\n");
i++;
}
System_printf("main waiting for thread to terminate...\n");
pthread_join(pth,NULL);
BIOS_start();
return 0;
}
this is my main code
and it doesn't work
how can i do?
if you know how can i fix the code, let me know plz :-)