1

Today I have a theoretical question for you guys. I just joined my first larger software project at my company.

For some tasks such as copying files with some additional verification the company writes command line tools and they're calling them from their Objective-C source code using NSTask, which executes the command line tools as extra processes.

I don't really understand what the point behind that is.

Why would I create a separate command line tool to call it from my code instead of just calling the code in a separate thread?

The only thing that comes to my mind is that a process has an independent address space and maybe that my app would not crash if the command line tool crashes.

I heard that this is a common thing to do, so I would love to hear some opinions on what the advantage of doing so is. Thanks in advance!

guitarflow
  • 2,930
  • 25
  • 38
  • 3
    You seem to already have identified two fairly major reasons to use processes... – Oliver Charlesworth Mar 26 '13 at 23:35
  • Consider what further implications the differences identified imply. –  Mar 26 '13 at 23:36
  • @OliCharlesworth but why is the address space a big deal when executing small bits of code? – guitarflow Mar 26 '13 at 23:36
  • @guitarflow: A separate address space isn't a useful goal in itself. But it's useful if you want to achieve some form of isolation. – Oliver Charlesworth Mar 27 '13 at 00:42
  • Threads have one large advantage over processes - very efficient communication of large amounts of data. If the data to be transferred is small, and so comms is quick anyway compared with the operation to be performed, threads lose this advantage. – Martin James Mar 27 '13 at 00:52

0 Answers0