source: CIVL/examples/compare/queue/driver.cvl@ bb03188

main test-branch
Last change on this file since bb03188 was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 802 bytes
Line 
1/* two_lock_queue.cvl: a "Two-Lock Concurrent
2 * Queue Algorithm", from Michael and Scott,
3 * https://www.cs.rochester.edu/research/synchronization/pseudocode/queues.html.
4 * Originally from "Simple, Fast, and
5 * Practical Non-Blocking and Blocking
6 * Concurrent Queue Algorithms", PODC96.
7 */
8#include <civlc.cvh>
9#include <assert.h>
10#include "queue.h"
11
12$input int N=2;
13$input int T=2;
14$output int RESULT[T][N];
15int A[N];
16queue_t queue;
17
18void thread(int tid){
19 for(int i=0; i<N; i++)
20 enqueue(&queue, A[i]+tid*N);
21 for(int i=0; i<N; i++)
22 dequeue(&queue, &(RESULT[tid][i]));
23}
24
25int main(){
26 for(int i=0; i<N; i++)
27 A[i] = i+1;
28 for(int i=0; i<T; i++)
29 for(int j=0; j<N; j++)
30 RESULT[i][j] = 0;
31 initialize(&queue);
32 $parfor(int i: 0 .. T-1)
33 thread(i);
34 freequeue(queue);
35}
Note: See TracBrowser for help on using the repository browser.