On 02/06/2012 05:18 PM, Shang Yanfeng wrote: > many low memory boards don't have 1G memory,so add get_free_mem function for > low memory target, > limit 3000M for 64bit kernel with n32 file system.
Can you explain that why limit 3000M for 64bit? and the n32 file system, can you give a example? You means the file system may failure with the not limited memory? a bit comment below: > > Signed-off-by: Shang Yanfeng <[email protected]> > --- > testcases/kernel/mem/mtest06/mmap2.c | 50 ++++++++++++++++++++++++++------- > 1 files changed, 39 insertions(+), 11 deletions(-) > > diff --git a/testcases/kernel/mem/mtest06/mmap2.c > b/testcases/kernel/mem/mtest06/mmap2.c > index 6d56a54..f9b7ccd 100644 > --- a/testcases/kernel/mem/mtest06/mmap2.c > +++ b/testcases/kernel/mem/mtest06/mmap2.c > @@ -68,13 +68,14 @@ > #include <signal.h> > #include <sys/time.h> > #include <sys/wait.h> > +#include <sys/sysinfo.h> > #include <signal.h> > #include <string.h> > #include <getopt.h> > #include "test.h" > #include "usctest.h" > > -#define GB 1000000000 > +#define MB 1048576 I wonder that why did the author definite the GB like this? > #ifndef TRUE > #define TRUE 1 > #endif > @@ -100,7 +101,7 @@ static int mkfile(int size) > fprintf(stdout, "creating tmp file and writing 'a' to it "); > } > > - while (index < (size * GB)) { > + while (index < (size * MB)) { > index += 4096; > if (write(fd, buff, 4096) == -1) { > perror("mkfile(): write()"); > @@ -128,6 +129,17 @@ static void sig_handler(int signal) > exit(0); > } > > + > +unsigned long get_free_mem() This may be *static* if no one else use this. > +{ > + struct sysinfo board_sysinfo; > + unsigned long avail_mem; > + if (sysinfo(&board_sysinfo)) > + perror("sysinfo failed\n"); > + avail_mem = board_sysinfo.freeram/MB; > + return avail_mem; > +} > + > static void usage(char *progname) > { > fprintf(stderr, > @@ -137,7 +149,7 @@ static void usage(char *progname) > "\t -p set map_flag to MAP_PRIVATE.\tdefault:" > "MAP_SHARED\n" > "\t -s size of the file/memory to be mmaped.\tdefault:" > - "1GB\n" > + "1000MB\n" Now, the 1000MB not equal the origin 1GB, what did you think about this? Thanks -Wanlong Gao ------------------------------------------------------------------------------ Keep Your Developer Skills Current with LearnDevNow! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-d2d _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
