From 591aacee97f4a6486631c38a6b418e20b2c4109c Mon Sep 17 00:00:00 2001 From: wangzhengquan <wangzhengquan85@126.com> Date: 星期四, 10 九月 2020 14:56:47 +0800 Subject: [PATCH] update --- test/test_io.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/test/test_io.c b/test/test_io.c index 2038497..6baa6f5 100644 --- a/test/test_io.c +++ b/test/test_io.c @@ -64,10 +64,12 @@ ifstream fin("stand.txt"); + int status, i = 0, processors = 4, scale = 100000; pid_t productors[processors], consumers[processors]; pid_t pid; + ofstream fouts[processors]; fout.open("stand.txt", ios_base::app); @@ -76,14 +78,15 @@ fout.close(); //read_from_file(fin); - fout.open("test.txt", ios_base::out | ios_base::app); + for ( i = 0; i < processors; i++) { if ((productors[i] = fork()) == 0) /* Child runs user job */ { + fouts[i].open("test.txt", ios_base::out | ios_base::app); int start = i * scale, end = i * scale + scale; printf("======start=%d, end=%d\n", start, end); - write_to_file(fout, start, end); + write_to_file(fouts[i], start, end); exit(0); } } -- Gitblit v1.8.0