Changeset 1edf37f


Ignore:
Timestamp:
Dec 14, 2017, 9:35:09 PM (4 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
fe4840a
Parents:
a1ecdd1
Message:

revert generic bounded-buffer to int bounded-buffer because of translator error

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tests/concurrent/examples/boundedBuffer.c

    ra1ecdd1 r1edf37f  
    88// Created On       : Mon Oct 30 12:45:13 2017
    99// Last Modified By : Peter A. Buhr
    10 // Last Modified On : Wed Dec 13 21:01:49 2017
    11 // Update Count     : 27
     10// Last Modified On : Thu Dec 14 21:28:52 2017
     11// Update Count     : 32
    1212//
    1313
     
    1818#include <unistd.h>                                                                             // getpid
    1919
    20 forall( otype T )
    2120monitor Buffer {
    2221        condition full, empty;
    2322        int front, back, count;
    24         T elements[20];
     23        int elements[20];
    2524};
    2625
    27 forall( otype T )
    28 void ?{}( Buffer(T) & buffer ) {
     26void ?{}( Buffer & buffer ) {
    2927        buffer.front = buffer.back = buffer.count = 0;
    3028}
    3129
    32 forall( otype T )
    33 int query( Buffer(T) & buffer ) { return buffer.count; }
     30int query( Buffer & buffer ) { return buffer.count; }
    3431
    35 forall( otype T )
    36 void insert( Buffer(T) & mutex buffer, T elem ) with( buffer ) {
     32void insert( Buffer & mutex buffer, int elem ) with( buffer ) {
    3733        if ( count == 20 ) wait( empty );
    3834        elements[back] = elem;
     
    4238}
    4339
    44 forall( otype T )
    45 T remove( Buffer(T) & mutex buffer ) with( buffer ) {
     40int remove( Buffer & mutex buffer ) with( buffer ) {
    4641        if ( count == 0 ) wait( full );
    47         T elem = elements[front];
     42        int elem = elements[front];
    4843        front = ( front + 1 ) % 20;
    4944        count -= 1;
     
    5348
    5449thread Producer {
    55         Buffer(int) & buffer;
     50        Buffer & buffer;
    5651        unsigned int N;
    5752};
     
    6358        insert( prod.buffer, -1 );
    6459}
    65 void ?{}( Producer & prod, Buffer(int) * buffer, unsigned int N ) {
     60void ?{}( Producer & prod, Buffer * buffer, unsigned int N ) {
    6661        &prod.buffer = buffer;
    6762        prod.N = N;
     
    6964
    7065thread Consumer {
    71         Buffer(int) & buffer;
     66        Buffer & buffer;
    7267        int & sum;                                              // summation of producer values
    7368};
     
    8176        } // for
    8277}
    83 void ?{}( Consumer & cons, Buffer(int) * buffer, int * sum ) {
     78void ?{}( Consumer & cons, Buffer * buffer, int * sum ) {
    8479        &cons.buffer = buffer;
    8580        &cons.sum = sum;
     
    8782
    8883int main() {
    89         Buffer(int) buffer;
     84        Buffer buffer;
    9085        enum { Prods = 5, Cons = 5 };
    9186        Producer * prods[Prods];
Note: See TracChangeset for help on using the changeset viewer.