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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [kernel/] [v2_0/] [tests/] [mutex3.cxx] - Blame information for rev 27

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

Line No. Rev Author Line
1 27 unneback
//==========================================================================
2
//
3
//        mutex3.cxx
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 Red Hat, 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 version.
16
//
17
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
18
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
19
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
20
// for more details.
21
//
22
// You should have received a copy of the GNU General Public License along
23
// with eCos; if not, write to the Free Software Foundation, Inc.,
24
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
25
//
26
// As a special exception, if other files instantiate templates or use macros
27
// or inline functions from this file, or you compile this file and link it
28
// with other works to produce a work based on this file, this file does not
29
// by itself cause the resulting work to be covered by the GNU General Public
30
// License. However the source code for this file must still be made available
31
// in accordance with section (3) of the GNU General Public License.
32
//
33
// This exception does not invalidate any other reasons why a work based on
34
// this file might be covered by the GNU General Public License.
35
//
36
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
37
// at http://sources.redhat.com/ecos/ecos-license/
38
// -------------------------------------------
39
//####ECOSGPLCOPYRIGHTEND####
40
//==========================================================================
41
//#####DESCRIPTIONBEGIN####
42
//
43
// Author(s):     hmt
44
// Contributors:  hmt
45
// Date:          2000-01-06
46
// Description:   Tests mutex priority inheritance
47
//####DESCRIPTIONEND####
48
 
49
#include <pkgconf/hal.h>
50
#include <pkgconf/kernel.h>
51
 
52
#include <cyg/kernel/sched.hxx>        // Cyg_Scheduler::start()
53
#include <cyg/kernel/thread.hxx>       // Cyg_Thread
54
 
55
#include <cyg/kernel/mutex.hxx>
56
 
57
#include <cyg/infra/testcase.h>
58
 
59
#include <cyg/kernel/sched.inl>
60
#include <cyg/kernel/thread.inl>
61
 
62
#include <cyg/infra/diag.h>             // diag_printf
63
 
64
#ifdef CYGSEM_HAL_STOP_CONSTRUCTORS_ON_FLAG
65
externC void
66
cyg_hal_invoke_constructors();
67
#endif
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
#if defined(CYGVAR_KERNEL_COUNTERS_CLOCK) &&    \
76
    (CYGNUM_KERNEL_SCHED_PRIORITIES > 20) &&    \
77
    !defined(CYGPKG_KERNEL_SMP_SUPPORT)
78
 
79
// ------------------------------------------------------------------------
80
// Manufacture a simpler feature test macro for priority inheritance than
81
// the configuration gives us. We have priority inheritance if it is configured
82
// as the only protocol, or if it is the default protocol for dynamic protocol
83
// choice.
84
// FIXME: If we have dynamic protocol choice, we can also set priority inheritance
85
// as the protocol to be used on the mutexes we are interested in. At present we
86
// do not do this.
87
 
88
#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_INHERIT
89
# ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DYNAMIC
90
#  ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DEFAULT_INHERIT
91
#   define PRIORITY_INHERITANCE "dynamic-default-inherit"
92
#  endif
93
# else
94
#  define PRIORITY_INHERITANCE "static-inherit"
95
# endif
96
#endif
97
 
98
#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_CEILING
99
# ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DYNAMIC
100
#  ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DEFAULT_CEILING
101
#   if CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DEFAULT_PRIORITY <= 5
102
#    define PRIORITY_INHERITANCE "dynamic-default-ceiling-high"
103
#   elif CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DEFAULT_PRIORITY >= 15
104
#    define NO_PRIORITY_INHERITANCE "dynamic-default-ceiling-low"
105
#   else
106
#    define PRIORITY_UNKNOWN "dynamic-default-ceiling-mid"
107
#   endif
108
#  endif
109
# else
110
#  if CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DEFAULT_PRIORITY <= 5
111
#   define PRIORITY_INHERITANCE "static-ceiling-high"
112
#  elif CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DEFAULT_PRIORITY >= 15
113
#   define NO_PRIORITY_INHERITANCE "static-ceiling-low"
114
#  else
115
#   define PRIORITY_UNKNOWN "static-ceiling-mid"
116
#  endif
117
# endif
118
#endif
119
 
120
#ifndef PRIORITY_INHERITANCE
121
# ifndef NO_PRIORITY_INHERITANCE
122
#  define NO_PRIORITY_INHERITANCE "no scheme selected"
123
# endif
124
#endif
125
 
126
// ------------------------------------------------------------------------
127
// Management functions
128
//
129
// Stolen from testaux.hxx and copied in here because I want to be able to
130
// reset the world also.
131
 
132
#define NTHREADS 7
133
 
134
static inline void *operator new(size_t size, void *ptr) { return ptr; };
135
 
136
#define STACKSIZE CYGNUM_HAL_STACK_SIZE_TYPICAL
137
 
138
static Cyg_Thread *thread[NTHREADS] = { 0 };
139
 
140
typedef CYG_WORD64 CYG_ALIGNMENT_TYPE;
141
 
142
static CYG_ALIGNMENT_TYPE thread_obj[NTHREADS] [
143
   (sizeof(Cyg_Thread)+sizeof(CYG_ALIGNMENT_TYPE)-1)
144
     / sizeof(CYG_ALIGNMENT_TYPE)                     ];
145
 
146
static CYG_ALIGNMENT_TYPE stack[NTHREADS] [
147
   (STACKSIZE+sizeof(CYG_ALIGNMENT_TYPE)-1)
148
     / sizeof(CYG_ALIGNMENT_TYPE)                     ];
149
 
150
static volatile int nthreads = 0;
151
 
152
static Cyg_Thread *new_thread( cyg_thread_entry *entry,
153
                               CYG_ADDRWORD data,
154
                               CYG_ADDRWORD priority,
155
                               int do_resume )
156
{
157
    int _nthreads = nthreads++;
158
 
159
    CYG_ASSERT(_nthreads < NTHREADS,
160
               "Attempt to create more than NTHREADS threads");
161
 
162
    thread[_nthreads] = new( (void *)&thread_obj[_nthreads] )
163
        Cyg_Thread(priority,
164
                   entry, data,
165
                   NULL,                // no name
166
                   (CYG_ADDRESS)stack[_nthreads], STACKSIZE );
167
 
168
    if ( do_resume )
169
        thread[_nthreads]->resume();
170
 
171
    return thread[_nthreads];
172
}
173
 
174
 
175
static void kill_threads( void )
176
{
177
    CYG_ASSERT(nthreads <= NTHREADS,
178
               "More than NTHREADS threads");
179
    CYG_ASSERT( Cyg_Thread::self() == thread[0],
180
                "kill_threads() not called from thread 0");
181
    while ( nthreads > 1 ) {
182
        nthreads--;
183
        if ( NULL != thread[nthreads] ) {
184
            thread[nthreads]->kill();
185
            thread[nthreads]->~Cyg_Thread();
186
            thread[nthreads] = NULL;
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
static Cyg_Mutex 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( CYG_ADDRWORD data )
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
    XINFO( running );
225
 
226
    Cyg_Thread *self = Cyg_Thread::self();
227
 
228
    self->suspend();
229
 
230
    XINFO( resumed );
231
 
232
    mutex.lock();
233
 
234
    XINFO( locked );
235
 
236
    mutex.unlock();
237
 
238
    XINFO( unlocked );
239
 
240
    extras[ data ] ++;
241
 
242
    XINFO( exiting );
243
 
244
}
245
 
246
// ------------------------------------------------------------------------
247
 
248
static void t1( CYG_ADDRWORD data )
249
{
250
    Cyg_Thread *self = Cyg_Thread::self();
251
 
252
    CYG_TEST_INFO( "Thread 1 running" );
253
 
254
    self->suspend();
255
 
256
    mutex.lock();
257
 
258
    got_it++;
259
 
260
    CYG_TEST_CHECK( 0 == t3ended, "T3 ended prematurely [T1,1]" );
261
 
262
    mutex.unlock();
263
 
264
    CYG_TEST_CHECK( 0 == t3ended, "T3 ended prematurely [T1,2]" );
265
 
266
    // That's all.
267
 
268
    CYG_TEST_INFO( "Thread 1 exit" );
269
}
270
 
271
// ------------------------------------------------------------------------
272
 
273
static void t2( CYG_ADDRWORD data )
274
{
275
    Cyg_Thread *self = Cyg_Thread::self();
276
    int i;
277
    cyg_tick_count then, now;
278
 
279
 
280
    CYG_TEST_INFO( "Thread 2 running" );
281
 
282
    CYG_TEST_CHECK( 0 == (data & ~0x77), "Bad T2 arg: extra bits" );
283
    CYG_TEST_CHECK( 0 == (data & (data >> 4)), "Bad T2 arg: overlap" );
284
 
285
    self->suspend();
286
 
287
    // depending on our config argument, optionally restart some of the
288
    // extra threads to throw noise into the scheduler:
289
    for ( i = 0; i < 3; i++ )
290
        if ( (1 << i) & data )          // bits 0-2 control
291
            thread[i+4]->resume();      // made sure extras are thread[4-6]
292
 
293
    self->delay( DELAYFACTOR * 10 );    // let those threads run
294
 
295
    Cyg_Scheduler::lock();              // do this next lot atomically
296
 
297
    go_flag = 1;                        // unleash thread 3
298
    thread[1]->resume();                // resume thread 1
299
 
300
    // depending on our config argument, optionally restart some of the
301
    // extra threads to throw noise into the scheduler at this later point:
302
    for ( i = 4; i < 7; i++ )
303
        if ( (1 << i) & data )          // bits 4-6 control
304
            thread[i]->resume();        // made sure extras are thread[4-6]
305
 
306
    Cyg_Scheduler::unlock();           // let scheduling proceed
307
 
308
    // Need a delay (but not a CPU yield) to allow t3 to awaken and act on
309
    // the go_flag, otherwise we check these details below too soon.
310
    // Actually, waiting for the clock to tick a couple of times would be
311
    // better, so that is what we will do.  Must be a busy-wait.
312
    then = Cyg_Clock::real_time_clock->current_value();
313
    do {
314
        now = Cyg_Clock::real_time_clock->current_value();
315
        // Wait longer than the delay in t3 waiting on go_flag
316
    } while ( now < (then + 3) );
317
 
318
#ifdef PRIORITY_UNKNOWN
319
    CYG_TEST_INFO( "Not checking: " PRIORITY_UNKNOWN );
320
#else
321
#ifdef PRIORITY_INHERITANCE
322
    CYG_TEST_INFO( "Checking priority scheme: " PRIORITY_INHERITANCE );
323
    CYG_TEST_CHECK( 1 == t3ran, "Thread 3 did not run" );
324
    CYG_TEST_CHECK( 1 == got_it, "Thread 1 did not get the mutex" );
325
#else
326
    CYG_TEST_INFO( "Checking NO priority scheme: " NO_PRIORITY_INHERITANCE );
327
    CYG_TEST_CHECK( 0 == t3ran, "Thread 3 DID run" );
328
    CYG_TEST_CHECK( 0 == got_it, "Thread 1 DID get the mutex" );
329
#endif
330
#endif
331
 
332
    CYG_TEST_CHECK( 0 == t3ended, "Thread 3 ended prematurely [T2,1]" );
333
 
334
    self->delay( DELAYFACTOR * 20 );    // let those threads run
335
 
336
    CYG_TEST_CHECK( 1 == t3ran, "Thread 3 did not run" );
337
    CYG_TEST_CHECK( 1 == got_it, "Thread 1 did not get the mutex" );
338
    CYG_TEST_CHECK( 1 == t3ended, "Thread 3 has not ended" );
339
 
340
    for ( i = 0; i < 3; i++ )
341
        if ( (1 << i) & (data | data >> 4) ) // bits 0-2 and 4-6 control
342
            CYG_TEST_CHECK( 1 == extras[i+1], "Extra thread did not run" );
343
        else
344
            CYG_TEST_CHECK( 0 == extras[i+1], "Extra thread ran" );
345
 
346
    CYG_TEST_PASS( "Thread 2 exiting, AOK" );
347
    // That's all: restart the control thread.
348
    thread[0]->resume();
349
}
350
 
351
// ------------------------------------------------------------------------
352
 
353
static void t3( CYG_ADDRWORD data )
354
{
355
    Cyg_Thread *self = Cyg_Thread::self();
356
 
357
    CYG_TEST_INFO( "Thread 3 running" );
358
 
359
    mutex.lock();
360
 
361
    self->delay( DELAYFACTOR * 5 );    // let thread 3a run
362
 
363
    thread[2]->resume();                // resume thread 2
364
 
365
    while ( 0 == go_flag )
366
        self->delay(1);                 // wait until we are told to go
367
 
368
    t3ran ++;                           // record the fact
369
 
370
    CYG_TEST_CHECK( 0 == got_it, "Thread 1 claims to have got my mutex" );
371
 
372
    mutex.unlock();
373
 
374
    t3ended ++;                         // record that we came back
375
 
376
    CYG_TEST_CHECK( 1 == got_it, "Thread 1 did not get the mutex" );
377
 
378
    CYG_TEST_INFO( "Thread 3 exit" );
379
}
380
 
381
// ------------------------------------------------------------------------
382
 
383
static void control_thread( CYG_ADDRWORD data )
384
{
385
    Cyg_Thread *self = Cyg_Thread::self();
386
    int i;
387
 
388
    CYG_TEST_INIT();
389
    CYG_TEST_INFO( "Control Thread running" );
390
 
391
    // Go through the 27 possibilitied of resuming the extra threads
392
    //     0: not at all
393
    //     1: early in the process
394
    //     2: later on
395
    // which are represented by bits 0-3 and 4-6 resp in the argument to
396
    // thread 2 (none set means no resume at all).
397
    for ( i = 0; i < 27; i++ ) {
398
        static int xx[] = { 0, 1, 16 };
399
        int j = i % 3;
400
        int k = (i / 3) % 3;
401
        int l = (i / 9) % 3;
402
 
403
        int d = xx[j] | (xx[k]<<1) | (xx[l]<<2) ;
404
 
405
        if ( cyg_test_is_simulator && (0 != i && 13 != i && 26 != i) )
406
            continue;    // 13 is 111 base 3, 26 is 222 base 3
407
 
408
#ifdef PRIORITY_INHERITANCE
409
        // If the simple scheme plus relay enhancement, or any other
410
        // *complete* scheme, we can run all three ancillary threads no
411
        // problem, so no special action here.
412
 
413
#else
414
        // If no priority inheritance at all, running threads 1a and 2a is
415
        // OK, but not thread 3a; it blocks the world.
416
        if ( l )                        // Cannot run thread 3a if no
417
            break;                      //     priority inheritance at all.
418
#endif
419
 
420
        mutex = Cyg_Mutex();            // Reinitialize this
421
 
422
        got_it  = 0;
423
        t3ran   = 0;
424
        t3ended = 0;
425
        for ( int z = 0; z < 4; z++ ) extras[z] = 0;
426
        go_flag = 0;
427
 
428
        new_thread( t1, 0,  5, 1 );            // Slot 1
429
        new_thread( t2, d, 10, 1 );            // Slot 2
430
        new_thread( t3, 0, 15, 1 );            // Slot 3
431
 
432
        new_thread( extra_thread, 1,  8, j );  // Slot 4
433
        new_thread( extra_thread, 2, 12, k );  // Slot 5
434
        new_thread( extra_thread, 3, 17, l );  // Slot 6
435
 
436
        {
437
            static char *a[] = { "inactive", "run early", "run late" };
438
            diag_printf( "\n----- [%2d] New Cycle: 0x%02x, Threads 1a %s, 2a %s, 3a %s -----\n",
439
                         i, d,  a[j], a[k], a[l] );
440
        }
441
 
442
        self->suspend();
443
 
444
        kill_threads();
445
        mutex.~Cyg_Mutex();
446
    }
447
    CYG_TEST_EXIT( "Control Thread exit" );
448
}
449
 
450
// ------------------------------------------------------------------------
451
 
452
externC void
453
cyg_user_start( void )
454
{
455
#ifdef CYGSEM_HAL_STOP_CONSTRUCTORS_ON_FLAG
456
    cyg_hal_invoke_constructors();
457
#endif
458
    new_thread( control_thread, 0, 2, 1 );
459
}
460
 
461
#else // CYGVAR_KERNEL_COUNTERS_CLOCK &c
462
 
463
externC void
464
cyg_start( void )
465
{
466
    CYG_TEST_INIT();
467
    CYG_TEST_PASS_FINISH("Mutex3 test requires:\n"
468
                         "CYGVAR_KERNEL_COUNTERS_CLOCK &&\n"
469
                         "(CYGNUM_KERNEL_SCHED_PRIORITIES > 20) &&\n"
470
                         "!defined(CYGPKG_KERNEL_SMP_SUPPORT)\n");
471
}
472
#endif // CYGVAR_KERNEL_COUNTERS_CLOCK &c
473
 
474
 
475
// ------------------------------------------------------------------------
476
// Documentation: enclosed is the design of this test.
477
//
478
// It has been carefully constructed so that it does NOT use other kernel
479
// facilities (aside from delay-task) to test that priority inheritance is
480
// working, or not, as intended by the configuration.
481
//
482
// These notes describe the flow of control in one run of the test with the
483
// ancillary tasks optionally interspersed.  The details of how those extra
484
// tasks are or are not allowed to run are not described.
485
// 
486
// 
487
// 
488
// The only change in the test that depends on whether there is inheritance or
489
// not is the check in thread 2 on "3-ran" and "got it" flags marked ****
490
// 
491
// 
492
// volatile &c booleans:
493
//         "got it"     = FALSE
494
//         "3-ran"      = FALSE
495
//         "3-ended"    = FALSE
496
//         "extras"[3]  = FALSE
497
// 
498
// thread 1.  prio 5, self-suspend.
499
// 
500
// thread 1a, prio 8, self-suspend.
501
// 
502
// thread 2.  prio 10, self-suspend.
503
// 
504
// thread 2a, prio 12, self-suspend.
505
// 
506
// thread 3.  prio 15, runs, lock mutex, resume(2)
507
// 
508
// thread 3a, prio 17, self-suspend.
509
// 
510
//        2.  runs,
511
//        2.  resume(3a) +++OPTIONAL
512
//        2.  resume(2a) +++OPTIONAL
513
//        2.  resume(1a) +++OPTIONAL
514
//        [1a lock-fail]        thread 3->prio := 8
515
// 
516
//        [3. runs maybe, does the looping thing]
517
// 
518
//        2.  sleep a while...
519
// 
520
//        [2a lock-fail]        thread 3->prio := 12
521
// 
522
//        [3. runs maybe, does the looping thing]
523
// 
524
//        [3a lock-fail]   thread 3->prio unchanged
525
// 
526
//        [3. runs maybe, does the looping thing]
527
// 
528
//        2.  lock scheduler
529
//        2.  set "go-flag"
530
//        2.  resume(1)
531
//        2.  resume(1a) +++OPTIONAL
532
//        2.  resume(2a) +++OPTIONAL
533
//        2.  resume(3a) +++OPTIONAL
534
//        2.  unlock scheduler
535
// 
536
//        1.  runs, lock mutex - thread 3 has it locked
537
//
538
//        2.  busy-waits a bit for thread 3 to come out of its delay() loop.
539
//            This must be a *busy*wait so that 3 can only run via the
540
//            inherited raised priority.
541
// 
542
//        [xa. all do the same: lock mutex,                ]
543
//        [xa. unlock mutex                                ]
544
//        [xa. set a flag "extras"[x] to say we are done.  ]
545
//        [xa. exit                                        ]
546
// 
547
// 
548
// 
549
// INHERIT
550
// -------
551
// 
552
//                 thread 3->prio := 5
553
// 
554
//        3.  runs,
555
//        3.  set a flag to say "3-ran",
556
//        3.  loop with a sleep(1) until "go-flag" is set.
557
//        3.  check "got it" is false,
558
//        3.  then unlock mutex,
559
// 
560
//                 thread 3->prio := 15
561
// 
562
//        1.  runs, set a flag to say "got it",
563
//        1.  check "3-ended" flag is false
564
//        1.  unlock mutex,
565
//        1.  check "3-ended" flag is still false
566
//        1.  exit.
567
// 
568
//        [1a locks, unlocks, exits]
569
// 
570
//        2.  runs, check "3-ran" and "got it" flags are TRUE ****
571
//        2.  check "3-ended" flag is false
572
//        2.  sleeps for a while so that...
573
// 
574
//        [2a locks, unlocks, exits]
575
//            
576
//        3.  runs, set "3-ended" flag,
577
//        3.  check "3-ran" and "got it" flags
578
//        3.  exit
579
// 
580
//        [3a locks, unlocks, exits]
581
// 
582
//        2.  awakens, checks all flags true,
583
//        2.  check that all "extra" threads that we started have indeed run
584
//        2.  end of test.
585
// 
586
// 
587
// 
588
// 
589
// NO-INHERIT
590
// ----------
591
//                 thread 1 is waiting on the mutex
592
// 
593
//        [1a lock-fail]
594
// 
595
//        2.  runs, checks that "3-ran" and "got it" flags are FALSE ****
596
//        2.  check "3-ended" flag is false
597
//        2.  sleeps for a while so that...
598
// 
599
//        [2a. lock-fail]
600
//            
601
//        3.  runs, set a flag to say "3-ran",
602
//        3.  check "got it" is false,
603
//        3.  then unlock mutex,
604
// 
605
//        1.  runs, set a flag to say "got it",
606
//        1.  check "3-ended" flag is false
607
//        1.  unlock mutex,
608
//        1.  check "3-ended" flag is still false
609
//        1.  exit.
610
// 
611
//        [1a locks, unlocks, exits]
612
//        [2a locks, unlocks, exits]
613
// 
614
//        3.  runs, set "3-ended" flag,
615
//        3.  check "3-ran" and "got it" flags
616
//        3.  exit
617
// 
618
//        [3a locks, unlocks, exits]
619
//                
620
//        2.  awakens, checks all flags true, 
621
//        2.  check that all "extra" threads that we started have indeed run
622
//        2.  end of test.
623
// 
624
// 
625
// (the end)
626
// 
627
// 
628
// ------------------------------------------------------------------------
629
 
630
// EOF mutex3.cxx

powered by: WebSVN 2.1.0

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