Thanks for creating this content, it really helped me in my OS class.
@rahulmaddula57763 жыл бұрын
No other channel can match the quality of your videos. Hands down the best.
@ash__borne2 жыл бұрын
Thank you for making such incredible videos. You're helping a lot of people. You're too underrated !
@hectordoyle47184 жыл бұрын
you're keep on makin' exactly what I am interested in - thank you! it may be quite a hardcore request, but how about a series about a small system programming project that will clip stuff from some of your other great videos together? (maybe a shell-like program, vim-like editor or a terminal function remake)
@CodeVault4 жыл бұрын
Nice suggestion! I have something similar in mind. Currently the website for CodeVault is in the works and I was thinking about making a devlog series about how I take certain implementation decisions for it. Another project would be related to computer graphics and implementing your own game engine (but, again, just a devlog series not full blown detailed tutorials). What do you think?
@hectordoyle47184 жыл бұрын
@@CodeVault I considered game engine a dream hahah that would be best thing possible!
@millicentmalinga9624 жыл бұрын
Even a simple C shell
@aniruddharora40042 жыл бұрын
@@CodeVault do a podcast, i'd be interested.
@haomintian68153 жыл бұрын
Great video content! But I am confused by why kill(pid, SIGKILL); under parent process. Since the pid is the parent process ID, does it actually terminate the parent process instead of children process? Would you mind explain? Thanks
@CodeVault3 жыл бұрын
Nonono, pid is the child's process ID. It's what fork() returns in the parent process. So we're sending sigkill to the child process
@pawcherry88072 жыл бұрын
@@CodeVault I have the same confusion. Since we are in the parent process doesnt pid have the ID of the current procces we are in(the parent process)? If we were in the child process shouldnt it only then contain the childs ID? Thanks for the content it helped me a lot so far!
@CodeVault2 жыл бұрын
@@pawcherry8807 No, the pid variable stores what fork() returns. And fork doesn't return the current process id. If you want to get the current process id you can simply use getpid() for that. fork() returns 0 in the child process so that you can distinguish between the child and the parent process. If it were to work the way you're explaining then this is what would happen: int pid = fork(); // parent process id is 1001, which means pid is 1001 in the parent process // child process id is 1002, which means pid is 1002 in the child process How do we check here which is which? We could try: if (pid == 1001) { // parent process } else if (pid == 1002) { // child process } That works, BUT, the problem is that the process IDs are dynamic and relies on what other current processes are running on the system. So... maybe the next time you run the program you would get the parent process id to be 1201 and the child process id to be 903. Now... what do we do? The code above no longer works and we cannot (easily) distinguish between the child and parent process
@pawcherry88072 жыл бұрын
@@CodeVault Ah i see. I had the return value confused... Thank you!
@dennisjoseph45282 жыл бұрын
Thanks for asking this question. I was thinking about this as well
@starthustling32903 жыл бұрын
OS students are grateful. Love from Poland
@antoineloiseau78112 жыл бұрын
Hi, I have a small suggestion to make here. We hear a lot of desk noises on the lowest frequencies, you should try to put a high pass filter on your microphone (you should be able to do that from your audio interface, if not I'd be glad to help you find out how to do it) Great contents by the way, very usefull, you helped me to understand many concepts during my cursus, thank you !
@CodeVault2 жыл бұрын
I'm sorry about that. I noticed that issue in the past and the later videos (namely the thread course) should have this issue anymore. If it's not yet fixed I will continue looking into it
@Justin-nf6tw2 жыл бұрын
I love you dude you really helped me a lot
@sxx24912 жыл бұрын
nice and useful contents, helped me a lot, hope to see more😀
@jorgealves69442 жыл бұрын
Good evennig! At minute 3:49. When you called the kill(pid, SIGKILL) function, was the process that died the child because the parent was on hold? Is this how KILL identified the pid of the child process?
@CodeVault2 жыл бұрын
pid was returned by fork(), the kill() function is executed in the parent process and pid is the process id of the child process. That's how it knows which process it should send the signal to
@Anduuu0772 ай бұрын
very good video adn explanation
@rajatsharma24293 жыл бұрын
If i run the same code on my PC and send CTRL + C on STDOUT, both parent and child are getting terminated, which is in contrast to your observation at 2:20 in this video, where sending CTRL + C only terminates the parent. Is it something machine specific? I am using MACOS terminal. In general if multiple processes are point to same STDOUT, if signal specific commands such as CTRL + C are sent to STDOUT, will OS send same INT to all the processes pointing to same STDOUT, it seems like this in my setup. Last but not the least, super content, much appreciated!
@CodeVault3 жыл бұрын
Interesting.The behavior could be platform specific. I'm not sure if it has to do with STDOUT or the terminal itself is doing some extra logic behind the scenes
@martinhuang34692 жыл бұрын
Same here on My M1 Mac
@VultureGamerPL3 жыл бұрын
Clearn and concise. Thanks
@michelemassa30292 жыл бұрын
saved my day dude, thanks
@joseluisdominguezplaza6839 Жыл бұрын
What program are you using?
@CodeVault Жыл бұрын
If you mean the IDE, I'm using Visual Studio Code
@yesnt19182 жыл бұрын
you are best and more thing you are the bestestest
@abbadkamel88394 жыл бұрын
thankk you soo much you helped a lot you explain very simple and easy way
@suneelabbigari2 жыл бұрын
Hi @Codevault Requested earlier as well, Please do a video on Timer module (timer init, timer set up) and different kinds of processes like daemon, init and sample programs in that. Please do a video on that.
@altoma35624 жыл бұрын
What program do you use for codding? Thanks
@CodeVault4 жыл бұрын
Visual Studio Code. Here's a video on how you can set it up (although you need to be on Unix/Linux if you want to use the functions in this video). kzbin.info/www/bejne/hGaqmYlugJ13f8U
@ib16644 жыл бұрын
Nice, Thanks. How about some threads, mutex, or semaphores
@CodeVault4 жыл бұрын
They are planned. First, we'll finish with the Linux specifics related to processes and then I'll release some videos on multi-threading.
@m.preacher28292 жыл бұрын
can i think that signal is just like an interrupt?
@CodeVault2 жыл бұрын
To some degree they are similar. This post explains the difference pretty well: stackoverflow.com/questions/13341870/signals-and-interrupts-a-comparison
@sudchmo7447 ай бұрын
Is the function 'wait()' nessecerry after 'kill()' function, If so why do we need 'wait() function' ?
@CodeVault7 ай бұрын
wait() also clears the resources left by the child process (if any)
@sakkamouid3343 Жыл бұрын
is it possible to call the function kill() from the child process so that the parent process is the one to be killed . I tried it and the whole program seems to be stopped.
@CodeVault Жыл бұрын
The child process shouldn't stop its execution even if you stop the parent process. After calling kill() try adding a sleep and some printf call in the child process. You should still see that message even after stopping the parent process
@alanmenescal34872 жыл бұрын
Veery good content
@lit7961 Жыл бұрын
Helpfull content, thanks
@mikelgarciarodriguez69613 жыл бұрын
Does the created process with fork run in parallel? i mean, the child and the father process?
@CodeVault3 жыл бұрын
Yes
@mikelgarciarodriguez69613 жыл бұрын
@@CodeVault how can i check this out by myself? im trying to make a programa and i want to see how this works. But i dont know how to see how processes works
@ruoyuanluo68963 жыл бұрын
What happens if a signal handler gets invoked when it’s already handling a signal for that same signal/handler? For example, what happens when a process receives a signal for SIGUSR1 when it’s already handling SIGUSR1?
@CodeVault3 жыл бұрын
They are executed in parallel multiple times
@ruoyuanluo68963 жыл бұрын
@@CodeVault Thanks! I am also wondering what happens if a signal handler gets invoked if the process is already handling a different signal? For example, what happens when a process receives a signal for SIGUSR2 when it’s busy handling SIGUSR1?
@CodeVault3 жыл бұрын
From my experience, they are handled in parallel as well. This is the reason I/O functions shouldn't really be used here, because it could cause issues when called in parallel.
@ruoyuanluo68963 жыл бұрын
@@CodeVault Thanks a lot! much appreciated
@georgioziozas90314 жыл бұрын
if we have multiple forks() so multiple processes , how are we gonna pass the correct pid in the kill function ?
@CodeVault4 жыл бұрын
If you properly retain the return values of fork() you can refer back to the child processes using it
@georgioziozas90314 жыл бұрын
@@CodeVault assigning an int variable at each fork call and play with if statements you mean?
@CodeVault4 жыл бұрын
Yes
@anuragupadhyay3193 жыл бұрын
Good content
@andreamartinez-xy8dm3 жыл бұрын
when it gets stuck does that mean it will create deadlock?
@CodeVault3 жыл бұрын
No, a deadlock is created when two processes or threads are waiting for each other. Usually that happens with mutexes
@TuMadre80003 жыл бұрын
amazing. thanks
@jaibalajt8333 жыл бұрын
can child kill the parent process by using getppid()?
@CodeVault3 жыл бұрын
You can, yes. But that would make the current process a zombie process.
@ORagnar3 жыл бұрын
Is there anything equivalent to signals in Windows?
@CodeVault3 жыл бұрын
Not very similar. Windows uses asynchronous procedure calls
@rigelmandarakuriom Жыл бұрын
Thank you ❤
@animeshkumar12014 жыл бұрын
Can this be done with threads?(expecting pthreads)
@CodeVault4 жыл бұрын
Threads are a different concept. You can have multiple threads running in the same process thus you can't communicate between them with signals. You usually use shared memory, locks, semaphores etc. to communicate between them
@matheusmaaia3 жыл бұрын
Thank you sir, it was very helpful!! I dont know if you'll see this but im kinda desperate so im going to ask anyway. I have some forks doing some executions but those executions are depending on random numbers generated with the rand function. Since the random takes a seed based on the time , the child processes keep finding always the sabe result as their fathers. Any tip to avoid that??Keep in mind that the program logic is to test random solutions for a problem and put the best one in a shared memory.
@CodeVault3 жыл бұрын
Hmm... You can change the parameter that you pass to srand. So instead of srand(time(NULL)); you could do srand(time(NULL) + getpid()); That way every process will pass a different number even if the time is the same
@matheusmaaia3 жыл бұрын
@@CodeVault Brilliantly simple! Thank you sir! i couldn't be abe to see this to the first step of my project but i'll try for sure on the next one!