c++ - Linux - 获取线程堆栈内存的开始和结束

标签 c++ linux multithreading

我正在尝试将某些东西移植到 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);

http://www.manpagez.com/man/3/pthread_attr/

http://www.manpagez.com/man/3/pthread_create/

关于c++ - Linux - 获取线程堆栈内存的开始和结束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33121057/

相关文章:

c++ - 在哪里可以找到 current 在 Mac 上使用 GCC 编译器的版本?

c++ - 使用 AlphaBlend 绘制略透明的矩形失败

linux - 使用 sed,我想替换文件中的字符串值

c# - new Task 总是在 ThreadPool 线程上执行吗?

vb.net - SyncLock 在单元测试中不起作用

multithreading - C#IE BHO : Do work asynchroniously while keeping to the same thread?

左值和右值的 C++ 运算符重载 [ ]

c++ - 用 Armadillo 加载大型矩阵

linux - 如何制作一个脚本来运行另一个脚本

linux - Bash linux 强制多个实例等待运行 sqlplus 命令完成