Skip to content

Instantly share code, notes, and snippets.

@binh12A3
Created September 3, 2023 16:17
Show Gist options
  • Save binh12A3/6e27bdc1494be7b51d80573db2ddc778 to your computer and use it in GitHub Desktop.
Save binh12A3/6e27bdc1494be7b51d80573db2ddc778 to your computer and use it in GitHub Desktop.
<< Thread >>
- Consume less resource.
- In multi-thread, when a thread calls exit() then all the threads will be exited.
<< Process >>
- The resource is duplicated.
- If Parent or Child calls exit(), then it doesn’t affect to the other as Parent and Child process is independent. If one dies, the other still alive.
- In case we have a code that can easily cause errors (i.e : open/close file, access to pointer, system call…) And we don’t want our program to be crashed because of that code, then we could separate the process by using fork().
- The parent process will run the main code.
- The child process will run the “risky” code.
- If the crash happens, the child will die, and the parent process will be still alive.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment