pthread_create memory size
Hi Gilles,
I enlarged the stack size during thread creation to 256KB and reduced the memory usage by ~140MB , this is roughly explained by an 8MB stack per thread .So there is no memory problem . Your quick and helpful responses are much appreciated.
Yigal Goldberger.
Quoted 153 lines · Gilles Chanteperdrix
From: Gilles Chanteperdrix <[email protected]>
Subject: Re: [Xenomai-help]pthread_creatememory size
To: "Yigal Goldberger" <[email protected]>
Cc: "Xenomai help" <[email protected]>
Date: Wednesday, July 8, 2009, 11:26 AMQuoted 2 lines · Yigal Goldberger
Hi again,
I've performed the cat proc/pid/mapsOk, could you try
/proc/pid/smaps? It gives you the sizes. Anyway:Quoted 11 lines
I see a lot of libraries that were loaded . Can you assist me in understanding this output :
-bash-3.2# cat proc/1203/maps
uart_ioctl, cmd is802c7415
inset_termios
inchange_termios00100000-00103000 r-xp 00100000 00:00 0[vdso]
Quoted 1 line
0fa60000-0fb9c000 r-xp 00000000 00:0b 3577533
/lib/libc-2.6.soQuoted 1 line
0fb9c000-0fbdb000 ---p
0013c00000:0b 3577533
/lib/libc-2.6.soQuoted 1 line
0fbdb000-0fbdd000 r--p
0013b00000:0b 3577533
/lib/libc-2.6.soQuoted 1 line
0fbdd000-0fbe0000 rwxp
0013d00000:0b 3577533
/lib/libc-2.6.soQuoted 2 lines
0fbe0000-0fbe3000 rwxp
0fbe000000:00 0 0fbf3000-0fc06000 r-xp 00000000 00:0b 3577554
/lib/libgcc_s.so.1Quoted 1 line
0fc06000-0fc45000 ---p 00013000 00:0b 3577554
/lib/libgcc_s.so.1Quoted 1 line
0fc45000-0fc46000 rwxp 00012000 00:0b 3577554
/lib/libgcc_s.so.1Quoted 1 line
0fc56000-0fcf6000 r-xp 00000000 00:0b 3577583
/lib/libm-2.6.soQuoted 1 line
0fcf6000-0fd35000 ---p
000a000000:0b 3577583
/lib/libm-2.6.soQuoted 1 line
0fd35000-0fd36000 r--p
0009f00000:0b 3577583
/lib/libm-2.6.soQuoted 1 line
0fd36000-0fd39000 rwxp
000a000000:0b 3577583
/lib/libm-2.6.soQuoted 1 line
0fd49000-0fd4c000 r-xp 00000000 00:0b 3508708
/usr/xenomai/lib/librtdm.so.1.0Quoted 2 lines
.0
0fd4c000-0fd8b000 ---p 00003000 00:0b 3508708
/usr/xenomai/lib/librtdm.so.1.0Quoted 2 lines
.0
0fd8b000-0fd8c000 rwxp 00002000 00:0b 3508708
/usr/xenomai/lib/librtdm.so.1.0Quoted 2 lines
.0
0fd9c000-0fe8a000 r-xp 00000000 00:0b 3577648
/lib/libstdc++.so.6.0.9Quoted 1 line
0fe8a000-0fec9000 ---p
000ee00000:0b 3577648
/lib/libstdc++.so.6.0.9Quoted 1 line
0fec9000-0fecd000 r--p
000ed00000:0b 3577648
/lib/libstdc++.so.6.0.9Quoted 1 line
0fecd000-0fece000 rwxp
000f100000:0b 3577648
/lib/libstdc++.so.6.0.9Quoted 2 lines
0fece000-0fed5000 rwxp
0fece00000:00 0 0fee5000-0feec000 r-xp 00000000 00:0b 3577633
/lib/librt-2.6.soQuoted 1 line
0feec000-0ff2b000 ---p 00007000 00:0b 3577633
/lib/librt-2.6.soQuoted 1 line
0ff2b000-0ff2c000 r--p 00006000 00:0b 3577633
/lib/librt-2.6.soQuoted 1 line
0ff2c000-0ff2d000 rwxp 00007000 00:0b 3577633
/lib/librt-2.6.soQuoted 1 line
0ff3d000-0ff51000 r-xp 00000000 00:0b 3577623
/lib/libpthread-2.6.soQuoted 1 line
0ff51000-0ff91000 ---p 00014000 00:0b 3577623
/lib/libpthread-2.6.soQuoted 1 line
0ff91000-0ff92000 r--p 00014000 00:0b 3577623
/lib/libpthread-2.6.soQuoted 1 line
0ff92000-0ff93000 rwxp 00015000 00:0b 3577623
/lib/libpthread-2.6.soQuoted 2 lines
0ff93000-0ff95000 rwxp
0ff9300000:00 0 0ffa5000-0ffb0000 r-xp 00000000 00:0b 3509109
/usr/xenomai/lib/libpthread_rt.Quoted 2 lines
so.1.0.0
0ffb0000-0ffef000 ---p0000b00000:0b 3509109
/usr/xenomai/lib/libpthread_rt.Quoted 2 lines
so.1.0.0
0ffef000-0fff0000 rwxp0000a00000:0b 3509109
/usr/xenomai/lib/libpthread_rt.Quoted 2 lines
so.1.0.0
10000000-1003e000 r-xp 00000000 00:0b 3509108/802Rdr
Quoted 1 line
1007e000-1007f000 rwxp
0003e00000:0b 3509108/802Rdr
Quoted 2 lines
1007f000-10081000 rwxp
1007f00000:00 0 10081000-100eb000 rwxp 10081000 00:00 0[heap]
Quoted 1 line
48000000-4801d000 r-xp 00000000 00:0b 3577520
/lib/ld-2.6.soQuoted 3 lines
4801d000-4801e000 rw-p
4801d00000:00 0 4801e000-4801f000 rw-p4801e00000:00 0 4801f000-48020000 rw-s 10000000 00:0b 3506904
/dev/memQuoted 1 line
48020000-48021000 rw-s 00010000 00:0b 3506904
/dev/memQuoted 2 lines
48023000-48026000 rw-p 48023000 00:00 0 48026000-4802e000 rw-s 10010000 00:0b 3506904
/dev/memQuoted 1 line
4805c000-4805d000 r--p
0001c00000:0b 3577520
/lib/ld-2.6.soQuoted 1 line
4805d000-4805e000 rwxp
0001d00000:0b 3577520
/lib/ld-2.6.soQuoted 2 lines
4805e000-4805f000 ---p
4805e00000:00 0 4805f000-4885e000 rw-p4805f00000:00 0This is typically a thread stack: the page with only the 'p' flag is the
"guard page", which will cause a segmentation fault in case of stack
overflow. The other area is the stack, its size is 8 MB.Quoted 2 lines
4885e000-4885f000 ---p
4885e00000:00 0 4885f000-4905e000 rw-p4885f00000:00 08 MB
etc...
Quoted 1 line
4d85e000-4d85fuart_ioctl, cmd is
402c7413These
uart_ioctlare printks in one of your drivers probablyQuoted 1 line
bfe75000-bfe8a000 rw-p
bffeb00000:00 0[stack]
The main thread stack, strangely, is only 86K large (I believe it is
allocated on demand).Did you try to check
pthread_attr_setstacksizereturn value when calling it?Please do not forget to cc the mailing list.
Signature · 3 lines
Gilles
Quoted 6 lines · Yigal Goldberger
Hi Gilles,
I enlarged the stack size during thread creation to 256KB and reduced the memory usage by ~140MB , this is roughly explained by an 8MB stack per thread .So there is no memory problem . Your quick and helpful responses are much appreciated.
Ok. But to avoid doing this tuning blindly, you can use PTHREAD_STACK_MIN, and I believe checking pthread_attr_setstacksize return value should tell you if the stack size you try is accepted.
Signature · 1 line
Gilles.