Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Side by Side Diff: test/cctest/test-platform-nullos.cc

Issue 21087012: Simplify implementation of Mutex. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix unit test. Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-platform-linux.cc ('k') | test/cctest/test-semaphore.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 static const int kLockCounterLimit = 50; 46 static const int kLockCounterLimit = 50;
47 static int busy_lock_counter = 0; 47 static int busy_lock_counter = 0;
48 48
49 49
50 static void LoopIncrement(Mutex* mutex, int rem) { 50 static void LoopIncrement(Mutex* mutex, int rem) {
51 while (true) { 51 while (true) {
52 int count = 0; 52 int count = 0;
53 int last_count = -1; 53 int last_count = -1;
54 do { 54 do {
55 CHECK_EQ(0, mutex->Lock()); 55 mutex->Lock();
56 count = busy_lock_counter; 56 count = busy_lock_counter;
57 CHECK_EQ(0, mutex->Unlock()); 57 mutex->Unlock();
58 yield(); 58 yield();
59 } while (count % 2 == rem && count < kLockCounterLimit); 59 } while (count % 2 == rem && count < kLockCounterLimit);
60 if (count >= kLockCounterLimit) break; 60 if (count >= kLockCounterLimit) break;
61 CHECK_EQ(0, mutex->Lock()); 61 mutex->Lock();
62 CHECK_EQ(count, busy_lock_counter); 62 CHECK_EQ(count, busy_lock_counter);
63 CHECK(last_count == -1 || count == last_count + 1); 63 CHECK(last_count == -1 || count == last_count + 1);
64 busy_lock_counter++; 64 busy_lock_counter++;
65 last_count = count; 65 last_count = count;
66 CHECK_EQ(0, mutex->Unlock()); 66 mutex->Unlock();
67 yield(); 67 yield();
68 } 68 }
69 } 69 }
70 70
71 71
72 static void* RunTestBusyLock(void* arg) { 72 static void* RunTestBusyLock(void* arg) {
73 LoopIncrement(static_cast<Mutex*>(arg), 0); 73 LoopIncrement(static_cast<Mutex*>(arg), 0);
74 return 0; 74 return 0;
75 } 75 }
76 76
(...skipping 19 matching lines...) Expand all
96 CHECK(vm->IsReserved()); 96 CHECK(vm->IsReserved());
97 void* block_addr = vm->address(); 97 void* block_addr = vm->address();
98 size_t block_size = 4 * KB; 98 size_t block_size = 4 * KB;
99 CHECK(vm->Commit(block_addr, block_size, false)); 99 CHECK(vm->Commit(block_addr, block_size, false));
100 // Check whether we can write to memory. 100 // Check whether we can write to memory.
101 int* addr = static_cast<int*>(block_addr); 101 int* addr = static_cast<int*>(block_addr);
102 addr[KB-1] = 2; 102 addr[KB-1] = 2;
103 CHECK(vm->Uncommit(block_addr, block_size)); 103 CHECK(vm->Uncommit(block_addr, block_size));
104 delete vm; 104 delete vm;
105 } 105 }
OLDNEW
« no previous file with comments | « test/cctest/test-platform-linux.cc ('k') | test/cctest/test-semaphore.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698