fork() in linux

Поделиться
HTML-код
  • Опубликовано: 9 апр 2019
  • This video explains fork function in linux by using simple examples and code with outputs. This video will clear out all your doubts about fork so do watch till the end. If you find any difficulty or have any query then do COMMENT below. PLEASE help our channel by SUBSCRIBING and LIKE our video if you found it helpful...CYA :)
    CODE LINK: www.geeksforgeeks.org/fork-sy...

Комментарии • 38

  • @shubhamn2690
    @shubhamn2690 4 года назад +11

    Searched a lot of videos but found this to be the best. Keep up the good work bro!

  • @axmedkayse01
    @axmedkayse01 Месяц назад

    The best video for For(); function.

  • @elyeskallel
    @elyeskallel 9 месяцев назад

    very helpful, thank you so much :) ! clear and concise .

  • @subhabera5775
    @subhabera5775 4 года назад +2

    Thanks TechDose, that variable example was quite helpful. Just remembered after watching this video every user space process have its own variable and properties. So x definitely will be copied to child process also. :)

  • @galnadjar
    @galnadjar Год назад

    amazing video, thank you so much!

  • @maximumalready
    @maximumalready 3 года назад +1

    Excellent teaching 🔥 understood every bit of what you said .Clear and Precise information

  • @nikhilshanmugama424
    @nikhilshanmugama424 3 года назад +1

    In the last example, the function 'example' is called only once in the driver code, thus either parent process may have higher priority then 0 will be printed or if child process has higher priority then 2 will be printed but both being printed is not possible because it's an if else block.

  • @wilayatshah8882
    @wilayatshah8882 5 месяцев назад

    waow tooo good ..veryyyyyyyyyy informative ..thank you so much

  • @mohseensk4487
    @mohseensk4487 9 месяцев назад

    awesome dude...

  • @rahulchaubey8988
    @rahulchaubey8988 4 года назад +1

    Aag lga di bhai aapne👌👌 Super explaination.

  • @anjalikrishna7333
    @anjalikrishna7333 3 года назад +2

    In the last example given.... The parent and child process not sharing the same address space... Whether it depends on the operating system... Or is it a standard process behaviour?

    • @techdose4u
      @techdose4u  3 года назад

      This is just for LINUX OS. Other OS may have other system or algo.

  • @yashesvii
    @yashesvii 4 года назад +1

    A very nice tutorial !

  • @lifehacks9450
    @lifehacks9450 3 года назад +2

    Nice pls upload important concept in operating systems which are important for interviews

  • @abhishekjaiswal6492
    @abhishekjaiswal6492 3 года назад

    Great explanation , bu there is one doubt that the is the child process created in the same stack (frame) or in different stack (frame) ??

  • @VijayKumar-io5mf
    @VijayKumar-io5mf 4 года назад +1

    good explanation bro!!

  • @mukulgautam7373
    @mukulgautam7373 3 года назад +1

    best explanation brother

  • @souha3233
    @souha3233 Месяц назад

    once fork() is called in the parent process, a child process will be created it feels like both will have the same exact code. So, will the fork be called again with the child or this specific line where the child appeared will not be repeated in the child, so this line will be ignored to avoid an infinite loop?

  • @louaytheking9989
    @louaytheking9989 Месяц назад

    good explanation bro, just try to improve your accent so we can understand you better next time, good luck

  • @saichennu5288
    @saichennu5288 4 года назад +5

    Knowledge of Linux do any help during campus interviews ?

    • @techdose4u
      @techdose4u  4 года назад

      Yes for sure. If you are asked questions on OS then it can very easily get converted to a LINUX question. I have seen it and so i am saying by experience only.

  • @muhammadzaeemnasir290
    @muhammadzaeemnasir290 3 года назад +1

    nICE

  • @user-wv5mc1sp9e
    @user-wv5mc1sp9e 4 года назад +2

    This is a good explanation, but since fork() is called only once, how can it return two different values ?

    • @techdose4u
      @techdose4u  4 года назад

      Can you please mention the TIME of the video where you saw it so that i can reply accordingly.

    • @user-wv5mc1sp9e
      @user-wv5mc1sp9e 4 года назад

      @@techdose4u 4:15, I got it that the parent process calls fork() and it returns newly created child process' ID, that's clear. But at the same time the child process also gets a return value(Which is 0). Does this mean the child process calls fork() too?

    • @techdose4u
      @techdose4u  4 года назад

      No... Child won't call fork.... Since both parent and child are exact same copy, therefore since parent is getting pid of child. Child should get some return value just to maintain the flow of program to be the same in both parent and child. So, people decided to give it a value 0 since parent cannot get value 0. I hope you are getting it.

    • @user-wv5mc1sp9e
      @user-wv5mc1sp9e 4 года назад +1

      @@techdose4u Alright, let me draw a picture of how I'm understanding the thing now. Excuse my dumbness, I'm just trying to dive into the process :-) So we have a fork function, and inside of it there is a block of code, which actually is responsible for copying all the stuff and starting a new process. Also inside fork we have a return statement at the end of it. So when the first(parent) process calls fork it executes this block of code which copies the process and starts another one. And once it's done we have two processes coming up to the return statement at the end. And there is some kind of if(parent) return childPID, else return 0; That's how we get two different values. The function does not return two values, it just returns twice. How far is this from being correct? :-)

  • @yashesvii
    @yashesvii 4 года назад

    what if there is no priority given and both are executed simultaneously, is that possible ? if yes then how will the execution happen?

    • @gamystation
      @gamystation 3 года назад

      actually there is no priority of in execution it all depends on CPU memory so anytime can change the order thats something that u must not care about because it depends on cpu just know that both will be executed simultanousely thats all