线程堆栈指针 [英] thread stack pointer

查看:206
本文介绍了线程堆栈指针的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在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() 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆