at 54:46, as the solution suggests that wordcount-esque are implemented in a way that they will take complete input before processing. What if they are in the middle of cascading (sort | wc | somefunc), if the pipe is filled before wc is initialized, then it will never complete its process?
Thanks a lot for these amazingly structured lessons professor! I had a question though, at 43:17, how are you very sure that the parent process will execute first? (you are reading in the child only after writing, so it has to be the case that you assumed here the parent will execute first).
parent process will execute only when the 'if' condition holds true (i.e. pid > 0 ) ... so it could be any of the two depending on the 'pid' and bc we've already forked it ; and the 'fd table' is duplicated and input and output is connected through pipe; we can inter-communicate between diff processes
@@miraatifrafiq yes, but that was exactly my question. If the child process executes, then the "else" condition will make the child process read the data which is not yet written by the parent. So it has to be the case that the prof. assumed the parent will have executed first. Or maybe, even if the child executes first, there is nothing to read from the pipe and hence the OS will ensure that someone has to fill the pipe before reading is what I'm assuming.
In the if else structure after fork 15:41, fork will return a pid which will randomly be either the child's pid or 0 ? which means other call might never happen ? For example, if pid is 0 child block's logic might get executed and wait() might never get executed ?
When we invoke `fork()` we get a return value of type `pid_t`, we can use this to refer to the process ID (PID) of the child to investigate. So, we pass this `pid_t` from `fork` to `wait(RETURNED_PID)` and the return value of wait() in this case corusponds to the return ID of the child processe's PID that we got from `fork()`. Since in this case, we're only creating one children at a time-meaning not multiple fork calls-we just pass `0` as an argument to wait() since its gonna be default.
get out of this channel idiot, I don't know from which place you people who have 0 CS knowledge come and blame the teacher. His teaching is absolutely amazing. You don't come to this channel after watching a python playlist.