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?
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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.