我正在尝试将某些东西移植到 Linux。 我的原始代码(用于 RTOS)如下所示:
int stackSize = 4*1024;
void* stack = malloc(stackSize);
int thread = create_thread(stack, FuncToRun)
稍后,垃圾收集器会使用堆栈和堆栈大小来获取一些线程统计信息。
现在,如何将上述代码转换为 Linux?
最佳答案
你应该使用 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);
关于c++ - Linux - 获取线程堆栈内存的开始和结束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33121057/