2

I am now using GNU parallel in company's project,I wonder if a shell function written like this will use the multicore?

shell_function arg1 arg2 &

shell_function arg3 arg4 &

shell_function arg5 arg6 &

this will using multicore?

Charles Duffy
  • 280,126
  • 43
  • 390
  • 441
52coder
  • 179
  • 1
  • 2
  • 11

1 Answers1

0

Using & splits not just a new thread, but a whole new process. As such, these processes can indeed be assigned to different CPU cores (or, in multisocket environments, different CPUs).

However, note that these processes now have their own copies of local variables, and can no longer modify shell or environment variables inside the parent shell. As such, in many respects they behave more like entirely separate scripts than like regular function calls.

Charles Duffy
  • 280,126
  • 43
  • 390
  • 441