Re: problem of stack size in st_thread_create()
John Newton <[email protected]> Wed, 10 Aug 2011 10:11:21 -0700
| Newsgroups | gmane.comp.lib.state-threads.user,gmane.comp.lib.state-threads.devel |
|---|---|
| Message-ID | <CAA7tSawaMkOGw97q1k4xHZs1t23fv1U-8xfp7juiRUwVoNsXEQ@mail.gmail.com> |
--===============0556716649714600214== Content-Type: multipart/alternative; boundary=000e0cd35a84faf68904aa29c460 --000e0cd35a84faf68904aa29c460 Content-Type: text/plain; charset=ISO-8859-1 The line you are asking about is a "round up" to the next page size calculation. For example, if getpagesize() returns 4096, and the "stk_size" parameter is 10,000 it would round up to the next even page size. (the division is doing integer math) Hope this helps! On Wed, Aug 10, 2011 at 9:06 AM, Alfred Zhong <[email protected]> wrote: > Hi, > I am new to state thread library and am reading the source code of ST to > study implementation of threading. > > in the st_thread_create() function > > there is this code piece > > if (stk_size == 0) > stk_size = ST_DEFAULT_STACK_SIZE; // I know this is to set the stack > size to a default size, if the input size is 0 > stk_size = ((stk_size + _ST_PAGE_SIZE - 1) / _ST_PAGE_SIZE) * > _ST_PAGE_SIZE; //what does this mean? > > Look like it equals (stk_size + ST_PAGE_SIZE -1) unless the previous > division gives 0. > > I am totally confused and can't find the answer in the code or the docs, > please help! > > Thanks a lot! > Alfred > > > ------------------------------------------------------------------------------ > uberSVN's rich system and user administration capabilities and model > configuration take the hassle out of deploying and managing Subversion and > the tools developers use with it. Learn more about uberSVN and get a free > download at: http://p.sf.net/sfu/wandisco-dev2dev > > _______________________________________________ > State-threads-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/state-threads-users > > --000e0cd35a84faf68904aa29c460 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable The line you are asking about is a "round up" to the next page si= ze calculation.<div><br></div><div>For example, if getpagesize() returns 40= 96, and the "stk_size" parameter is 10,000 it would round up to t= he next even page size. (the division is doing integer math)</div> <div><br></div><div>Hope this helps!</div><div><br><div class=3D"gmail_quot= e">On Wed, Aug 10, 2011 at 9:06 AM, Alfred Zhong <span dir=3D"ltr"><<a h= ref=3D"mailto:[email protected]">[email protected]</a>></span> wro= te:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex;"><span style=3D"font-family:arial, sans-seri= f;font-size:13px;background-color:rgb(255, 255, 255)">Hi,<div>I am new to s= tate thread library and am reading the source code of ST to study implement= ation of threading.=A0</div> <div><br></div><div>in the st_thread_create() function</div><div><br></div>= <div>there is this code piece</div><div><br></div><div><div>if (stk_size = =3D=3D 0)</div><div>=A0 =A0 stk_size =3D ST_DEFAULT_STACK_SIZE; =A0// I kno= w this is to set the stack size to a default size, if the input size is 0</= div> <div>=A0 stk_size =3D ((stk_size + _ST_PAGE_SIZE - 1) / _ST_PAGE_SIZE) * _S= T_PAGE_SIZE; //what does this mean?</div></div><div><br></div><div>Look lik= e it equals (stk_size + ST_PAGE_SIZE -1) unless the previous division gives= 0.</div> <div><br></div><div>I am totally confused and can't find the answer in = the code or the docs, please help!</div><div><br></div><div>Thanks a lot!</= div><div>Alfred</div></span> <br>-----------------------------------------------------------------------= -------<br> uberSVN's rich system and user administration capabilities and model<br= > configuration take the hassle out of deploying and managing Subversion and<= br> the tools developers use with it. Learn more about uberSVN and get a free<b= r> download at: =A0<a href=3D"http://p.sf.net/sfu/wandisco-dev2dev" target=3D"= _blank">http://p.sf.net/sfu/wandisco-dev2dev</a><br> <br>_______________________________________________<br> State-threads-users mailing list<br> <a href=3D"mailto:[email protected]">State-threads-= [email protected]</a><br> <a href=3D"https://lists.sourceforge.net/lists/listinfo/state-threads-users= " target=3D"_blank">https://lists.sourceforge.net/lists/listinfo/state-thre= ads-users</a><br> <br></blockquote></div><br></div> --000e0cd35a84faf68904aa29c460-- --===============0556716649714600214== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------------ uberSVN's rich system and user administration capabilities and model configuration take the hassle out of deploying and managing Subversion and the tools developers use with it. Learn more about uberSVN and get a free download at: http://p.sf.net/sfu/wandisco-dev2dev --===============0556716649714600214== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ State-threads-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/state-threads-users --===============0556716649714600214==--