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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [kernel/] [current/] [tests/] [mutex3.cxx] - Blame information for rev 842

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

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
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 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
44
// Date:          2000-01-06
45
// Description:   Tests mutex priority inheritance
46
//####DESCRIPTIONEND####
47
 
48
#include <pkgconf/hal.h>
49
#include <pkgconf/kernel.h>
50
 
51
#include <cyg/kernel/sched.hxx>        // Cyg_Scheduler::start()
52
#include <cyg/kernel/thread.hxx>       // Cyg_Thread
53
 
54
#include <cyg/kernel/mutex.hxx>
55
 
56
#include <cyg/infra/testcase.h>
57
 
58
#include <cyg/kernel/sched.inl>
59
#include <cyg/kernel/thread.inl>
60
 
61
#include <cyg/infra/diag.h>             // diag_printf
62
#include CYGHWR_MEMORY_LAYOUT_H
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
#if (CYGMEM_REGION_ram_SIZE <= 32768)
133
# define NTHREADS 5
134
#else
135
# define NTHREADS 7
136
#endif
137
 
138
inline void *operator new(size_t size, void *ptr) { return ptr; };
139
 
140
#define STACKSIZE CYGNUM_HAL_STACK_SIZE_TYPICAL
141
 
142
static Cyg_Thread *thread[NTHREADS] = { 0 };
143
 
144
typedef CYG_WORD64 CYG_ALIGNMENT_TYPE;
145
 
146
static CYG_ALIGNMENT_TYPE thread_obj[NTHREADS] [
147
   (sizeof(Cyg_Thread)+sizeof(CYG_ALIGNMENT_TYPE)-1)
148
     / sizeof(CYG_ALIGNMENT_TYPE)                     ];
149
 
150
static CYG_ALIGNMENT_TYPE stack[NTHREADS] [
151
   (STACKSIZE+sizeof(CYG_ALIGNMENT_TYPE)-1)
152
     / sizeof(CYG_ALIGNMENT_TYPE)                     ];
153
 
154
static volatile int nthreads = 0;
155
 
156
static Cyg_Thread *new_thread( cyg_thread_entry *entry,
157
                               CYG_ADDRWORD data,
158
                               CYG_ADDRWORD priority,
159
                               int do_resume )
160
{
161
    int _nthreads = nthreads++;
162
 
163
    CYG_ASSERT(_nthreads < NTHREADS,
164
               "Attempt to create more than NTHREADS threads");
165
 
166
    thread[_nthreads] = new( (void *)&thread_obj[_nthreads] )
167
        Cyg_Thread(priority,
168
                   entry, data,
169
                   NULL,                // no name
170
                   (CYG_ADDRESS)stack[_nthreads], STACKSIZE );
171
 
172
    if ( do_resume )
173
        thread[_nthreads]->resume();
174
 
175
    return thread[_nthreads];
176
}
177
 
178
 
179
static void kill_threads( void )
180
{
181
    CYG_ASSERT(nthreads <= NTHREADS,
182
               "More than NTHREADS threads");
183
    CYG_ASSERT( Cyg_Thread::self() == thread[0],
184
                "kill_threads() not called from thread 0");
185
    while ( nthreads > 1 ) {
186
        nthreads--;
187
        if ( NULL != thread[nthreads] ) {
188
            thread[nthreads]->kill();
189
            thread[nthreads]->~Cyg_Thread();
190
            thread[nthreads] = NULL;
191
        }
192
    }
193
    CYG_ASSERT(nthreads == 1,
194
               "No threads left");
195
}
196
 
197
// ------------------------------------------------------------------------
198
 
199
#define DELAYFACTOR 1 // for debugging
200
 
201
// ------------------------------------------------------------------------
202
 
203
static Cyg_Mutex mutex;
204
 
205
// These are for reporting back to the master thread
206
volatile int got_it  = 0;
207
volatile int t3ran   = 0;
208
volatile int t3ended = 0;
209
volatile int extras[4] = {0,0,0,0};
210
 
211
volatile int go_flag = 0; // but this one controls thread 3 from thread 2
212
 
213
// ------------------------------------------------------------------------
214
// 0 to 3 of these run generally to interfere with the other processing,
215
// to cause multiple prio inheritances, and clashes in any orders.
216
 
217
static void extra_thread( CYG_ADDRWORD data )
218
{
219
#define XINFO( z ) \
220
    do { z[13] = '0' + data; CYG_TEST_INFO( z ); } while ( 0 )
221
 
222
    static char running[]  = "Extra thread Xa running";
223
    static char exiting[]  = "Extra thread Xa exiting";
224
    static char resumed[]  = "Extra thread Xa resumed";
225
    static char locked[]   = "Extra thread Xa locked";
226
    static char unlocked[] = "Extra thread Xa unlocked";
227
 
228
    XINFO( running );
229
 
230
    Cyg_Thread *self = Cyg_Thread::self();
231
 
232
    self->suspend();
233
 
234
    XINFO( resumed );
235
 
236
    mutex.lock();
237
 
238
    XINFO( locked );
239
 
240
    mutex.unlock();
241
 
242
    XINFO( unlocked );
243
 
244
    extras[ data ] ++;
245
 
246
    XINFO( exiting );
247
 
248
}
249
 
250
// ------------------------------------------------------------------------
251
 
252
static void t1( CYG_ADDRWORD data )
253
{
254
    Cyg_Thread *self = Cyg_Thread::self();
255
 
256
    CYG_TEST_INFO( "Thread 1 running" );
257
 
258
    self->suspend();
259
 
260
    mutex.lock();
261
 
262
    got_it++;
263
 
264
    CYG_TEST_CHECK( 0 == t3ended, "T3 ended prematurely [T1,1]" );
265
 
266
    mutex.unlock();
267
 
268
    CYG_TEST_CHECK( 0 == t3ended, "T3 ended prematurely [T1,2]" );
269
 
270
    // That's all.
271
 
272
    CYG_TEST_INFO( "Thread 1 exit" );
273
}
274
 
275
// ------------------------------------------------------------------------
276
 
277
static void t2( CYG_ADDRWORD data )
278
{
279
    Cyg_Thread *self = Cyg_Thread::self();
280
    int i;
281
    cyg_tick_count then, now;
282
 
283
 
284
    CYG_TEST_INFO( "Thread 2 running" );
285
 
286
    CYG_TEST_CHECK( 0 == (data & ~0x77), "Bad T2 arg: extra bits" );
287
    CYG_TEST_CHECK( 0 == (data & (data >> 4)), "Bad T2 arg: overlap" );
288
 
289
    self->suspend();
290
 
291
    // depending on our config argument, optionally restart some of the
292
    // extra threads to throw noise into the scheduler:
293
    for ( i = 0; i < 3; i++ )
294
        if ( (1 << i) & data )          // bits 0-2 control
295
            thread[i+4]->resume();      // made sure extras are thread[4-6]
296
 
297
    self->delay( DELAYFACTOR * 10 );    // let those threads run
298
 
299
    Cyg_Scheduler::lock();              // do this next lot atomically
300
 
301
    go_flag = 1;                        // unleash thread 3
302
    thread[1]->resume();                // resume thread 1
303
 
304
    // depending on our config argument, optionally restart some of the
305
    // extra threads to throw noise into the scheduler at this later point:
306
    for ( i = 4; i < 7; i++ )
307
        if ( (1 << i) & data )          // bits 4-6 control
308
            thread[i]->resume();        // made sure extras are thread[4-6]
309
 
310
    Cyg_Scheduler::unlock();           // let scheduling proceed
311
 
312
    // Need a delay (but not a CPU yield) to allow t3 to awaken and act on
313
    // the go_flag, otherwise we check these details below too soon.
314
    // Actually, waiting for the clock to tick a couple of times would be
315
    // better, so that is what we will do.  Must be a busy-wait.
316
    then = Cyg_Clock::real_time_clock->current_value();
317
    do {
318
        now = Cyg_Clock::real_time_clock->current_value();
319
        // Wait longer than the delay in t3 waiting on go_flag
320
    } while ( now < (then + 3) );
321
 
322
#ifdef PRIORITY_UNKNOWN
323
    CYG_TEST_INFO( "Not checking: " PRIORITY_UNKNOWN );
324
#else
325
#ifdef PRIORITY_INHERITANCE
326
    CYG_TEST_INFO( "Checking priority scheme: " PRIORITY_INHERITANCE );
327
    CYG_TEST_CHECK( 1 == t3ran, "Thread 3 did not run" );
328
    CYG_TEST_CHECK( 1 == got_it, "Thread 1 did not get the mutex" );
329
#else
330
    CYG_TEST_INFO( "Checking NO priority scheme: " NO_PRIORITY_INHERITANCE );
331
    CYG_TEST_CHECK( 0 == t3ran, "Thread 3 DID run" );
332
    CYG_TEST_CHECK( 0 == got_it, "Thread 1 DID get the mutex" );
333
#endif
334
#endif
335
 
336
    CYG_TEST_CHECK( 0 == t3ended, "Thread 3 ended prematurely [T2,1]" );
337
 
338
    self->delay( DELAYFACTOR * 20 );    // let those threads run
339
 
340
    CYG_TEST_CHECK( 1 == t3ran, "Thread 3 did not run" );
341
    CYG_TEST_CHECK( 1 == got_it, "Thread 1 did not get the mutex" );
342
    CYG_TEST_CHECK( 1 == t3ended, "Thread 3 has not ended" );
343
 
344
    for ( i = 0; i < 3; i++ )
345
        if ( (1 << i) & (data | data >> 4) ) // bits 0-2 and 4-6 control
346
            CYG_TEST_CHECK( 1 == extras[i+1], "Extra thread did not run" );
347
        else
348
            CYG_TEST_CHECK( 0 == extras[i+1], "Extra thread ran" );
349
 
350
    CYG_TEST_PASS( "Thread 2 exiting, AOK" );
351
    // That's all: restart the control thread.
352
    thread[0]->resume();
353
}
354
 
355
// ------------------------------------------------------------------------
356
 
357
static void t3( CYG_ADDRWORD data )
358
{
359
    Cyg_Thread *self = Cyg_Thread::self();
360
 
361
    CYG_TEST_INFO( "Thread 3 running" );
362
 
363
    mutex.lock();
364
 
365
    self->delay( DELAYFACTOR * 5 );    // let thread 3a run
366
 
367
    thread[2]->resume();                // resume thread 2
368
 
369
    while ( 0 == go_flag )
370
        self->delay(1);                 // wait until we are told to go
371
 
372
    t3ran ++;                           // record the fact
373
 
374
    CYG_TEST_CHECK( 0 == got_it, "Thread 1 claims to have got my mutex" );
375
 
376
    mutex.unlock();
377
 
378
    t3ended ++;                         // record that we came back
379
 
380
    CYG_TEST_CHECK( 1 == got_it, "Thread 1 did not get the mutex" );
381
 
382
    CYG_TEST_INFO( "Thread 3 exit" );
383
}
384
 
385
// ------------------------------------------------------------------------
386
 
387
static void control_thread( CYG_ADDRWORD data )
388
{
389
    Cyg_Thread *self = Cyg_Thread::self();
390
    int i;
391
 
392
    CYG_TEST_INIT();
393
    CYG_TEST_INFO( "Control Thread running" );
394
 
395
    // Go through the 27 possibilitied of resuming the extra threads
396
    //     0: not at all
397
    //     1: early in the process
398
    //     2: later on
399
    // which are represented by bits 0-3 and 4-6 resp in the argument to
400
    // thread 2 (none set means no resume at all).
401
    for ( i = 0; i < 27; i++ ) {
402
        static int xx[] = { 0, 1, 16 };
403
        int j = i % 3;
404
        int k = (i / 3) % 3;
405
        int l = (i / 9) % 3;
406
 
407
        int d = xx[j] | (xx[k]<<1) | (xx[l]<<2) ;
408
 
409
        if ( cyg_test_is_simulator && (0 != i && 13 != i && 26 != i) )
410
            continue;    // 13 is 111 base 3, 26 is 222 base 3
411
 
412
#ifdef PRIORITY_INHERITANCE
413
        // If the simple scheme plus relay enhancement, or any other
414
        // *complete* scheme, we can run all three ancillary threads no
415
        // problem, so no special action here.
416
 
417
#else
418
        // If no priority inheritance at all, running threads 1a and 2a is
419
        // OK, but not thread 3a; it blocks the world.
420
        if ( l )                        // Cannot run thread 3a if no
421
            break;                      //     priority inheritance at all.
422
#endif
423
 
424
        mutex = Cyg_Mutex();            // Reinitialize this
425
 
426
        got_it  = 0;
427
        t3ran   = 0;
428
        t3ended = 0;
429
        for ( int z = 0; z < 4; z++ ) extras[z] = 0;
430
        go_flag = 0;
431
 
432
        new_thread( t1, 0,  5, 1 );            // Slot 1
433
        new_thread( t2, d, 10, 1 );            // Slot 2
434
        new_thread( t3, 0, 15, 1 );            // Slot 3
435
 
436
        new_thread( extra_thread, 1,  8, j );  // Slot 4
437
        new_thread( extra_thread, 2, 12, k );  // Slot 5
438
        new_thread( extra_thread, 3, 17, l );  // Slot 6
439
 
440
        {
441
            static char *a[] = { "inactive", "run early", "run late" };
442
            diag_printf( "\n----- [%2d] New Cycle: 0x%02x, Threads 1a %s, 2a %s, 3a %s -----\n",
443
                         i, d,  a[j], a[k], a[l] );
444
        }
445
 
446
        self->suspend();
447
 
448
        kill_threads();
449
        mutex.~Cyg_Mutex();
450
    }
451
    CYG_TEST_EXIT( "Control Thread exit" );
452
}
453
 
454
// ------------------------------------------------------------------------
455
 
456
externC void
457
cyg_user_start( void )
458
{
459
#ifdef CYGSEM_HAL_STOP_CONSTRUCTORS_ON_FLAG
460
    cyg_hal_invoke_constructors();
461
#endif
462
    new_thread( control_thread, 0, 2, 1 );
463
}
464
 
465
#else // CYGVAR_KERNEL_COUNTERS_CLOCK &c
466
 
467
externC void
468
cyg_start( void )
469
{
470
    CYG_TEST_INIT();
471
    CYG_TEST_INFO("Mutex3 test requires:\n"
472
                         "CYGVAR_KERNEL_COUNTERS_CLOCK &&\n"
473
                         "(CYGNUM_KERNEL_SCHED_PRIORITIES > 20) &&\n"
474
                         "!defined(CYGPKG_KERNEL_SMP_SUPPORT)\n");
475
    CYG_TEST_NA("Mutex3 test requirements");
476
}
477
#endif // CYGVAR_KERNEL_COUNTERS_CLOCK &c
478
 
479
 
480
// ------------------------------------------------------------------------
481
// Documentation: enclosed is the design of this test.
482
//
483
// It has been carefully constructed so that it does NOT use other kernel
484
// facilities (aside from delay-task) to test that priority inheritance is
485
// working, or not, as intended by the configuration.
486
//
487
// These notes describe the flow of control in one run of the test with the
488
// ancillary tasks optionally interspersed.  The details of how those extra
489
// tasks are or are not allowed to run are not described.
490
// 
491
// 
492
// 
493
// The only change in the test that depends on whether there is inheritance or
494
// not is the check in thread 2 on "3-ran" and "got it" flags marked ****
495
// 
496
// 
497
// volatile &c booleans:
498
//         "got it"     = FALSE
499
//         "3-ran"      = FALSE
500
//         "3-ended"    = FALSE
501
//         "extras"[3]  = FALSE
502
// 
503
// thread 1.  prio 5, self-suspend.
504
// 
505
// thread 1a, prio 8, self-suspend.
506
// 
507
// thread 2.  prio 10, self-suspend.
508
// 
509
// thread 2a, prio 12, self-suspend.
510
// 
511
// thread 3.  prio 15, runs, lock mutex, resume(2)
512
// 
513
// thread 3a, prio 17, self-suspend.
514
// 
515
//        2.  runs,
516
//        2.  resume(3a) +++OPTIONAL
517
//        2.  resume(2a) +++OPTIONAL
518
//        2.  resume(1a) +++OPTIONAL
519
//        [1a lock-fail]        thread 3->prio := 8
520
// 
521
//        [3. runs maybe, does the looping thing]
522
// 
523
//        2.  sleep a while...
524
// 
525
//        [2a lock-fail]        thread 3->prio := 12
526
// 
527
//        [3. runs maybe, does the looping thing]
528
// 
529
//        [3a lock-fail]   thread 3->prio unchanged
530
// 
531
//        [3. runs maybe, does the looping thing]
532
// 
533
//        2.  lock scheduler
534
//        2.  set "go-flag"
535
//        2.  resume(1)
536
//        2.  resume(1a) +++OPTIONAL
537
//        2.  resume(2a) +++OPTIONAL
538
//        2.  resume(3a) +++OPTIONAL
539
//        2.  unlock scheduler
540
// 
541
//        1.  runs, lock mutex - thread 3 has it locked
542
//
543
//        2.  busy-waits a bit for thread 3 to come out of its delay() loop.
544
//            This must be a *busy*wait so that 3 can only run via the
545
//            inherited raised priority.
546
// 
547
//        [xa. all do the same: lock mutex,                ]
548
//        [xa. unlock mutex                                ]
549
//        [xa. set a flag "extras"[x] to say we are done.  ]
550
//        [xa. exit                                        ]
551
// 
552
// 
553
// 
554
// INHERIT
555
// -------
556
// 
557
//                 thread 3->prio := 5
558
// 
559
//        3.  runs,
560
//        3.  set a flag to say "3-ran",
561
//        3.  loop with a sleep(1) until "go-flag" is set.
562
//        3.  check "got it" is false,
563
//        3.  then unlock mutex,
564
// 
565
//                 thread 3->prio := 15
566
// 
567
//        1.  runs, set a flag to say "got it",
568
//        1.  check "3-ended" flag is false
569
//        1.  unlock mutex,
570
//        1.  check "3-ended" flag is still false
571
//        1.  exit.
572
// 
573
//        [1a locks, unlocks, exits]
574
// 
575
//        2.  runs, check "3-ran" and "got it" flags are TRUE ****
576
//        2.  check "3-ended" flag is false
577
//        2.  sleeps for a while so that...
578
// 
579
//        [2a locks, unlocks, exits]
580
//            
581
//        3.  runs, set "3-ended" flag,
582
//        3.  check "3-ran" and "got it" flags
583
//        3.  exit
584
// 
585
//        [3a locks, unlocks, exits]
586
// 
587
//        2.  awakens, checks all flags true,
588
//        2.  check that all "extra" threads that we started have indeed run
589
//        2.  end of test.
590
// 
591
// 
592
// 
593
// 
594
// NO-INHERIT
595
// ----------
596
//                 thread 1 is waiting on the mutex
597
// 
598
//        [1a lock-fail]
599
// 
600
//        2.  runs, checks that "3-ran" and "got it" flags are FALSE ****
601
//        2.  check "3-ended" flag is false
602
//        2.  sleeps for a while so that...
603
// 
604
//        [2a. lock-fail]
605
//            
606
//        3.  runs, set a flag to say "3-ran",
607
//        3.  check "got it" is false,
608
//        3.  then unlock mutex,
609
// 
610
//        1.  runs, set a flag to say "got it",
611
//        1.  check "3-ended" flag is false
612
//        1.  unlock mutex,
613
//        1.  check "3-ended" flag is still false
614
//        1.  exit.
615
// 
616
//        [1a locks, unlocks, exits]
617
//        [2a locks, unlocks, exits]
618
// 
619
//        3.  runs, set "3-ended" flag,
620
//        3.  check "3-ran" and "got it" flags
621
//        3.  exit
622
// 
623
//        [3a locks, unlocks, exits]
624
//                
625
//        2.  awakens, checks all flags true, 
626
//        2.  check that all "extra" threads that we started have indeed run
627
//        2.  end of test.
628
// 
629
// 
630
// (the end)
631
// 
632
// 
633
// ------------------------------------------------------------------------
634
 
635
// EOF mutex3.cxx

powered by: WebSVN 2.1.0

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