The fact that these videos comes with a great knowledge delivered in the most golden way possible and I still end up gaining even more from the replies to comments and questions below.... man your a kind hero.., Thank you!!.
@kerryhuang695310 ай бұрын
Thank you! I was 6 hours in and wondering why my code doesn't work. Followed your tutorial and it immediately solved my problem.
@hectordoyle47184 жыл бұрын
great topic - it's really helpful!
@lucas90gs2 жыл бұрын
Thanks for the videos! A couple of things that are not so clear to me: 1. When working with pipes, is it guaranteed that the first read on the parent process is going to happen after the first write on the child process, and in turn the second read on the parent process will happen after the second write of the child process? 2. In this specific program, is adding a wait(null) after the parent first read a good practice, as we know that the child has only one more write to do before finishing its scope, or is it expandable?
@CodeVault2 жыл бұрын
1) Read operations on pipes wait for something to exist in the buffer. So, if the read operation executes first it will wait until something is written to that pipe. Same thing with the write function if there's no space in the pipe's buffer. 2) You could, but then you can only use the pipe (and the whole child process) only once
@ozziekhoo4 жыл бұрын
Hi Sir, what would be the difference of doing wait(NULL) at the beginning of the parent process, instead of at the end?
@raimo791111 ай бұрын
not much difference, but you wouldn't be taking advantage of parallelism of processes. but again, in this case it's the same because read is going to be on hold until something is written to the write end of the pipe
@ayoubmentag98832 жыл бұрын
Amazing video , thank you :)
@navidnouri1513 жыл бұрын
Thank you!
@RaviSankar-ln3ki3 жыл бұрын
Nice one. Thank you.
@zyghom2 жыл бұрын
ha, "always send first the number of elements in array" - that is what I got from your another video already but here you explicitly said the same - amazing! Question: would pipes work also on embedded systems, i.e. ESP32? I know at the beginning you said: "this is for Linux" but I could find an usage for pipes on microcontroller as well. thx Another point: finally I understood why it is so important that array is always "a contiguous block of bytes" - write(fd,arr,n) or read(fd,arr,n) would not work in here if the array was fragmented ;)
@CodeVault2 жыл бұрын
Hmm, for embedded it might be different since it doesn't have a notion of processes, it's usually just one big process for the whole thing
@massinissamellikeche685921 күн бұрын
I tried to send a matrix from a server to a client with read and write but the client only prints the first line of the matrix, do you have any idea why this happens ?
@venkatesh47604 жыл бұрын
@CodeVault Great explanation .. I watch all ur videos..please make your codes in videos available anywhere like Github.
@CodeVault4 жыл бұрын
Will do in the near future!
@vladimir_khlghatyan2 жыл бұрын
@@CodeVault Have you already done?
@sudhansujena53232 жыл бұрын
How is it possible for fork() to return two values?
@CodeVault2 жыл бұрын
It doesn't return two values. It creates a separate copy of the existing process and simply returns different values based on which process it returns to
@utksingh73 жыл бұрын
does read() know to read from after , what has already been read (here n) ?
@CodeVault3 жыл бұрын
Yes. read() waits for data to be written to the pipe
@utksingh73 жыл бұрын
@@CodeVault thanks for replying, i mean why doesn't read() read from the start of the pipe/file on every call? if we are reading a file and we call read (100 bytes) 2 times then on the first call first 100 bytes will be read and on the second the next 100. How does it know to start reading after the first 100 bytes on the second call?
@CodeVault3 жыл бұрын
Ahhh, the file descriptor has something called a cursor that remembers where it last finished reading. You can change that with: linux.die.net/man/2/lseek
@utksingh73 жыл бұрын
@@CodeVault Okay, I get it now. Thanks a lot
@anujajadhav95324 жыл бұрын
Sir, how to pass an two integer value for though pipe without rand function and how to calculate the sum of that is integer
@CodeVault4 жыл бұрын
You can simply call write twice for those 2 integers you want to pass and read 2 times in the receiving process
@franklinordonez72432 жыл бұрын
Hi your videos are saving my ass on OS class! I have a question, how do you send an array of structs? I'm trying to do it but sometimes the reader gets incorrect and crazy values, sometimes it reads the values fine. I do not know what is the cause of this problem. :(
@CodeVault2 жыл бұрын
Make sure you're passing the sizeof(struct) to the read/write operations
@dragosmarinescu93888 ай бұрын
are you romanian?
@CodeVault8 ай бұрын
Da
@asifsaad58274 жыл бұрын
and why did you close the write end in parents process?
@CodeVault4 жыл бұрын
Because the parent process never writes anything on the pipe and pipes are unidirectional.
@asifsaad58274 жыл бұрын
why are you not doing your program in cpp?
@CodeVault4 жыл бұрын
Well, that's because all the functions we're using in this course are from unix C libraries. So, if people wanted to use C++ for their projects, the same code would work for both.
@asifsaad58274 жыл бұрын
@@CodeVault would you mind doing a video on Unix C libraries?
@CodeVault4 жыл бұрын
I'll look into it
@paulosantana96073 жыл бұрын
I'm studying at 42 and pretty glad that he's doing all of these explanations in C xD
@theflyingdutchman39423 жыл бұрын
@@paulosantana9607 I feel you brother, just started on minishell :D
@prasannapm32202 жыл бұрын
how to read and write to a pipe..... when the date to be written to a pipe is from a filename.txt ? // copy the contents from the filename.txt to the pipe write(fd[1], &filename.txt, sizeof(char)) ?
@CodeVault2 жыл бұрын
You'd have to probably read/write a string that represents the date in the pipe. There is this video on the topic: code-vault.net/lesson/81boknswet:1603732432887