@ -80,7 +80,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
printf("[ RUSAGE_CHILDREN ]\n");
|
||||
OKNG(cur_maxrss < 16 * 1024 || cur_maxrss > 32 * 1024,
|
||||
" maxrss: %d KB (+ %d KB) <- 子プロセス終了後に更新される",
|
||||
" maxrss: %d KB (+ %d KB) <- 子プロセス終了後に更新 (プロセス生成時の5~6M + mmapでの16M)",
|
||||
cur_maxrss, delta_maxrss);
|
||||
|
||||
prev_maxrss = cur_maxrss;
|
||||
|
||||
@ -12,12 +12,12 @@
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int rc;
|
||||
char *buf_child = NULL, *buf_mago = NULL;
|
||||
char *buf_child = NULL, *buf_grand_child = NULL;
|
||||
struct rusage cur_rusage;
|
||||
long cur_utime, cur_stime, cur_maxrss;
|
||||
long delta_utime, delta_stime, delta_maxrss;
|
||||
long prev_utime = 0, prev_stime = 0, prev_maxrss = 0;
|
||||
int pid, pid_mago, status, status_mago;
|
||||
int pid, pid_grand_child, status, status_grand_child;
|
||||
|
||||
printf("---- just started ----\n");
|
||||
/* check rusage 1st */
|
||||
@ -52,31 +52,31 @@ int main(int argc, char* argv[])
|
||||
CHKANDJUMP(pid == -1, "fork");
|
||||
|
||||
if (pid == 0) { /* child */
|
||||
printf(" ---- fork mago process ----\n");
|
||||
pid_mago = fork();
|
||||
CHKANDJUMP(pid_mago == -1, "fork mago");
|
||||
printf(" ---- fork grand_child process ----\n");
|
||||
pid_grand_child = fork();
|
||||
CHKANDJUMP(pid_grand_child == -1, "fork grand_child");
|
||||
|
||||
if (pid_mago == 0) /* mago */
|
||||
if (pid_grand_child == 0) /* grand_child */
|
||||
{
|
||||
/* add utime 1sec */
|
||||
printf(" ---- add utime 1sec in mago ----\n");
|
||||
printf(" ---- add utime 1sec in grand_child ----\n");
|
||||
add_utime(1);
|
||||
|
||||
/* add stime 1sec */
|
||||
printf(" ---- add stime 1sec in mago ----\n");
|
||||
printf(" ---- add stime 1sec in grand_child ----\n");
|
||||
add_stime(1);
|
||||
|
||||
/* mmap 32MB */
|
||||
printf(" ---- mmap and access 32MB (%d KB) in mago ----\n", 32 * 1024);
|
||||
buf_mago = mmap(0, 32 * M_BYTE, PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
|
||||
CHKANDJUMP(!buf_mago, "mmap");
|
||||
memset(buf_mago, 0xff, 32 * M_BYTE);
|
||||
printf(" ---- mmap and access 32MB (%d KB) in grand_child ----\n", 32 * 1024);
|
||||
buf_grand_child = mmap(0, 32 * M_BYTE, PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
|
||||
CHKANDJUMP(!buf_grand_child, "mmap");
|
||||
memset(buf_grand_child, 0xff, 32 * M_BYTE);
|
||||
|
||||
/* munmap 32MB */
|
||||
printf(" ---- munmap 32MB (%d KB) in mago ----\n", 32 * 1024);
|
||||
munmap(buf_mago, 16 * M_BYTE);
|
||||
printf(" ---- munmap 32MB (%d KB) in grand_child ----\n", 32 * 1024);
|
||||
munmap(buf_grand_child, 16 * M_BYTE);
|
||||
|
||||
printf(" ---- mago process exit ----\n");
|
||||
printf(" ---- grand_child process exit ----\n");
|
||||
_exit(234);
|
||||
}
|
||||
|
||||
@ -98,8 +98,8 @@ int main(int argc, char* argv[])
|
||||
printf(" ---- munmap 8MB (%d KB) in child ----\n", 8 * 1024);
|
||||
munmap(buf_child, 8 * M_BYTE);
|
||||
|
||||
printf(" ---- wait mago's exit ----\n");
|
||||
rc = waitpid(pid_mago, &status_mago, 0);
|
||||
printf(" ---- wait grand_child's exit ----\n");
|
||||
rc = waitpid(pid_grand_child, &status_grand_child, 0);
|
||||
CHKANDJUMP(rc == -1, "waitpid");
|
||||
|
||||
printf(" ---- child process exit ----\n");
|
||||
|
||||
@ -91,16 +91,16 @@ RESULT: you need check rusage value
|
||||
/home/satoken/ppos/bin/mcexec ./CT_001
|
||||
---- just started ----
|
||||
[ RUSAGE_SELF ]
|
||||
[OK] utime: 0.000528 s (+ 0.000528 s)
|
||||
[OK] stime: 0.010448 s (+ 0.010448 s)
|
||||
[OK] utime: 0.000529 s (+ 0.000529 s)
|
||||
[OK] stime: 0.024795 s (+ 0.024795 s)
|
||||
---- add utime 2sec ----
|
||||
[ RUSAGE_SELF ]
|
||||
[OK] utime: 1.997452 s (+ 1.996924 s)
|
||||
[OK] stime: 0.010633 s (+ 0.000185 s)
|
||||
[OK] utime: 1.997453 s (+ 1.996924 s)
|
||||
[OK] stime: 0.024974 s (+ 0.000179 s)
|
||||
---- add stime 1sec ----
|
||||
[ RUSAGE_SELF ]
|
||||
[OK] utime: 1.997459 s (+ 0.000007 s)
|
||||
[OK] stime: 1.009232 s (+ 0.998599 s)
|
||||
[OK] utime: 1.997461 s (+ 0.000008 s)
|
||||
[OK] stime: 1.023560 s (+ 0.998586 s)
|
||||
*** CT_001 PASS
|
||||
|
||||
/home/satoken/ppos/bin/mcexec ./CT_002
|
||||
@ -121,15 +121,15 @@ RESULT: you need check rusage value
|
||||
/home/satoken/ppos/bin/mcexec ./CT_003
|
||||
---- just started ----
|
||||
[ RUSAGE_SELF ]
|
||||
[OK] utime: 0.000530 s (+ 0.000530 s)
|
||||
[OK] stime: 0.010266 s (+ 0.010266 s)
|
||||
[OK] utime: 0.000531 s (+ 0.000531 s)
|
||||
[OK] stime: 0.009804 s (+ 0.009804 s)
|
||||
---- create thread and join ----
|
||||
---- add utime 2sec in sub thread ----
|
||||
---- add stime 1sec in sub thread ----
|
||||
---- sub thread exit ----
|
||||
[ RUSAGE_SELF ]
|
||||
[OK] utime: 1.997492 s (+ 1.996962 s) <- サブスレッド増分2秒
|
||||
[OK] stime: 4.005857 s (+ 3.995591 s) <- サブスレッド増分1秒 + メインスレッドjoin待ち3秒
|
||||
[OK] utime: 1.997496 s (+ 1.996965 s) <- サブスレッド増分2秒
|
||||
[OK] stime: 4.005407 s (+ 3.995603 s) <- サブスレッド増分1秒 + メインスレッドjoin待ち3秒
|
||||
*** CT_003 PASS
|
||||
|
||||
/home/satoken/ppos/bin/mcexec ./CT_004
|
||||
@ -147,8 +147,8 @@ RESULT: you need check rusage value
|
||||
/home/satoken/ppos/bin/mcexec ./CT_005
|
||||
---- just started ----
|
||||
[ RUSAGE_SELF ]
|
||||
[OK] utime: 0.000522 s (+ 0.000522 s)
|
||||
[OK] stime: 0.010163 s (+ 0.010163 s)
|
||||
[OK] utime: 0.000523 s (+ 0.000523 s)
|
||||
[OK] stime: 0.009879 s (+ 0.009879 s)
|
||||
[OK] maxrss: 6012 KB (+ 6012 KB)
|
||||
---- fork child process ----
|
||||
---- add utime 3sec in parent ----
|
||||
@ -159,8 +159,8 @@ RESULT: you need check rusage value
|
||||
---- child process exit ----
|
||||
---- wait child's exit ----
|
||||
[ RUSAGE_SELF ]
|
||||
[OK] utime: 2.995901 s (+ 2.995379 s)
|
||||
[OK] stime: 0.016541 s (+ 0.006378 s)
|
||||
[OK] utime: 2.995900 s (+ 2.995377 s)
|
||||
[OK] stime: 0.015519 s (+ 0.005640 s)
|
||||
[OK] maxrss: 6084 KB (+ 72 KB)
|
||||
*** CT_005 PASS
|
||||
|
||||
@ -179,8 +179,8 @@ RESULT: you need check rusage value
|
||||
---- add stime 1sec in child ----
|
||||
---- child process exit ----
|
||||
[ RUSAGE_CHILDREN ]
|
||||
[OK] utime: 1.996946 s (+ 1.996946 s)
|
||||
[OK] stime: 0.998663 s (+ 0.998663 s)
|
||||
[OK] utime: 1.996949 s (+ 1.996949 s)
|
||||
[OK] stime: 0.998664 s (+ 0.998664 s)
|
||||
*** CT_006 PASS
|
||||
|
||||
/home/satoken/ppos/bin/mcexec ./CT_007
|
||||
@ -196,7 +196,7 @@ RESULT: you need check rusage value
|
||||
---- munmap 16MB (16384 KB) in child ----
|
||||
---- child process exit ----
|
||||
[ RUSAGE_CHILDREN ]
|
||||
[OK] maxrss: 21516 KB (+ 21516 KB) <- 子プロセス終了後に更新される
|
||||
[OK] maxrss: 21516 KB (+ 21516 KB) <- 子プロセス終了後に更新 (プロセス生成時の5~6M + mmapでの16M)
|
||||
*** CT_007 PASS
|
||||
|
||||
/home/satoken/ppos/bin/mcexec ./CT_008
|
||||
@ -207,42 +207,42 @@ RESULT: you need check rusage value
|
||||
[OK] maxrss: 0 KB (+ 0 KB)
|
||||
---- fork child process ----
|
||||
---- wait child's exit ----
|
||||
---- fork mago process ----
|
||||
---- fork grand_child process ----
|
||||
---- add utime 2sec in child ----
|
||||
---- add utime 1sec in mago ----
|
||||
---- add stime 1sec in mago ----
|
||||
---- add utime 1sec in grand_child ----
|
||||
---- add stime 1sec in grand_child ----
|
||||
---- add stime 1sec in child ----
|
||||
---- mmap and access 32MB (32768 KB) in mago ----
|
||||
---- munmap 32MB (32768 KB) in mago ----
|
||||
---- mago process exit ----
|
||||
---- mmap and access 32MB (32768 KB) in grand_child ----
|
||||
---- munmap 32MB (32768 KB) in grand_child ----
|
||||
---- grand_child process exit ----
|
||||
---- mmap and access 8MB (8192 KB) in child ----
|
||||
---- munmap 8MB (8192 KB) in child ----
|
||||
---- wait mago's exit ----
|
||||
---- wait grand_child's exit ----
|
||||
---- child process exit ----
|
||||
[ RUSAGE_CHILDREN ]
|
||||
[OK] utime: 2.999763 s (+ 2.999763 s) <- 子プロセス2秒、孫プロセス1秒の和
|
||||
[OK] stime: 2.009389 s (+ 2.009389 s) <- 子プロセス1秒、孫プロセス1秒の和
|
||||
[OK] utime: 2.999773 s (+ 2.999773 s) <- 子プロセス2秒、孫プロセス1秒の和
|
||||
[OK] stime: 2.009370 s (+ 2.009370 s) <- 子プロセス1秒、孫プロセス1秒の和
|
||||
[OK] maxrss: 37896 KB (+ 37896 KB) <- 子、孫のmaxrssの最大値
|
||||
*** CT_008 PASS
|
||||
|
||||
/home/satoken/ppos/bin/mcexec ./CT_009
|
||||
---- just started ----
|
||||
[OK] utime: 0.000535 s (+ 0.000535 s)
|
||||
[OK] stime: 0.009965 s (+ 0.009965 s)
|
||||
[OK] utime: 0.000533 s (+ 0.000533 s)
|
||||
[OK] stime: 0.009959 s (+ 0.009959 s)
|
||||
---- add utime 1sec in main thread ----
|
||||
---- create thread and join ----
|
||||
[ RUSAGE_THREAD ]
|
||||
[OK] utime: 0.000005 s (+ 0.000005 s)
|
||||
[OK] stime: 0.000014 s (+ 0.000014 s)
|
||||
[OK] stime: 0.000013 s (+ 0.000013 s)
|
||||
---- add utime 2sec in sub thread ----
|
||||
---- add stime 1sec in sub thread ----
|
||||
[ RUSAGE_THREAD ]
|
||||
[OK] utime: 1.996925 s (+ 1.996925 s)
|
||||
[OK] stime: 0.998649 s (+ 0.998649 s)
|
||||
[OK] utime: 1.996928 s (+ 1.996928 s)
|
||||
[OK] stime: 0.998632 s (+ 0.998632 s)
|
||||
---- sub thread exit ----
|
||||
[ RUSAGE_THREAD ]
|
||||
[OK] utime: 0.999027 s (+ 0.998492 s)
|
||||
[OK] stime: 3.006955 s (+ 2.996990 s) <- join待ち3秒
|
||||
[OK] utime: 0.999024 s (+ 0.998491 s)
|
||||
[OK] stime: 3.006973 s (+ 2.997014 s) <- join待ち3秒
|
||||
*** CT_009 PASS
|
||||
|
||||
/home/satoken/ppos/bin/mcexec ./CT_010
|
||||
|
||||
Reference in New Issue
Block a user