this post was submitted on 14 Oct 2023
1206 points (98.6% liked)

Programmer Humor

37423 readers
69 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 6 years ago
MODERATORS
 

Programmers can answer all existential questions with ease

you are viewing a single comment's thread
view the rest of the comments
[–] mofongo@lemm.ee 12 points 2 years ago (1 children)

Is that actually more efficient if I need my child process to do something different with different data?

[–] raubarno@lemmy.ml 7 points 2 years ago (2 children)

It's more efficient for memory until you start working with different data. Threads also rely on the same syscall on Linux, clone(2), but they don't share the entire context by default, so they're more lightweight. It is recommended to use pthreads(3) API instead of fork(2).

[–] dan@upvote.au 3 points 2 years ago* (last edited 2 years ago)

Also, if you care about Windows, threads are far lighter than processes on that platform. Starting a new process is relatively slow compared to other platforms.

[–] mofongo@lemm.ee 2 points 2 years ago

Ah thx for the info