[fpc-pascal] Threading vs Parallelism ?

Sven Barth pascaldragon at googlemail.com
Fri Apr 14 09:36:11 CEST 2017


Am 14.04.2017 09:23 schrieb "Michael Schnell" <mschnell at lumino.de>:
>
> On 12.04.2017 14:09, Lars wrote:
>>
>> If unix could just make processes even lighter weight or
>> faster loading, I might avoid threads and just use processes...
>
> in Unix/Linux processes are not less "light" then threads. You can create
a process by "fork". no "Loading" involved. it just creates the process. If
you want to have the new process execute any code that is not shared with
the you need to do another system call to replace the code with the new
one. Moreover even if "loading" new code - in case another process already
runs this file, no actual loading  takes place, either, as the memory
management just uses the code page already in RAM.
>
> This definitively is as light as it gets.

A process definitely is less "light" than threads even on Unix systems: a
process has its own address space (even if it shares all pages with its
parent process) and also structures keeping track of the used resources
(e.g. open file descriptors). A thread does not need all this as it always
shares the same address space and the same resources.
Why do you think the concept of threads was introduced in Unix? Early Unix
systems only had processes.

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20170414/09a28c3c/attachment.html>


More information about the fpc-pascal mailing list