Microsoft research: A fork() in the road
Microsoft research: A fork() in the road
Posted Apr 10, 2019 13:32 UTC (Wed) by ibukanov (subscriber, #3942)Parent article: Microsoft Research: A fork() in the road
The real fork drawback is that it does not have sane semantics in multi-threaded semantics and using it with threads with shared memory do more harm then good . But fork in single threaded applications that uses it for computational workers works nicely and may even leads to better CPU cache utilization.
Posted Apr 10, 2019 21:00 UTC (Wed)
by rweikusat2 (subscriber, #117920)
[Link] (12 responses)
NB: I'm not going to read a paper presenting decades-old VMS 'design [irr]rationales' as 'new reseach'.
Posted Apr 11, 2019 7:23 UTC (Thu)
by ibukanov (subscriber, #3942)
[Link] (11 responses)
Posted Apr 11, 2019 10:31 UTC (Thu)
by dufkaf (guest, #10358)
[Link] (10 responses)
Posted Apr 11, 2019 15:33 UTC (Thu)
by ibukanov (subscriber, #3942)
[Link] (2 responses)
But my point is that for single-threaded applications fork has clear semantic. For example, to spawn a computation, prepare in the parent process all data in memory, fork, compute and send the results back using a pipe or shared memory. Works nicely.
Posted Apr 11, 2019 17:04 UTC (Thu)
by rweikusat2 (subscriber, #117920)
[Link]
Even assuming this was true (and it isn't), the original fork use-case would come to mind here: Execute a command in a background process instead of in the current one.
A use-case for 'exec in same process': In-place update of a running program. The currently running instance serializes and records its current state somehow and then execs itself, causing the updated program file to be loaded. The new instance then restores the serialized state and continues where the previous one left off.
Posted Apr 12, 2019 19:09 UTC (Fri)
by dufkaf (guest, #10358)
[Link]
Posted Apr 11, 2019 16:58 UTC (Thu)
by rweikusat2 (subscriber, #117920)
[Link] (6 responses)
Posted Apr 11, 2019 17:18 UTC (Thu)
by Cyberax (✭ supporter ✭, #52523)
[Link] (5 responses)
Posted Apr 11, 2019 17:35 UTC (Thu)
by rweikusat2 (subscriber, #117920)
[Link] (4 responses)
More complicated extension: For my usual use-case, the parent of the log forwarder will be a program which monitors another program, restarts that if it terminates unexpectedly and provides facilities for reliable termination of the other program and for reliably sending signals to it (feels like wrong grammar ...). For this to work, it needs to be the parent of the payload process.
Posted Apr 11, 2019 17:51 UTC (Thu)
by Cyberax (✭ supporter ✭, #52523)
[Link] (3 responses)
In your wrapper just spawn a log process, passing your stdin/stdout to it. Then exec() the payload.
No fork() required.
Posted Apr 11, 2019 18:03 UTC (Thu)
by rweikusat2 (subscriber, #117920)
[Link] (2 responses)
Posted Apr 11, 2019 18:07 UTC (Thu)
by Cyberax (✭ supporter ✭, #52523)
[Link] (1 responses)
Posted Apr 11, 2019 19:07 UTC (Thu)
by rweikusat2 (subscriber, #117920)
[Link]
Microsoft research: A fork() in the road
Microsoft research: A fork() in the road
And why should multithreaded app do it if not for the exec? For all other cases it can just create new thread?
Microsoft research: A fork() in the road
Microsoft research: A fork() in the road
Microsoft research: A fork() in the road
I was anwering to "How a multi-threaded application can do a fork in a sane manner?". One can fork as much as needed to create separate child processes first and then possibly create threads in each of those (which I guess is not a problem?) but why forking already multithreaded process (instead of creating additional thread) if not for the exec?
Microsoft research: A fork() in the road
Microsoft research: A fork() in the road
Microsoft research: A fork() in the road
Microsoft research: A fork() in the road
Microsoft research: A fork() in the road
Microsoft research: A fork() in the road
Microsoft research: A fork() in the road
Microsoft research: A fork() in the road
