I am trying to port something to Linux. My original code (for a RTOS) looks like:
int stackSize = 4*1024; void* stack = malloc(stackSize); int thread = create_thread(stack, FuncToRun)
Later the stack and stackSize are used by the garbage collector and to get some thread statistics.
Now, how do I convert the above code to Linux?
Advertisement
Answer
You should use Pthread:
int stackSize = 4*1024; pthread_attr_t atrib_thread; pthread_attr_init(&atrib_thread); pthread_attr_setstacksize(&atrib_thread,stackSize); pthread_t my_thread; pthread_create(&my_thread,&atrib_thread,FuncToRun,NULL);