| 11044 | } |
| 11045 | |
| 11046 | void testLockedInc(U32 address) { |
| 11047 | const U32 numberOfThreads = 10; |
| 11048 | const U32 numberOfIterationsPerThread = 1000000; |
| 11049 | |
| 11050 | memory->writed(cpu->seg[DS].address + address, 0); |
| 11051 | |
| 11052 | // inc memory |
| 11053 | newInstructionWithRM(0xff, 5, 0, 0xf0); |
| 11054 | pushCode32(address); |
| 11055 | |
| 11056 | // loop |
| 11057 | pushCode8(0xe2); |
| 11058 | pushCode8((U8)(S8)(-9)); // jump amount if ecx is not 0 |
| 11059 | |
| 11060 | setupForThread(); |
| 11061 | std::vector<KThread*> threads; |
| 11062 | for (U32 i = 0; i < numberOfThreads; i++) { |
| 11063 | threads.push_back(doLockedIncThread(numberOfIterationsPerThread)); |
| 11064 | } |
| 11065 | for (U32 i = 0; i < numberOfThreads; i++) { |
| 11066 | joinThread(threads[i]); |
| 11067 | } |
| 11068 | U32 value = memory->readd(cpu->seg[DS].address + address); |
| 11069 | assertTrue(value == numberOfIterationsPerThread * numberOfThreads); |
| 11070 | } |
| 11071 | |
| 11072 | void testLockedInc() { |
| 11073 | testLockedInc(0xc8); // aligned 8 |
nothing calls this directly
no test coverage detected