Click for: WEBPAGE INDEXweb page last updated Wednesday 25th Feb 2004 night, With assign counts every time you do the assign the count goes up by one, when you remove an assign the count goes down by one, only if assign count reaches 0 is the assign removed. The problem that can happen is that if 2 tasks read the count in very quick succesion the count may take on a wrong value eg: count == 3 Task A reads count == 3, Task A is pre-empted, Task B reads count == 3 , adds 1 to get 4, updates: count = 4 Later Task A gets the CPU, it continues from where it left off adds 1 to 3, gets 4, updates: count = 4. So now count wrongly says 4, when it should say 5. This will lead to the assign being removed too early. There are other variants of the same theme that can go wrong. I think this problem is responsible for some of the weird problems that sometimes happen. It means that code such as the following is wrong: if $xyz_count eq 1 assign xyz endif if $xyz_count gt 0 eval $xyz_count - 1 to env:xyz_count endif This code is wrong in several places, and if 2 tasks use it in very quick succession things can go totally skew. eg if task A reads count and sees it is 1, and then is pre-empted, and task B now reads count sees it is 1 and so doesnt do an assign. task A now gets the CPU and removes the assign which creates problems for task B. Note that between any 2 references to $xyz_count in the above example the value might have been changed by some other task. Anyway I am planning to make an assign count mechanism, I think I have a fool proof mechanism thought up. I just have to scrutinize it a bit and then I'll write + upload it to this website. Its one of those generic useful utilities, not GS8 specific. When I mentioned the assign count problem to J.E.Gilpin in an email, he pointed out to me that the Amiga's Semaphore mechanism was created for resolving precisely this type of multitasking bug. I didnt quite believe him! But then I decided to look at the RKMs and found Semaphores will solve the assign count problem in a very generic and elegant manner. Anyway as a result I have created a generic mechanism that uses the Exec Semaphores from which the assign count problem can be solved. It will all get uploaded eventually, I'm very busy on the main GS8 problems + issues at the moment hence the delay.

visit this page for how to do assign counts correctly


Get a GoStats hit counter