Kirk Brooks wrote: > True, but this illustrates that without multi-threading it's still a > sequential processor. Only one process at a time can be executing.
Yes, BUT... The thing about semaphores is, that they are atomic commands (the command is guranteed to execute without any other process interrupting it). And semaphore is the ONLY atomic command, all the other commands can be split in the middle by the systems scheduler. Your example might work, as you are only adding to the array but it will break, when you also delete array elements. Consider this: Process A adds array elements to an IP array and Process B deletes elements. Works fine, as long as the scheduler does not interrupt one of those commands. If the array has zero elements and process A tries to create a new one, the sheduler might switch processes when the element is created, but before a value is assigned. Then process B deletes an element. Now if it´s processes A time to continue, it tries to write the value to an array element that does not exist anymore. BAD! That´s why you better protect access to IP arrays/variables with semaphores. It is very hard to simulate the above since lots of conditions come into play and you MIGHT get lucky that it never happens to you, but if it DOES happen - good luck with finding the error. Greetings from Germany, Bernd Fröhlich ********************************************************************** 4D Internet Users Group (4D iNUG) FAQ: http://lists.4d.com/faqnug.html Archive: http://lists.4d.com/archives.html Options: http://lists.4d.com/mailman/options/4d_tech Unsub: mailto:[email protected] **********************************************************************

