0
HP-UX 11.31에서 실행되는 응용 프로그램에서 현재 스레드의 스택 크기를 가져 오려고합니다.HP-UX 11에서 현재 스레드의 스택 크기 가져 오기
Linux의 경우 pthread_getattr_np
을 사용하고 Solaris의 경우 thr_stksegment
을 사용할 수 있습니다. 나 스레드를 알 수있는 방법을 찾아주십시오
도움말 C.
HP-UX 11.31에서 실행되는 응용 프로그램에서 현재 스레드의 스택 크기를 가져 오려고합니다.HP-UX 11에서 현재 스레드의 스택 크기 가져 오기
Linux의 경우 pthread_getattr_np
을 사용하고 Solaris의 경우 thr_stksegment
을 사용할 수 있습니다. 나 스레드를 알 수있는 방법을 찾아주십시오
도움말 C.
에 내가 webkit sources에서이 문제에 대한 해결책을 발견하십시오 크기를 스택. 하지만이 솔루션은 응용 프로그램의 성능이 매우 중요하다면 스레드를 생성하고 일시 중단하는 것이 값 비싼 작업이므로 매우 중요합니다.
단어를 size
으로 바꿉니다. 웹킷 소스에서 크기가 아니라 스택베이스를 찾고 있기 때문입니다. 예제 코드 :
struct hpux_get_stack_size_data
{
pthread_t thread;
_pthread_stack_info info;
};
static void *hpux_get_stack_size_internal(void *d)
{
hpux_get_stack_base_data *data = static_cast<hpux_get_stack_size_data *>(d);
// _pthread_stack_info_np requires the target thread to be suspended
// in order to get information about it
pthread_suspend(data->thread);
// _pthread_stack_info_np returns an errno code in case of failure
// or zero on success
if (_pthread_stack_info_np(data->thread, &data->info)) {
// failed
return 0;
}
pthread_continue(data->thread);
return data;
}
static void *hpux_get_stack_size()
{
hpux_get_stack_size_data data;
data.thread = pthread_self();
// We cannot get the stack information for the current thread
// So we start a new thread to get that information and return it to us
pthread_t other;
pthread_create(&other, 0, hpux_get_stack_size_internal, &data);
void *result;
pthread_join(other, &result);
if (result)
return data.info.stk_stack_size;
return 0;
}
당신은 몇 가지 답변을 찾을 수 있습니다, 관련 특히 하나 ** libunwind는 **에서 [이 질문] (http://stackoverflow.com/questions/975108/stack-unwinding- on-hp-ux-and-linux) 도움이됩니다. – WhozCraig