![]() 2 cagarvin cagarvin 4096 Sep 16 00:09 Downloadsĭrwxr-xr-x. 2 cagarvin cagarvin 4096 Sep 16 00:09 Musicĭrwxr-xr-x. 2 cagarvin cagarvin 4096 Sep 16 00:09 Picturesĭrwxr-xr-x. 2 cagarvin cagarvin 4096 Sep 16 00:09 Publicĭrwxr-xr-x. ![]() 2 cagarvin cagarvin 4096 Sep 16 00:09 Templatesĭrwxr-xr-x. 2 cagarvin cagarvin 4096 Sep 16 00:09 Videosĭrwxr-xr-x. Interestingly, the program stopped perfectly fine for me, but the output did look strange (perhaps you had a similar situation and didn't realize the program stopped. That would be the better measure of how much processing time was spent on the parent and child processes. I think once you get the waitpid call in there, you want to call times twice in the parent, once right before you fork, and once after wait returns successfully. times() only returns how much time has been used from startup to when it's called. The parent process needs to call wait or waitpid to wait for the child to finish.Īs for why the times are zero, you call times() early on in the program. After the fork, the parent may be active and finish it's tasks and exit before the control switches to the child. Once you fork, you have no guarantee that the child will fully execute before control returns to the parent (at least, as you have it written). ![]() Until you do that, it will be very difficult to troubleshoot any problems with your pipe setup.Īlso, the order in which processes are scheduled by the OS is not to be relied upon. You need to check the return value and print an appropriate error message if any of the following calls fail. ![]() }May you please help me and tell me what i'm doing wrong? nbytes = read(fd, readbuffer, sizeof(readbuffer)) }I would be glad if someone could help me and tell what i'm doing wrong Unfortunately printfs return zero, but why? * Calculate times, unfortunately return zero, but why? */ĭouble cpu_time = end_tms.tms_cutime - t1 Printf("Received Time: %f\n\n\n",t1) //prints zero Printf("Received string: %s\n\n", readbuffer) Nbytes = read(fd, readbuffer, sizeof(readbuffer)) * Parent process closes up output side of pipe */ Write(fd,
0 Comments
Leave a Reply. |