Changeset df65c0c


Ignore:
Timestamp:
Mar 12, 2021, 4:31:04 PM (6 months ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
arm-eh, jacob/cs343-translation, master, new-ast-unique-expr
Children:
41ca6fa, e867b44
Parents:
a1538cd
Message:

Fixed test after change to C api.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/concurrent/clib.c

    ra1538cd rdf65c0c  
     1#include <stdio.h>
     2#include <stdlib.h>
    13#include <clib/cfathread.h>
    24
    3 #include <stdio.h>
    4 #include <stdlib.h>
     5extern "C" {
     6void _exit(int status);
     7}
    58
    69thread_local struct drand48_data buffer = { 0 };
     
    1518cfathread_t volatile blocked[blocked_size];
    1619
    17 void Worker( cfathread_t this ) {
     20void * Worker( void * ) {
    1821        for(int i = 0; i < 1000; i++) {
    1922                int idx = myrand() % blocked_size;
     
    2225                        cfathread_unpark( thrd );
    2326                } else {
    24                         cfathread_t thrd = __atomic_exchange_n(&blocked[idx], this, __ATOMIC_SEQ_CST);
     27                        cfathread_t thrd = __atomic_exchange_n(&blocked[idx], cfathread_self(), __ATOMIC_SEQ_CST);
    2528                        cfathread_unpark( thrd );
    2629                        cfathread_park();
     
    2831        }
    2932        printf("Done\n");
     33        return NULL;
    3034}
    3135
    3236volatile bool stop;
    33 void Unparker( cfathread_t this ) {
     37void * Unparker( void * ) {
    3438        while(!stop) {
    3539                int idx = myrand() % blocked_size;
     
    4246        }
    4347        printf("Done Unparker\n");
     48        return NULL;
    4449}
    4550
     
    5156        }
    5257
    53         cfathread_setproccnt( 4 );
    54         cfathread_t u = cfathread_create( Unparker );
     58        cfathread_cluster_t cl = cfathread_cluster_self();
     59
     60        cfathread_cluster_add_worker( cl, NULL, NULL, NULL );
     61        cfathread_cluster_add_worker( cl, NULL, NULL, NULL );
     62        cfathread_cluster_add_worker( cl, NULL, NULL, NULL );
     63        cfathread_t u;
     64        cfathread_create( &u, NULL, Unparker, NULL );
    5565        {
    5666                cfathread_t t[20];
    5767                for(int i = 0; i < 20; i++) {
    58                         t[i] = cfathread_create( Worker );
     68                        cfathread_create( &t[i], NULL, Worker, NULL );
    5969                }
    6070                for(int i = 0; i < 20; i++) {
    61                         cfathread_join( t[i] );
     71                        cfathread_join( t[i], NULL );
    6272                }
    6373        }
    6474        stop = true;
    65         cfathread_join(u);
    66         cfathread_setproccnt( 1 );
     75        cfathread_join(u, NULL);
     76        fflush(stdout);
     77        _exit(0);
    6778}
Note: See TracChangeset for help on using the changeset viewer.