线程堆栈指针 [英] thread stack pointer
本文介绍了线程堆栈指针的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Linux的2.6.32-32,是有办法找到编程在的pthreads
程序线程下列信息?我需要:运行计数,堆栈指针,堆栈开始/结束,堆栈大小,堆栈使用情况。喜欢的ThreadX的东西,我猜,但在程序中。谢谢你。
In Linux 2.6.32-32, is there a way to find the following information about a thread programmatically in a pthreads
program? I need: run count, stack pointer, stack start/end, stack size, stack usage. Something like ThreadX, I guess, but within a program. Thanks.
推荐答案
- pthread_getattr_np()应该给你一个线程的pthread的属性
- pthread_attr_getstack()回报栈地址和大小
- 我不知道你的运行计数的意思。
- 对于比你当前不同的线程的堆栈指针,你可能需要使用的 ptrace的。一旦你拥有它,你可以用它来确定多少堆栈是用来做数学。
- pthread_getattr_np() should give you the pthread attributes of a thread
- pthread_attr_getstack() returns the stack address and size
- I don't know what you mean by run count.
- For the stack pointer of a thread different than your current one you might need to use ptrace. Once you have it, you can use it to do the maths for determining how much of the stack is used.
为了获得自己的堆栈指针,你总是可以做线沿线的东西:
For obtaining your own stack pointer you can always do something along the lines of:
mword sp;
asm volatile ("mov %esp, $0" : "=r"(sp));
这篇关于线程堆栈指针的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文