OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [compat/] [posix/] [current/] [tests/] [pmutex3.c] - Blame information for rev 810

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//        pmutex3.c
4
//
5
//        Mutex test 3 - priority inheritance
6
//
7
//==========================================================================
8
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
9
// -------------------------------------------                              
10
// This file is part of eCos, the Embedded Configurable Operating System.   
11
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
12
//
13
// eCos is free software; you can redistribute it and/or modify it under    
14
// the terms of the GNU General Public License as published by the Free     
15
// Software Foundation; either version 2 or (at your option) any later      
16
// version.                                                                 
17
//
18
// eCos is distributed in the hope that it will be useful, but WITHOUT      
19
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
20
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
21
// for more details.                                                        
22
//
23
// You should have received a copy of the GNU General Public License        
24
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
25
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
26
//
27
// As a special exception, if other files instantiate templates or use      
28
// macros or inline functions from this file, or you compile this file      
29
// and link it with other works to produce a work based on this file,       
30
// this file does not by itself cause the resulting work to be covered by   
31
// the GNU General Public License. However the source code for this file    
32
// must still be made available in accordance with section (3) of the GNU   
33
// General Public License v2.                                               
34
//
35
// This exception does not invalidate any other reasons why a work based    
36
// on this file might be covered by the GNU General Public License.         
37
// -------------------------------------------                              
38
// ####ECOSGPLCOPYRIGHTEND####                                              
39
//==========================================================================
40
//#####DESCRIPTIONBEGIN####
41
//
42
// Author(s):     hmt
43
// Contributors:  hmt, nickg, jlarmour
44
// Date:          2000-01-06
45
// Description:   Tests mutex priority inheritance. This is simply a translation
46
//                of the similarly named kernel test to the POSIX API
47
//####DESCRIPTIONEND####
48
 
49
// ------------------------------------------------------------------------
50
 
51
#include <cyg/infra/testcase.h>
52
#include <pkgconf/posix.h>
53
#include <pkgconf/system.h>
54
#ifdef CYGPKG_KERNEL
55
#include <pkgconf/kernel.h>
56
#endif
57
 
58
#ifdef CYGPKG_ISOINFRA
59
# include <sys/types.h>
60
# include <pthread.h>
61
# include <semaphore.h>
62
# include <time.h>
63
# include <unistd.h>
64
#endif
65
 
66
#if !defined(CYGPKG_POSIX_PTHREAD)
67
#define NA_MSG "POSIX threads not enabled"
68
 
69
// ------------------------------------------------------------------------
70
//
71
// These checks should be enough; any other scheduler which has priorities
72
// should manifest as having no priority inheritance, but otherwise fine,
73
// so the test should work correctly.
74
 
75
#elif !defined(_POSIX_THREAD_PRIORITY_SCHEDULING)
76
#define NA_MSG "No POSIX thread priority scheduling enabled"
77
#elif !defined(_POSIX_THREAD_PRIO_INHERIT)
78
#define NA_MSG "No POSIX thread priority inheritance enabled"
79
#elif !defined(_POSIX_SEMAPHORES)
80
#define NA_MSG "No POSIX sempaphore support enabled enabled"
81
#elif !defined(CYGFUN_KERNEL_API_C)
82
#define NA_MSG "Kernel C API not enabled"
83
#elif defined(CYGPKG_KERNEL_SMP_SUPPORT)
84
#define NA_MSG "Test cannot run with SMP support"
85
#endif
86
 
87
#ifdef NA_MSG
88
void
89
cyg_start(void)
90
{
91
    CYG_TEST_INIT();
92
    CYG_TEST_NA(NA_MSG);
93
}
94
#else
95
 
96
#include <cyg/infra/cyg_ass.h>
97
#include <cyg/infra/cyg_trac.h>
98
#include <cyg/infra/diag.h>             // diag_printf
99
 
100
#include <cyg/kernel/kapi.h>            // Some extras
101
 
102
// ------------------------------------------------------------------------
103
// Management functions
104
//
105
// Stolen from testaux.hxx and copied in here because I want to be able to
106
// reset the world also.
107
// ... and subsequently POSIXized out of all similarly with its progenitors.
108
 
109
#define NTHREADS 7
110
 
111
#define STACKSIZE (PTHREAD_STACK_MIN*2)
112
 
113
static pthread_t thread[NTHREADS] = { 0 };
114
 
115
typedef CYG_WORD64 CYG_ALIGNMENT_TYPE;
116
 
117
static CYG_ALIGNMENT_TYPE stack[NTHREADS] [
118
   (STACKSIZE+sizeof(CYG_ALIGNMENT_TYPE)-1)
119
     / sizeof(CYG_ALIGNMENT_TYPE)                     ];
120
 
121
// Semaphores to halt execution of threads     
122
static sem_t hold[NTHREADS];
123
 
124
// Flag to tell all threads to exit
125
static int all_exit;
126
 
127
// Application thread data is passed here, the thread
128
// argument is 
129
static CYG_ADDRWORD thread_data[NTHREADS];
130
 
131
static volatile int nthreads = 0;
132
 
133
// Sleep for 1 tick...
134
static struct timespec sleeptime;
135
 
136
 
137
static pthread_t new_thread( void *(*entry)(void *),
138
                             CYG_ADDRWORD data,
139
                             int priority,
140
                             int do_resume)
141
{
142
    pthread_attr_t attr;
143
    int _nthreads = nthreads++;
144
 
145
    struct sched_param schedparam;
146
    schedparam.sched_priority = priority;
147
 
148
    pthread_attr_init( &attr );
149
    pthread_attr_setstackaddr( &attr, (void *)((char *)(&stack[_nthreads])+STACKSIZE) );
150
    pthread_attr_setstacksize( &attr, STACKSIZE );
151
    pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED );
152
    pthread_attr_setschedpolicy( &attr, SCHED_RR );
153
    pthread_attr_setschedparam( &attr, &schedparam );
154
 
155
    CYG_ASSERT(_nthreads < NTHREADS,
156
               "Attempt to create more than NTHREADS threads");
157
 
158
    thread_data[_nthreads] = data;
159
 
160
    sem_init( &hold[_nthreads], 0, do_resume ? 1 : 0 );
161
    all_exit = 0;
162
 
163
    pthread_create( &thread[_nthreads],
164
                    &attr,
165
                    entry,
166
                    (void *)_nthreads);
167
 
168
    return thread[_nthreads];
169
}
170
 
171
 
172
static void kill_threads( void )
173
{
174
    CYG_ASSERT(nthreads <= NTHREADS,
175
               "More than NTHREADS threads");
176
    CYG_ASSERT( pthread_equal(pthread_self(),thread[0]),
177
                "kill_threads() not called from thread 0");
178
    all_exit = 1;
179
    while ( nthreads > 1 ) {
180
        nthreads--;
181
        if ( 0 != thread[nthreads] ) {
182
            sem_post( &hold[nthreads] );
183
            pthread_cancel( thread[nthreads] );
184
            pthread_join( thread[nthreads], NULL );
185
            thread[nthreads] = 0;
186
            sem_destroy( &hold[nthreads] );
187
        }
188
    }
189
    CYG_ASSERT(nthreads == 1,
190
               "No threads left");
191
}
192
 
193
// ------------------------------------------------------------------------
194
 
195
#define DELAYFACTOR 1 // for debugging
196
 
197
// ------------------------------------------------------------------------
198
 
199
pthread_mutex_t mutex;
200
 
201
// These are for reporting back to the master thread
202
volatile int got_it  = 0;
203
volatile int t3ran   = 0;
204
volatile int t3ended = 0;
205
volatile int extras[4] = {0,0,0,0};
206
 
207
volatile int go_flag = 0; // but this one controls thread 3 from thread 2
208
 
209
// ------------------------------------------------------------------------
210
// 0 to 3 of these run generally to interfere with the other processing,
211
// to cause multiple prio inheritances, and clashes in any orders.
212
 
213
static void *extra_thread( void *arg )
214
{
215
#define XINFO( z ) \
216
    do { z[13] = '0' + data; CYG_TEST_INFO( z ); } while ( 0 )
217
 
218
    static char running[]  = "Extra thread Xa running";
219
    static char exiting[]  = "Extra thread Xa exiting";
220
    static char resumed[]  = "Extra thread Xa resumed";
221
    static char locked[]   = "Extra thread Xa locked";
222
    static char unlocked[] = "Extra thread Xa unlocked";
223
 
224
    int id = (int)arg;
225
    CYG_ADDRWORD data = thread_data[id];
226
 
227
    CYG_ASSERT( (id >= 4 && id <= 6), "extra_thread invalid id" );
228
 
229
    // Emulate resume behaviour
230
    sem_wait( &hold[id] );
231
    if( all_exit ) return 0;
232
 
233
    XINFO( running );
234
 
235
    sem_wait( &hold[id] );
236
 
237
    XINFO( resumed );
238
 
239
    pthread_mutex_lock( &mutex );
240
 
241
    XINFO( locked );
242
 
243
    pthread_mutex_unlock( &mutex );
244
 
245
    XINFO( unlocked );
246
 
247
    extras[ data ] ++;
248
 
249
    XINFO( exiting );
250
 
251
    return NULL;
252
}
253
 
254
// ------------------------------------------------------------------------
255
 
256
static void *t1( void *arg )
257
{
258
    int id = (int)arg;
259
    //CYG_ADDRWORD data = thread_data[id];
260
 
261
    // Emulate resume behaviour
262
    sem_wait( &hold[id] );
263
    if( all_exit ) return 0;
264
 
265
    CYG_TEST_INFO( "Thread 1 running" );
266
 
267
    sem_wait( &hold[id] );
268
 
269
    pthread_mutex_lock( &mutex );
270
 
271
    got_it++;
272
 
273
    CYG_TEST_CHECK( 0 == t3ended, "T3 ended prematurely [T1,1]" );
274
 
275
    pthread_mutex_unlock( &mutex );
276
 
277
    CYG_TEST_CHECK( 0 == t3ended, "T3 ended prematurely [T1,2]" );
278
 
279
    // That's all.
280
 
281
    CYG_TEST_INFO( "Thread 1 exit" );
282
 
283
    return 0;
284
}
285
 
286
// ------------------------------------------------------------------------
287
 
288
static void *t2( void *arg )
289
{
290
    int i;
291
    int id = (int)arg;
292
    CYG_ADDRWORD data = thread_data[id];
293
    cyg_tick_count_t now, then;
294
 
295
    // Emulate resume behaviour
296
    sem_wait( &hold[id] );
297
    if( all_exit ) return 0;
298
 
299
    CYG_TEST_INFO( "Thread 2 running" );
300
 
301
    CYG_TEST_CHECK( 0 == (data & ~0x77), "Bad T2 arg: extra bits" );
302
    CYG_TEST_CHECK( 0 == (data & (data >> 4)), "Bad T2 arg: overlap" );
303
 
304
    sem_wait( &hold[id] );
305
 
306
    // depending on our config argument, optionally restart some of the
307
    // extra threads to throw noise into the scheduler:
308
    for ( i = 0; i < 3; i++ )
309
        if ( (1 << i) & data )          // bits 0-2 control
310
            sem_post( &hold[i+4] );     // made sure extras are thread[4-6]
311
 
312
    // let those threads run
313
    for( i = 0; i < DELAYFACTOR * 10; i++ )
314
        nanosleep( &sleeptime, NULL );
315
 
316
    cyg_scheduler_lock();               // do this next lot atomically
317
 
318
    go_flag = 1;                        // unleash thread 3
319
    sem_post( &hold[1] );               // resume thread 1
320
 
321
    // depending on our config argument, optionally restart some of the
322
    // extra threads to throw noise into the scheduler at this later point:
323
    for ( i = 4; i < 7; i++ )
324
        if ( (1 << i) & data )          // bits 4-6 control
325
            sem_post( &hold[i] );       // made sure extras are thread[4-6]
326
 
327
    cyg_scheduler_unlock();             // let scheduling proceed
328
 
329
    // Need a delay (but not a CPU yield) to allow t3 to awaken and act on
330
    // the go_flag, otherwise we check these details below too soon.
331
    // Actually, waiting for the clock to tick a couple of times would be
332
    // better, so that is what we will do.  Must be a busy-wait.
333
    then = cyg_current_time();
334
    do {
335
        now = cyg_current_time();
336
        // Wait longer than the delay in t3 waiting on go_flag
337
    } while ( now < (then + 3) );
338
 
339
#ifdef _POSIX_THREAD_PRIO_INHERIT
340
    CYG_TEST_INFO( "Checking for mutex priority inheritance" );
341
    CYG_TEST_CHECK( 1 == t3ran, "Thread 3 did not run" );
342
    CYG_TEST_CHECK( 1 == got_it, "Thread 1 did not get the mutex" );
343
#else
344
    CYG_TEST_INFO( "Checking for NO mutex priority inheritance" );
345
    CYG_TEST_CHECK( 0 == t3ran, "Thread 3 DID run" );
346
    CYG_TEST_CHECK( 0 == got_it, "Thread 1 DID get the mutex" );
347
#endif
348
 
349
    CYG_TEST_CHECK( 0 == t3ended, "Thread 3 ended prematurely [T2,1]" );
350
 
351
    for( i = 0; i < DELAYFACTOR * 20; i++ )
352
        nanosleep( &sleeptime, NULL );      // let those threads run  
353
 
354
    CYG_TEST_CHECK( 1 == t3ran, "Thread 3 did not run" );
355
    CYG_TEST_CHECK( 1 == got_it, "Thread 1 did not get the mutex" );
356
    CYG_TEST_CHECK( 1 == t3ended, "Thread 3 has not ended" );
357
 
358
    for ( i = 0; i < 3; i++ )
359
        if ( (1 << i) & (data | data >> 4) ) // bits 0-2 and 4-6 control
360
            CYG_TEST_CHECK( 1 == extras[i+1], "Extra thread did not run" );
361
        else
362
            CYG_TEST_CHECK( 0 == extras[i+1], "Extra thread ran" );
363
 
364
    CYG_TEST_PASS( "Thread 2 exiting, AOK" );
365
    // That's all: restart the control thread.
366
    sem_post( &hold[0] );
367
 
368
    return 0;
369
}
370
 
371
// ------------------------------------------------------------------------
372
 
373
static void *t3( void *arg )
374
{
375
    int i;
376
    int id = (int)arg;
377
    //CYG_ADDRWORD data = thread_data[id];
378
 
379
    // Emulate resume behaviour
380
    sem_wait( &hold[id] );
381
    if( all_exit ) return 0;
382
 
383
    CYG_TEST_INFO( "Thread 3 running" );
384
 
385
    pthread_mutex_lock( &mutex );
386
 
387
    for( i = 0; i < DELAYFACTOR * 5; i++ )
388
        nanosleep( &sleeptime, NULL );      // let thread 3a run
389
 
390
    sem_post( &hold[2] );               // resume thread 2
391
 
392
    while ( 0 == go_flag )
393
        nanosleep( &sleeptime, NULL );  // wait until we are told to go
394
 
395
    t3ran ++;                           // record the fact
396
 
397
    CYG_TEST_CHECK( 0 == got_it, "Thread 1 claims to have got my mutex" );
398
 
399
    pthread_mutex_unlock( &mutex );
400
 
401
    t3ended ++;                         // record that we came back
402
 
403
    CYG_TEST_CHECK( 1 == got_it, "Thread 1 did not get the mutex" );
404
 
405
    CYG_TEST_INFO( "Thread 3 exit" );
406
 
407
    return 0;
408
}
409
 
410
// ------------------------------------------------------------------------
411
 
412
static void *control_thread( void *arg )
413
{
414
    int i,z;
415
    int id = (int)arg;
416
    //CYG_ADDRWORD data = thread_data[id];
417
 
418
    // Emulate resume behaviour
419
    sem_wait( &hold[id] );
420
    if( all_exit ) return 0;
421
 
422
    // one tick sleep time
423
    sleeptime.tv_nsec = 10000000;
424
    sleeptime.tv_sec = 0;
425
 
426
    CYG_TEST_INIT();
427
    CYG_TEST_INFO( "Control Thread running" );
428
 
429
    // Go through the 27 possibilitied of resuming the extra threads
430
    //     0: not at all
431
    //     1: early in the process
432
    //     2: later on
433
    // which are represented by bits 0-3 and 4-6 resp in the argument to
434
    // thread 2 (none set means no resume at all).
435
    for ( i = 0; i < 27; i++ ) {
436
        static int xx[] = { 0, 1, 16 };
437
        int j = i % 3;
438
        int k = (i / 3) % 3;
439
        int l = (i / 9) % 3;
440
 
441
        int d = xx[j] | (xx[k]<<1) | (xx[l]<<2) ;
442
 
443
        if ( cyg_test_is_simulator && (0 != i && 13 != i && 26 != i) )
444
            continue;    // 13 is 111 base 3, 26 is 222 base 3
445
 
446
#ifdef _POSIX_THREAD_PRIO_INHERIT
447
        // If the simple scheme plus relay enhancement, or any other
448
        // *complete* scheme, we can run all three ancillary threads no
449
        // problem, so no special action here.
450
 
451
#else
452
        // If no priority inheritance at all, running threads 1a and 2a is
453
        // OK, but not thread 3a; it blocks the world.
454
        if ( l )                        // Cannot run thread 3a if no
455
            break;                      //     priority inheritance at all.
456
#endif
457
 
458
        // Reinitialize mutex to provide priority inheritance
459
        {
460
            pthread_mutexattr_t attr;
461
            pthread_mutexattr_init( &attr );
462
            pthread_mutexattr_setprotocol( &attr, PTHREAD_PRIO_INHERIT );
463
            pthread_mutex_init( &mutex, &attr );
464
        }
465
 
466
        got_it  = 0;
467
        t3ran   = 0;
468
        t3ended = 0;
469
        for ( z = 0; z < 4; z++ ) extras[z] = 0;
470
        go_flag = 0;
471
 
472
        new_thread( t1, 0, 15, 1 );            // Slot 1
473
        new_thread( t2, d, 10, 1 );            // Slot 2
474
        new_thread( t3, 0,  5, 1 );            // Slot 3
475
 
476
        new_thread( extra_thread, 1, 17, j );  // Slot 4
477
        new_thread( extra_thread, 2, 12, k );  // Slot 5
478
        new_thread( extra_thread, 3,  8, l );  // Slot 6
479
 
480
        {
481
            static char *a[] = { "inactive", "run early", "run late" };
482
            diag_printf( "\n----- [%2d] New Cycle: 0x%02x, Threads 1a %s, 2a %s, 3a %s -----\n",
483
                         i, d,  a[j], a[k], a[l] );
484
        }
485
 
486
        sem_wait( &hold[0] );
487
 
488
        kill_threads();
489
        pthread_mutex_destroy( &mutex );
490
    }
491
    CYG_TEST_EXIT( "Control Thread exit" );
492
 
493
    return 0;
494
}
495
 
496
// ------------------------------------------------------------------------
497
 
498
static sem_t main_sem;
499
 
500
externC int
501
main( int argc, char **argv )
502
{
503
    new_thread( control_thread, 0, 20, 1 );
504
 
505
    // We have nothing for main to do here, so put it to sleep on
506
    // its own semaphore. We cannot let it just exit since that
507
    // will end the whole program.
508
 
509
    sem_init( &main_sem, 0, 0 );
510
 
511
    for(;;) sem_wait( &main_sem );
512
}
513
 
514
// ------------------------------------------------------------------------
515
// Documentation: enclosed is the design of this test.
516
//
517
// It has been carefully constructed so that it does NOT use other kernel
518
// facilities (aside from delay-task) to test that priority inheritance is
519
// working, or not, as intended by the configuration.
520
//
521
// These notes describe the flow of control in one run of the test with the
522
// ancillary tasks optionally interspersed.  The details of how those extra
523
// tasks are or are not allowed to run are not described.
524
// 
525
// 
526
// 
527
// The only change in the test that depends on whether there is inheritance or
528
// not is the check in thread 2 on "3-ran" and "got it" flags marked ****
529
// 
530
// 
531
// volatile &c booleans:
532
//         "got it"     = FALSE
533
//         "3-ran"      = FALSE
534
//         "3-ended"    = FALSE
535
//         "extras"[3]  = FALSE
536
// 
537
// thread 1.  prio 5, self-suspend.
538
// 
539
// thread 1a, prio 8, self-suspend.
540
// 
541
// thread 2.  prio 10, self-suspend.
542
// 
543
// thread 2a, prio 12, self-suspend.
544
// 
545
// thread 3.  prio 15, runs, lock mutex, resume(2)
546
// 
547
// thread 3a, prio 17, self-suspend.
548
// 
549
//        2.  runs,
550
//        2.  resume(3a) +++OPTIONAL
551
//        2.  resume(2a) +++OPTIONAL
552
//        2.  resume(1a) +++OPTIONAL
553
//        [1a lock-fail]        thread 3->prio := 8
554
// 
555
//        [3. runs maybe, does the looping thing]
556
// 
557
//        2.  sleep a while...
558
// 
559
//        [2a lock-fail]        thread 3->prio := 12
560
// 
561
//        [3. runs maybe, does the looping thing]
562
// 
563
//        [3a lock-fail]   thread 3->prio unchanged
564
// 
565
//        [3. runs maybe, does the looping thing]
566
// 
567
//        2.  lock scheduler
568
//        2.  set "go-flag"
569
//        2.  resume(1)
570
//        2.  resume(1a) +++OPTIONAL
571
//        2.  resume(2a) +++OPTIONAL
572
//        2.  resume(3a) +++OPTIONAL
573
//        2.  unlock scheduler
574
// 
575
//        1.  runs, lock mutex - thread 3 has it locked
576
//
577
//        2.  busy-waits a bit for thread 3 to come out of its delay() loop.
578
//            This must be a *busy*wait so that 3 can only run via the
579
//            inherited raised priority.
580
// 
581
//        [xa. all do the same: lock mutex,                ]
582
//        [xa. unlock mutex                                ]
583
//        [xa. set a flag "extras"[x] to say we are done.  ]
584
//        [xa. exit                                        ]
585
// 
586
// 
587
// 
588
// INHERIT
589
// -------
590
// 
591
//                 thread 3->prio := 5
592
// 
593
//        3.  runs,
594
//        3.  set a flag to say "3-ran",
595
//        3.  loop with a sleep(1) until "go-flag" is set.
596
//        3.  check "got it" is false,
597
//        3.  then unlock mutex,
598
// 
599
//                 thread 3->prio := 15
600
// 
601
//        1.  runs, set a flag to say "got it",
602
//        1.  check "3-ended" flag is false
603
//        1.  unlock mutex,
604
//        1.  check "3-ended" flag is still false
605
//        1.  exit.
606
// 
607
//        [1a locks, unlocks, exits]
608
// 
609
//        2.  runs, check "3-ran" and "got it" flags are TRUE ****
610
//        2.  check "3-ended" flag is false
611
//        2.  sleeps for a while so that...
612
// 
613
//        [2a locks, unlocks, exits]
614
//            
615
//        3.  runs, set "3-ended" flag,
616
//        3.  check "3-ran" and "got it" flags
617
//        3.  exit
618
// 
619
//        [3a locks, unlocks, exits]
620
// 
621
//        2.  awakens, checks all flags true,
622
//        2.  check that all "extra" threads that we started have indeed run
623
//        2.  end of test.
624
// 
625
// 
626
// 
627
// 
628
// NO-INHERIT
629
// ----------
630
//                 thread 1 is waiting on the mutex
631
// 
632
//        [1a lock-fail]
633
// 
634
//        2.  runs, checks that "3-ran" and "got it" flags are FALSE ****
635
//        2.  check "3-ended" flag is false
636
//        2.  sleeps for a while so that...
637
// 
638
//        [2a. lock-fail]
639
//            
640
//        3.  runs, set a flag to say "3-ran",
641
//        3.  check "got it" is false,
642
//        3.  then unlock mutex,
643
// 
644
//        1.  runs, set a flag to say "got it",
645
//        1.  check "3-ended" flag is false
646
//        1.  unlock mutex,
647
//        1.  check "3-ended" flag is still false
648
//        1.  exit.
649
// 
650
//        [1a locks, unlocks, exits]
651
//        [2a locks, unlocks, exits]
652
// 
653
//        3.  runs, set "3-ended" flag,
654
//        3.  check "3-ran" and "got it" flags
655
//        3.  exit
656
// 
657
//        [3a locks, unlocks, exits]
658
//                
659
//        2.  awakens, checks all flags true, 
660
//        2.  check that all "extra" threads that we started have indeed run
661
//        2.  end of test.
662
// 
663
// 
664
// (the end)
665
// 
666
// 
667
// ------------------------------------------------------------------------
668
 
669
#endif
670
 
671
// EOF pmutex3.c

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.