Fork and Exec Linux Programming

Поделиться
HTML-код
  • Опубликовано: 2 июн 2024
  • Demo using fork and exec to run an executable from disk in a new process. Show how to pass arguments, wait for child to complete, and how to spawn multiple children. Shows advantage of using multiple processes over a single process in terms of using CPU power of multiple processors (cores).
    Other Videos:
    - Fork: • Linux fork() Introduction
    - Exec: • Linux Exec System Call
    - Eclipse Linux setup: • C Makefile Project in ...
    - Linux Programming playlist: • C Makefile Project in ...

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

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

    Hello, you didn't show us the bogosort file. Can you or anyone put here the code for that algorithm?

  • @jphamzz
    @jphamzz 6 лет назад

    thank you for making these videos. it is really helping me in class a lot!

  • @aboxx1982
    @aboxx1982 5 лет назад

    This is helping a whole bunch write a shell program. Thank you !!!!

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

    Great explanation! Helped a lot with my lab assignment.
    THANK YOU!!!!

  • @vigneshwarp3462
    @vigneshwarp3462 7 лет назад +2

    Really nice way to explain processes, showing sys utilization. Great help Sir. Thanks!!

  • @fuanka1724
    @fuanka1724 6 лет назад +1

    Thank you for these very informative videos.

  • @N.I.C.K-
    @N.I.C.K- 8 лет назад

    Excellent tutorial man, thank you so much

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

    thank you for your tutorial. It helps me a lot to understand fork and exec :D

  • @ahmadzaklouta
    @ahmadzaklouta 5 лет назад +1

    Thank you very much for this tutorial. I wish you do one for Kernal programming

  • @damjandjordjevic1994
    @damjandjordjevic1994 7 лет назад

    Nice tuts, but I still have a few questions:
    0.what happens if you allocate memory on the heap before calling fork and exec?
    1.how can I communicate between the parent and the forked process (beyond just getting child's return value)
    2.i forked my program, and exec'ed some other binary(from the child). the binary prints stuff out to the cli. Can I get its output from the parent code? Is popen() better suited for that kind of stuff?

  • @user-bp4sx6hx3q
    @user-bp4sx6hx3q 6 лет назад +2

    Much love from TU Graz

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

    what if one of the arguments passed in is "&" so that it is a background command when doing bash arguments? does exec recognize this?

  • @adilsher
    @adilsher 8 лет назад

    Sir! I have a scenario.. Can we take inputs using exec system call?
    As fork() returns two values, then how we are going to return those two values using exec(). If it makes sense, Please do a short program on execlp() taking two inputs from user and returning two values(one to the child process and other value to the parent process).. and it actually performs a task there like making a directory or pings for a website etc.
    Regards!

  • @neochen7235
    @neochen7235 9 лет назад

    Thank you so much for the tutorial, it is really helpful. :D

  • @lighttangerinesky
    @lighttangerinesky 8 лет назад

    Great explanation! Thanks!

  • @abdelhamid5371
    @abdelhamid5371 6 лет назад

    great work sir, thank you a lot.

  • @user-ew6wv9ln5h
    @user-ew6wv9ln5h Год назад

    Your explanation is really amazing👍👍
    I got so much help!!! Thank you!!!!!

  • @Mozkysl
    @Mozkysl 8 лет назад

    Awesome, great videos!

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

    is there any way to make the fork even faster?

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

    Hi sir, Hope you are good, have doubt in threading, can you help me. how can i get in touch with you regarding the same, Thanks

  • @muhanad102
    @muhanad102 9 лет назад

    Thank you very much , is there a way to make the children do different tasks for example I want one to sort and the other get the sum or average and so on ? Thank you

    • @HimikoWerckmeister
      @HimikoWerckmeister 8 лет назад

      +Muhanad Ahmad Yes you would need to call fork twice to create two children processes. and also run two if checks.

    • @ezetreezy
      @ezetreezy 8 лет назад

      +Muhanad Ahmad I believe you can create a function called ChildWork(int i); -> inside the function have a switch statement that does different sorts of work depending on if the child's integer value (iteration of i) is 1,2,3 etc.. -> place that function in the child else if part of his main code and pass in i)

  • @hadadrefael
    @hadadrefael 7 лет назад

    תודה רבה !

  • @piyushshrivastav3939
    @piyushshrivastav3939 9 лет назад

    thanks!!!!

  • @Nk_flim
    @Nk_flim 5 лет назад

    Nice sir

  • @faizanjoyia
    @faizanjoyia 9 лет назад

    Thanks

  • @johndoherty2403
    @johndoherty2403 9 лет назад

    What IDE is that ?

    • @theadrum
      @theadrum 9 лет назад +1

      John Doherty Looks like Eclipse

  • @mattsquires8047
    @mattsquires8047 5 лет назад

    nice tut, is this donald sutherland ?

  • @xion649
    @xion649 8 лет назад

    I cant understand why the parent need to wait for the child or the program would never end. It is the part around 8 mins.

    • @HimikoWerckmeister
      @HimikoWerckmeister 8 лет назад

      +Klose Ho A bit late, the answer is no he made another video on this.

    • @SravaniVadlamani
      @SravaniVadlamani 6 лет назад

      And Which video is that ? Could you share the link ?

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

    TYFYS

  • @OverRatedTechTV
    @OverRatedTechTV 8 лет назад +1

    breh u didn't talk about bogosort.c

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

      rosettacode.org/wiki/Sorting_algorithms/Bogosort#C
      Edit: here is what I used, adapted from above:
      #include
      #include
      #include
      #include
      #include
      bool isSorted(int *a, int n)
      {
      while ( --n >= 1)
      {
      //printf("
      not sorted..
      ");
      if ( a[n] < a[n-1] ) return false;
      }
      //printf("
      sorted..
      ");
      return true;
      }
      // LOL
      void shuffle(int *a, int n)
      {
      //printf("
      shufflin..
      ");
      int t, r;
      for (int i = 0; i < n; ++i)
      {
      t = a[i];
      r = rand() % n;
      a[i] = a[r];
      a[r] = t;
      }
      }
      void bogosort(int *a, int n)
      {
      while (!isSorted(a, n)) shuffle(a, n);
      }
      int main(int argc, char* argv[])
      {
      srand(time(NULL));
      // read numbers from input
      int n = argc-1;
      int* a = (int *)malloc(sizeof(int)*n);
      for (int i = 1; i

  • @Blazing234
    @Blazing234 6 лет назад

    Ugh I hate how none of these videos go into any detail. Can't one of them at least describe more complex trees

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

    Hello Khan academy?

  • @adarshgautam6712
    @adarshgautam6712 5 лет назад

    suppu what ra????????