Changeset d8d9c115 for tests/concurrency
- Timestamp:
- May 30, 2023, 8:30:17 PM (19 months ago)
- Branches:
- ast-experimental, master
- Children:
- 5d81edb
- Parents:
- 8cbb6aa
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/concurrency/lockfree_stack.cfa
r8cbb6aa rd8d9c115 10 10 // Created On : Thu May 25 15:36:50 2023 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri May 26 08:08:47202313 // Update Count : 412 // Last Modified On : Tue May 30 19:02:32 2023 13 // Update Count : 18 14 14 // 15 15 … … 20 20 struct Node; // forward declaration 21 21 union Link { 22 struct { // 64-bit x 222 struct { // 32/64-bit x 2 23 23 Node * volatile top; // pointer to stack top 24 24 uintptr_t count; // count each push … … 57 57 Stack stack; // global stack 58 58 59 enum { Times = 60 #if defined( __ARM_ARCH ) // ARM CASV is very slow 61 10_000 62 #else 63 1_000_000 64 #endif // __arm_64__ 65 }; 66 59 67 thread Worker {}; 60 68 void main( Worker & w ) { 61 for ( i; 100000) {62 Node & n = *pop( stack ); 69 for ( i; Times ) { 70 Node & n = *pop( stack ); // pop any node 63 71 assert( &n != NULL ); 64 n.next.top = 0p; // s hrub fields72 n.next.top = 0p; // scrub fields 65 73 n.next.count = 0; 66 74 //yield( rand() % 3 ); 67 push( stack, n ); 75 push( stack, n ); // push it back 68 76 } 69 77 } 70 78 71 72 79 int main() { 73 enum { N = 10 };74 processor p[N - 1]; // kernel threads80 enum { N = 8 }; // kernel threads 81 processor p[N - 1]; // add kernel threads 75 82 76 83 for ( i; N ) { // push N values on stack
Note: See TracChangeset
for help on using the changeset viewer.