fork

Started by frontera000, August 15, 2006, 01:07:00 PM

Previous topic - Next topic

frontera000

I am a bit confused about fork. It seems to be based on Unix fork() which creates a process. But manual says something about thread which is suggestive of light-weight process or threads as in pthread.  Normally thread is something that shares memory space with other threads, not a complete process with its own memory space.



Many languages have thread support and they all use light-weight threads, not processes.  I am wondering perhaps we should clarify the terminology in the manul or perhaps I am misguided. Is it the intent of newLISP to use processes for forking off an expression? I see value in that and it is useful. I am just wondering if there is a plan for supporting proper threads in the future and any clarifications on this. Java and C# have thread support in the language. Perl, python, ruby, etc. have support libraries. Lua has a coroutine that is interesting in that it can be used for multi-tasking as well as a generator. I am thinking it might be tricky to implement a coroutine in newLISP without support for continuation, but it might be interesting to have that feature.

Lutz

#1
Yes, newLISP uses classic UNIX style fork(). Pthreads will not be supported in newLISP, they do not fit into newLISP's architecture and style of programming. Processes based on UNIX fork are very efficient in newLISP, need a minimum of code to implement while keeping newLISP small and light weight. They inherent the parent variable space. To exchange information use shared memory or pipes.



Here is an example of using fork and shared memory in newLISP: http://newlisp.org/syntax.cgi?benchmarks/prodcons.newlisp.txt">http://newlisp.org/syntax.cgi?benchmark ... ewlisp.txt">http://newlisp.org/syntax.cgi?benchmarks/prodcons.newlisp.txt (also included in the source distribution. The manual entry for 'fork' has a pipe example.



The manual states that the implemantation is build on UNIX fork: http://newlisp.org/downloads/newlisp_manual.html#fork">http://newlisp.org/downloads/newlisp_manual.html#fork . If the terminology of 'process threads' is confusing and I can make the distinction to POSIX Pthreads more clearly in the manual.



Lutz