Ignore:
Timestamp:
Nov 8, 2017, 2:50:35 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
049ead9
Parents:
136ccd7 (diff), e35f30a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into cleanup-dtors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tests/datingService.c

    r136ccd7 r4ee36bf0  
    1 //                               -*- Mode: C -*- 
    2 // 
     1//                               -*- Mode: C -*-
     2//
    33// The contents of this file are covered under the licence agreement in the
    44// file "LICENCE" distributed with Cforall.
    5 // 
    6 // datingService.c -- 
    7 // 
     5//
     6// datingService.c --
     7//
    88// Author           : Peter A. Buhr
    99// Created On       : Mon Oct 30 12:56:20 2017
     
    1111// Last Modified On : Mon Oct 30 23:02:11 2017
    1212// Update Count     : 15
    13 // 
     13//
    1414
    1515#include <stdlib>                                                                               // random
     
    1818#include <thread>
    1919#include <unistd.h>                                                                             // getpid
    20 
    21 bool empty( condition & c ) {
    22         return c.blocked.head == NULL;
    23 }
    2420
    2521enum { NoOfPairs = 20 };
     
    3127
    3228unsigned int girl( DatingService & mutex ds, unsigned int PhoneNo, unsigned int ccode ) {
    33         if ( empty( ds.Boys[ccode] ) ) {
    34                 wait( &ds.Girls[ccode] );
     29        if ( is_empty( ds.Boys[ccode] ) ) {
     30                wait( ds.Girls[ccode] );
    3531                ds.GirlPhoneNo = PhoneNo;
    3632        } else {
    3733                ds.GirlPhoneNo = PhoneNo;
    38                 signal_block( &ds.Boys[ccode] );
     34                signal_block( ds.Boys[ccode] );
    3935        } // if
    4036        return ds.BoyPhoneNo;
     
    4238
    4339unsigned int boy( DatingService & mutex ds, unsigned int PhoneNo, unsigned int ccode ) {
    44         if ( empty( ds.Girls[ccode] ) ) {
    45                 wait( &ds.Boys[ccode] );
     40        if ( is_empty( ds.Girls[ccode] ) ) {
     41                wait( ds.Boys[ccode] );
    4642                ds.BoyPhoneNo = PhoneNo;
    4743        } else {
    4844                ds.BoyPhoneNo = PhoneNo;
    49                 signal_block( &ds.Girls[ccode] );
     45                signal_block( ds.Girls[ccode] );
    5046        } // if
    5147        return ds.GirlPhoneNo;
Note: See TracChangeset for help on using the changeset viewer.