From: Alfred Z. <alf...@gm...> - 2011-08-10 17:33:05
|
Oh my god! + _ST_PAGE_SIZE - 1 if stk_size is just x times of the _ST_PAGE_SIZE, the integer division will return exactly x b/c of the -1. if stk_size is smaller than x times of _ST_PAGE_SIZE, the integer division will return exactly x, and ignore the remaining >x but <x+1 That is smart! If the purpose is in the comment or docs will be better to understand Thanks a lot, John! Alfred On Wed, Aug 10, 2011 at 1:11 PM, John Newton <jn...@gm...> wrote: > 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 <alf...@gm...>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 >> Sta...@li... >> https://lists.sourceforge.net/lists/listinfo/state-threads-users >> >> > |