In another thread, a puzzle was mentioned where the goal is to read a list of words out of a file (one word per line, no spaces) and find the longest word which contains another word in the file (so "form" would qualify if "for" also appears).
I'm using this as a means of trying out fork and semaphore. However, I can't seem to get one process to finish. Here is the code:
This is another interesting item. It seems to fail when forking score-word at the same place every time for me, about 412 words in. Here is some testing code for it:
you have to use 'wait-pid' on a thread's process id returned from the 'fork' statement to make a thraed go away after returning. Wee the following program from newlisp-9.2.0/examples/prodcons.lsp
In that last post of mine, I map wait-pid to a list of the pids returned from fork. Then I run score-keeper in the main thread. It's like it locks after so many threads.
Jeff
=====
Old programmers don't die. They just parse on...
Ok, it appears that I am failing due to creating too many forks. When I reduce the number of forks it will continue, although apparently (while (read-line channel)) does not automatically fail with pipes. I had to use a dotimes over the length of the word list.
Jeff
=====
Old programmers don't die. They just parse on...
its probably running out of resources. On my MacBook (1.25Gig memory) I can do at least 2000 threads, but it starts to do the wait-pid branch after about 1200 threads.
Also, the size of the forks may be an issue, but even so, it should be greater than 500. With four gigs of ram and four 2.5 GHz cpus, it should be able to handle just about anything that I could possibly conceive to throw at it (except, perhaps, simple addition in Java, which takes several days to compute).
Jeff
=====
Old programmers don't die. They just parse on...
The amount of memory inside a machine is not the counter for the amount
of tasks/forks. That is a hardcoded counter. But the more memory the more
space is reserved per task. (this is what i remember from the old day on linux
kernels..)
My current linux machine handles 512 forks whereas my OS/2 machine only
handles 128.. the older linux kernel on 386 could only handle 128 too.. iirc..
I dont have a clue how this is done on the OSX BSD release but you should
be able to find some topics on it..
Using Bash, you could have a task limit per user (normaly not) but checkout the "ulimit" command perhpas its set...