Dec 2

Linux: default stack size of pthread 不指定

felix021 @ 2010-12-2 17:19 [IT » 操作系统] 评论(0) , 引用(0) , 阅读(5293) | Via 本站原创 | |
Ubuntu Server 10.04 x86和x86_64下是8MB,RHEL4 x86下是10MB。开线程的开销真大。
#include <pthread.h>
#include <stdio.h>

void *thread(void *arg)
{
    size_t stacksize;
    pthread_attr_t attr;
    pthread_attr_init(&attr);
    pthread_attr_getstacksize (&attr, &stacksize);
    printf("Default stack size = %lu KB\n", stacksize / 1024);
}

int main(int argc, char *argv[])
{
    void *x;
    pthread_t t;
    pthread_create(&t, NULL, thread, NULL);
    pthread_join(t, &x);
    return 0;
}




欢迎扫码关注:




转载请注明出自 ,如是转载文则注明原出处,谢谢:)
RSS订阅地址: https://www.felix021.com/blog/feed.php
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   *非必须
网址   电邮   [注册]