How is preventing deadlocks in multi-processing different from multi-threading? via /r/learnprogramming


How is preventing deadlocks in multi-processing different from multi-threading?

A few weeks ago during a phone interview the hiring manager asked me how resolving a deadlock with multiple processes in parallel differs from resolving a deadlock in multi-threading.

I'm aware that for multi-threading, you can resolve deadlocks by making sure the code always acquires a lock on resources in a set order. So for example, if Thread 1 and Thread 2 both want resource A and resource B, then a deadlock cannot occur if they always attempt to acquire resource A first, then resource B in that order

In the case of multi-processing with processes instead of threads, I thought requiring the processes to acquire resource A first, and then B, would also resolve the deadlock. But he said no and I believe he said it was because multi-threading the threads share the same memory but for multi-processing the processes don't share the memory

Why would the processes not sharing memory have to do with acquiring a lock on resources in a set order not preventing deadlocks for multi-processing?

Submitted July 10, 2017 at 04:37AM by 74throwaway
via reddit http://ift.tt/2tYWQUc

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s