diff options
author | micha <micha@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2007-05-21 20:39:33 +0000 |
---|---|---|
committer | micha <micha@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2007-05-21 20:39:33 +0000 |
commit | 9269e6e2979ce1a2cc12666cec100b9f503fbea2 (patch) | |
tree | 40aa13fb0c8a84dc31362095188f94e982273fe3 /tests/test/theapthread.pp | |
parent | 95335370cbb79345017dbf0397c67c11fed4164d (diff) | |
download | fpc-9269e6e2979ce1a2cc12666cec100b9f503fbea2.tar.gz |
* prevent freeing in both threads at the same time in theapthread test
git-svn-id: http://svn.freepascal.org/svn/fpc/trunk@7415 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'tests/test/theapthread.pp')
-rw-r--r-- | tests/test/theapthread.pp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/test/theapthread.pp b/tests/test/theapthread.pp index bf8131b7dc..5502c298b0 100644 --- a/tests/test/theapthread.pp +++ b/tests/test/theapthread.pp @@ -21,6 +21,7 @@ var writeindex: integer; fifo: array[0..1023] of pointer; done: boolean; + freefifolock: trtlcriticalsection; type ttestarray = array[0..31] of pointer; @@ -79,7 +80,9 @@ begin end; end; freearray(p, sizeof(p) div sizeof(pointer)); + entercriticalsection(freefifolock); freearray(fifo, sizeof(fifo) div sizeof(pointer)); + leavecriticalsection(freefifolock); end; procedure consumer; @@ -91,6 +94,7 @@ begin i := 0; j := 0; k := 0; + entercriticalsection(freefifolock); while not done do begin if readindex <> writeindex then @@ -108,6 +112,7 @@ begin end; end; end; + leavecriticalsection(freefifolock); freearray(p, sizeof(p) div sizeof(pointer)); end; @@ -127,6 +132,7 @@ var produce_thread: tproducethread; consume_thread: tconsumethread; begin + initcriticalsection(freefifolock); done := false; filldword(fifo, sizeof(fifo) div sizeof(dword), 0); readindex := 0; @@ -139,4 +145,5 @@ begin consume_thread.waitfor; produce_thread.free; consume_thread.free; + donecriticalsection(freefifolock); end. |