| | |
| | | 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); |
| | | |
| | |
| | | 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); |
| | | } |
| | | } |