Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changes between Version 6 and Version 7 of DiffFromUnix


Ignore:
Timestamp:
2013-03-08T09:52:27Z (6 years ago)
Author:
Jiri Svoboda
Comment:

UN*X standards have posix_spawn()

Legend:

Unmodified
Added
Removed
Modified
  • DiffFromUnix

    v6 v7  
    33== No `fork()`, no `exec()` ==
    44
    5 In traditional UN*X, new processes are created by duplicating the resources of the current process via a call to `fork()`. Forking a process will, among other things, clone the current thread of that process. After `fork()`, both threads typically test whether they are the parent or the child instance. Very often, the child thread makes a call to `exec()` to load a new program. Calling `exec()` replaces the contents of the address space of the entire process with the new content of the loaded program. As can be seen, especially without heavy optimizations such as copy-on-write allocation of memory pages and non-duplicating variants of `fork()` such as `vfork()`, the procedure of spawning a new program is quite wasteful.
     5In traditional UN*X, new processes are created by duplicating the resources of the current process via a call to `fork()`. Forking a process will, among other things, clone the current thread of that process. After `fork()`, both threads typically test whether they are the parent or the child instance. Very often, the child thread makes a call to `exec()` to load a new program. Calling `exec()` replaces the contents of the address space of the entire process with the new content of the loaded program. As can be seen, especially without heavy optimizations such as copy-on-write allocation of memory pages and non-duplicating variants of `fork()` such as`vfork()`, the procedure of spawning a new program is quite wasteful. This is the reason why UN*X standards introduced `posix_spawn()` which should be the way forward, but fork()/exec() will probably remain for backward compatibility (forever?)
    66
    77In HelenOS, there is no `fork()` or `exec()` or any variant thereof. Programs are simply spawned by calling `task_spawn()`, which creates a separate new task for the loaded program and allows the caller to continue to run. Likewise, new threads and thread-like entities are created by calling `thread_create()` and `fibril_create()`.