File: tthread.cc

package info (click to toggle)
dcmtk 3.6.9-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 95,648 kB
  • sloc: ansic: 426,874; cpp: 318,177; makefile: 6,401; sh: 4,341; yacc: 1,026; xml: 482; lex: 321; perl: 277
file content (663 lines) | stat: -rw-r--r-- 17,509 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
/*
 *
 *  Copyright (C) 2000-2022, OFFIS e.V.
 *  All rights reserved.  See COPYRIGHT file for details.
 *
 *  This software and supporting documentation were developed by
 *
 *    OFFIS e.V.
 *    R&D Division Health
 *    Escherweg 2
 *    D-26121 Oldenburg, Germany
 *
 *
 *  Module:  ofstd
 *
 *  Author:  Marco Eichelberg
 *
 *  Purpose: Define classes for Semaphore, Mutex and Read/Write Lock
 *           as used by most multithread implementations
 *
 *
 */

#include "dcmtk/config/osconfig.h"

#define OFTEST_OFSTD_ONLY
#include "dcmtk/ofstd/oftest.h"
#include "dcmtk/ofstd/ofthread.h"
#include "dcmtk/ofstd/ofstring.h"
#include "dcmtk/ofstd/ofstd.h"
#include "dcmtk/ofstd/ofdiag.h"

#define BAILOUT(msg) do { \
    OFCHECK_FAIL(msg); \
    return; \
} while (0)

static OFMutex *mutex=NULL;
static volatile int mtx_var=0;
static volatile int mtx_cond1=0;
static volatile int mtx_cond2=0;
static volatile int mtx_cond3=0;
static const int wait_timeout = 100;


class MutexT1: public OFThread
{
public:
  MutexT1(): OFThread() {}
  ~MutexT1() {}

  virtual void run()
  {
    if (OFMutex::busy == mutex->trylock()) mtx_cond1=1; // trylock works
    if (0 == mutex->lock())
    {
      mtx_var = 1;
      OFStandard::milliSleep(wait_timeout); // since I've got the mutex, nobody should write to mtx_var
      if ((mtx_var == 1)&&(0 == mutex->unlock())) mtx_cond2 = 1;
    }
  }
};

class MutexT2: public OFThread
{
public:
  MutexT2(): OFThread() {}
  ~MutexT2() {}

  virtual void run()
  {
    if (0 == mutex->lock())
    {
      mtx_var = 2;
      OFStandard::milliSleep(wait_timeout); // since I've got the mutex, nobody should write to mtx_var
      if ((mtx_var == 2)&&(0 == mutex->unlock())) mtx_cond3 = 1;
    }
  }
};

static void mutex_test()
{
  OFString errmsg;
  mutex = new OFMutex();
  if ((!mutex)||(! mutex->initialized())) BAILOUT("creation of mutex failed");
  OFMutex memory_barrier;
  if (! memory_barrier.initialized()) BAILOUT("creation of mutex failed");

  int condition = mutex->trylock();
  if (condition)
  {
    mutex->errorstr(errmsg, condition);
    errmsg = "mutex lock failed: " + errmsg;
    BAILOUT(errmsg);
  }

  mtx_var = -1;

  MutexT1 t1;
  if (0 != t1.start()) BAILOUT("unable to create thread, mutex test failed");

  MutexT2 t2;
  if (0 != t2.start()) BAILOUT("unable to create thread, mutex test failed");

  OFStandard::milliSleep(wait_timeout); // since I've got the mutex, nobody should write to mtx_var
  memory_barrier.lock(); // locking the mutex acts as a (inefficient, but portable) memory barrier
  memory_barrier.unlock();
  if (mtx_var != -1) BAILOUT("mutex test failed");

  int i=0;
  while ((i++<10) && (!mtx_cond1))
  {
    memory_barrier.lock(); // locking the mutex acts as a (inefficient, but portable) memory barrier
    memory_barrier.unlock();
    OFStandard::milliSleep(wait_timeout);
  }
  if (!mtx_cond1) BAILOUT("mutex trylock test failed");

  if (0 != (condition = mutex->unlock()))
  {
    mutex->errorstr(errmsg, condition);
    errmsg =  "mutex unlock failed: " + errmsg;
    BAILOUT(errmsg);
  }

  while ((i++<10) && ((!mtx_cond2)||(!mtx_cond3)))
  {
    memory_barrier.lock(); // locking the mutex acts as a (inefficient, but portable) memory barrier
    memory_barrier.unlock();
    OFStandard::milliSleep(wait_timeout);
  }
  if ((!mtx_cond2) || (!mtx_cond3)) BAILOUT("mutex lock/unlock test failed");

  if (0 != t1.join()) BAILOUT("unable to join thread, mutex test failed");
  if (0 != t2.join()) BAILOUT("unable to join thread, mutex test failed");

  delete mutex;
}

static OFSemaphore *semaphore=NULL;
static volatile int sem_cond1=0;
static volatile int sem_cond2=0;
static volatile int sem_cond3=0;
static volatile int sem_cond4=0;

class SemaT1: public OFThread
{
public:
  SemaT1(): OFThread() {}
  ~SemaT1() {}

  virtual void run()
  {
    if (0 == semaphore->wait())
    {
      sem_cond1 = 1; // acquired semaphore
      mutex->lock();
      mutex->unlock();
      if (0== semaphore->post()) sem_cond2=1;
    }
  }
};

class SemaT2: public OFThread
{
public:
  SemaT2(): OFThread() {}
  ~SemaT2() {}

  virtual void run()
  {
    if (OFSemaphore::busy == semaphore->trywait())
    {
      if (0 == semaphore->wait()) // block on semaphore
      {
        sem_cond3 = 1; // acquired semaphore
        if (0== semaphore->post()) sem_cond4=1;
      }
    }
    else
    {
        sem_cond3 = 1; // acquired semaphore
        if (0== semaphore->post()) sem_cond4=1;
    }
  }
};

static void semaphore_test()
{
  OFString errmsg;
  mutex = new OFMutex();
  if ((!mutex)||(! mutex->initialized())) BAILOUT("creation of mutex failed");
  semaphore = new OFSemaphore(2);
  if ((!semaphore)||(! semaphore->initialized())) BAILOUT("creation of semaphore failed");
  int condition = mutex->trylock();
  if (condition)
  {
    mutex->errorstr(errmsg, condition);
    errmsg = "mutex lock failed: " + errmsg;
    BAILOUT(errmsg);
  }
  condition = semaphore->trywait();
  if (condition)
  {
    semaphore->errorstr(errmsg, condition);
    errmsg = "semaphore acquisition failed: " + errmsg;
    BAILOUT(errmsg);
  }

  OFMutex memory_barrier;
  if (! memory_barrier.initialized()) BAILOUT("creation of mutex failed");

  SemaT1 t1;
  if (0 != t1.start()) BAILOUT("unable to create thread, semaphore test failed");

  int i=0;
  while ((i++<10) && (!sem_cond1))
  {
    memory_barrier.lock(); // locking the mutex acts as a (inefficient, but portable) memory barrier
    memory_barrier.unlock();
    OFStandard::milliSleep(wait_timeout);
  }
  if (!sem_cond1) BAILOUT("semaphore lock/unlock test failed");

  SemaT2 t2;
  if (0 != t2.start()) BAILOUT("unable to create thread, semaphore test failed");

  OFStandard::milliSleep(wait_timeout);
  if (sem_cond3) BAILOUT("semaphore lock/unlock test failed"); // make sure T2 is really blocked
  mutex->unlock();

  i=0;
  while ((i++<10) && ((!sem_cond2)||(!sem_cond3)||(!sem_cond4)))
  {
    memory_barrier.lock(); // locking the mutex acts as a (inefficient, but portable) memory barrier
    memory_barrier.unlock();
    OFStandard::milliSleep(wait_timeout);
  }

  if ((!sem_cond2)||(!sem_cond3)||(!sem_cond4)) BAILOUT("semaphore lock/unlock test failed: sem_cond2=" << sem_cond2 << ", sem_cond3=" << sem_cond3 << ", sem_cond4=" << sem_cond4);

  if (0 != t1.join()) BAILOUT("unable to join thread, semaphore test failed");
  if (0 != t2.join()) BAILOUT("unable to join thread, semaphore test failed");

  delete mutex;
  delete semaphore;
}

static OFReadWriteLock *rwlock=NULL;
static OFMutex *mutex2=NULL;
static volatile int rw_cond1=0;
static volatile int rw_cond2=0;
static volatile int rw_cond3=0;
static volatile int rw_cond4=0;
static volatile int rw_cond5=0;
static volatile int rw_cond6=0;
static volatile int rw_cond7=0;

class RWLockT2: public OFThread
{
public:
  RWLockT2(): OFThread() {}
  ~RWLockT2() {}

  virtual void run()
  {
    if ((0==mutex2->trylock())&&(OFReadWriteLock::busy == rwlock->trywrlock())) rw_cond5=1;
    if (0 == rwlock->wrlock())
    {
      rw_cond6=1;
      mutex2->unlock();
      OFStandard::milliSleep(wait_timeout);
      if (0==rwlock->wrunlock()) rw_cond7=1;
    }
    return;
  }
};

class RWLockT1: public OFThread
{
private:
  RWLockT2 &t2;
public:
#include DCMTK_DIAGNOSTIC_PUSH
#include DCMTK_DIAGNOSTIC_IGNORE_SHADOW
  RWLockT1(RWLockT2 &t2) : OFThread(), t2(t2) {}
#include DCMTK_DIAGNOSTIC_POP
  ~RWLockT1() {}

  virtual void run()
  {
    if (0 == rwlock->rdlock())
    {
      t2.start();
      rw_cond1 = 1; // acquired read lock
      mutex->lock();
      mutex->unlock();
      if (0== rwlock->rdunlock()) rw_cond2=1;
      mutex2->lock();
      mutex2->unlock();
      if (OFReadWriteLock::busy == rwlock->tryrdlock()) rw_cond3=1;
      if ((0 == rwlock->rdlock())&&(0==rwlock->rdunlock())) rw_cond4=1;
    }
    return;
  }
};

static void rwlock_test()
{
  OFString errmsg;

  mutex = new OFMutex();
  if ((!mutex)||(! mutex->initialized())) BAILOUT("creation of mutex failed");
  mutex2 = new OFMutex();
  if ((!mutex2)||(! mutex2->initialized())) BAILOUT("creation of mutex failed");
  rwlock = new OFReadWriteLock();
  if ((!rwlock)||(! rwlock->initialized())) BAILOUT("creation of read/write lock failed");

  int condition = mutex->trylock();
  if (condition)
  {
    mutex->errorstr(errmsg, condition);
    errmsg = "mutex lock failed: " + errmsg;
    BAILOUT(errmsg);
  }

  condition = rwlock->tryrdlock();
  if (condition)
  {
    rwlock->errorstr(errmsg, condition);
    errmsg = "read lock failed: " + errmsg;
    BAILOUT(errmsg);
  }

  OFMutex memory_barrier;
  if (! memory_barrier.initialized()) BAILOUT("creation of mutex failed");

  RWLockT2 t2;
  RWLockT1 t1(t2);
  if (0 != t1.start()) BAILOUT("unable to create thread, read/write lock/unlock test failed");

  int i=0;
  while ((i++<10) && ((!rw_cond1)||(!rw_cond5)))
  {
    memory_barrier.lock(); // locking the mutex acts as a (inefficient, but portable) memory barrier
    memory_barrier.unlock();
    OFStandard::milliSleep(wait_timeout);
  }

  if ((!rw_cond1)||(!rw_cond5)) BAILOUT("read/write lock/unlock test failed");
  condition = rwlock->rdunlock();
  if (condition)
  {
    rwlock->errorstr(errmsg, condition);
    errmsg = "read lock failed: " + errmsg;
    BAILOUT(errmsg);
  }
  OFStandard::milliSleep(wait_timeout);
  memory_barrier.lock(); // locking the mutex acts as a (inefficient, but portable) memory barrier
  memory_barrier.unlock();
  if (rw_cond6) BAILOUT("read/write lock/unlock test failed");

  mutex->unlock();

  i=0;
  while ((i++<10) && ((!rw_cond2)||(!rw_cond3)||(!rw_cond4)||(!rw_cond5)||(!rw_cond6)||(!rw_cond7)))
  {
    memory_barrier.lock(); // locking the mutex acts as a (inefficient, but portable) memory barrier
    memory_barrier.unlock();
    OFStandard::milliSleep(wait_timeout);
  }

  if ((!rw_cond2)||(!rw_cond3)||(!rw_cond4)||(!rw_cond5)||(!rw_cond6)||(!rw_cond7)) BAILOUT("read/write lock/unlock test failed");

  if (0 != t1.join()) BAILOUT("unable to join thread, read/write lock/unlock test failed");
  if (0 != t2.join()) BAILOUT("unable to join thread, read/write lock/unlock test failed");

  delete mutex;
  delete mutex2;
  delete rwlock;
}

class RWLockerT2: public OFThread
{
public:
  RWLockerT2(): OFThread() {}
  ~RWLockerT2() {}

  virtual void run()
  {
    OFReadWriteLocker locker(*rwlock);
    if ((0==mutex2->trylock())&&(OFReadWriteLock::busy == locker.trywrlock())) rw_cond5=1;
    if (0 == locker.wrlock())
    {
      rw_cond6=1;
      mutex2->unlock();
      OFStandard::milliSleep(wait_timeout);
      // Explicit unlock(), check if this causes one unlock() too much
      if (0==locker.unlock()) rw_cond7=1;
    }
    return;
  }
};

class RWLockerT1: public OFThread
{
private:
  RWLockerT2 &t2;
public:
#include DCMTK_DIAGNOSTIC_PUSH
#include DCMTK_DIAGNOSTIC_IGNORE_SHADOW
  RWLockerT1(RWLockerT2 &t2): OFThread(), t2(t2) {}
#include DCMTK_DIAGNOSTIC_POP
  ~RWLockerT1() {}

  virtual void run()
  {
    OFReadWriteLocker locker(*rwlock);
    if (0 == locker.rdlock())
    {
      t2.start();
      rw_cond1 = 1; // acquired read lock
      mutex->lock();
      mutex->unlock();
      if (0== locker.unlock()) rw_cond2=1;
      mutex2->lock();
      mutex2->unlock();
      if (OFReadWriteLock::busy == locker.tryrdlock()) rw_cond3=1;
      if (0 == locker.rdlock()) rw_cond4=1;
      // Implicit unlock() at the end
    }
    return;
  }
};

static void rwlocker_test()
{
  OFString errmsg;

  // Reset global state
  rwlock=NULL;
  mutex2=NULL;
  rw_cond1=0;
  rw_cond2=0;
  rw_cond3=0;
  rw_cond4=0;
  rw_cond5=0;
  rw_cond6=0;
  rw_cond7=0;

  mutex = new OFMutex();
  if ((!mutex)||(! mutex->initialized())) BAILOUT("creation of mutex failed");
  mutex2 = new OFMutex();
  if ((!mutex2)||(! mutex2->initialized())) BAILOUT("creation of mutex failed");
  rwlock = new OFReadWriteLock();
  if ((!rwlock)||(! rwlock->initialized())) BAILOUT("creation of read/write lock failed");

  int condition = mutex->trylock();
  if (condition)
  {
    mutex->errorstr(errmsg, condition);
    errmsg = "mutex lock failed: " + errmsg;
    BAILOUT(errmsg);
  }

  OFReadWriteLocker rwlockLocker(*rwlock);
  condition = rwlockLocker.tryrdlock();
  if (condition)
  {
    rwlock->errorstr(errmsg, condition);
    errmsg = "read lock failed: " + errmsg;
    BAILOUT(errmsg);
  }

  OFMutex memory_barrier;
  if (! memory_barrier.initialized()) BAILOUT("creation of mutex failed");

  RWLockerT2 t2;
  RWLockerT1 t1(t2);
  if (0 != t1.start()) BAILOUT("unable to create thread, read/write lock test failed");

  int i=0;
  while ((i++<10) && ((!rw_cond1)||(!rw_cond5)))
  {
    memory_barrier.lock(); // locking the mutex acts as a (inefficient, but portable) memory barrier
    memory_barrier.unlock();
    OFStandard::milliSleep(wait_timeout);
  }

  if ((!rw_cond1)||(!rw_cond5)) BAILOUT("read/write lock test failed");
  condition = rwlockLocker.unlock();
  if (condition)
  {
    rwlock->errorstr(errmsg, condition);
    errmsg = "read lock failed: " + errmsg;
    BAILOUT(errmsg);
  }
  OFStandard::milliSleep(wait_timeout);
  memory_barrier.lock(); // locking the mutex acts as a (inefficient, but portable) memory barrier
  memory_barrier.unlock();
  if (rw_cond6) BAILOUT("read/write lock test failed");

  mutex->unlock();

  i=0;
  while ((i++<10) && ((!rw_cond2)||(!rw_cond3)||(!rw_cond4)||(!rw_cond5)||(!rw_cond6)||(!rw_cond7)))
  {
    memory_barrier.lock(); // locking the mutex acts as a (inefficient, but portable) memory barrier
    memory_barrier.unlock();
    OFStandard::milliSleep(wait_timeout);
  }

  if ((!rw_cond2)||(!rw_cond3)||(!rw_cond4)||(!rw_cond5)||(!rw_cond6)||(!rw_cond7)) BAILOUT("read/write lock test failed");

  if (0 != t1.join()) BAILOUT("unable to join thread, read/write lock test failed");
  if (0 != t2.join()) BAILOUT("unable to join thread, read/write lock test failed");

  delete mutex;
  delete mutex2;
  delete rwlock;
}


static OFThreadSpecificData *tsdata=NULL;
static volatile int tsd_cond1=0;
static volatile int tsd_cond2=0;
static volatile int tsd_cond3=0;
static volatile int tsd_cond4=0;

class TSDataT1: public OFThread
{
public:
  TSDataT1(): OFThread() {}
  ~TSDataT1() {}

  virtual void run()
  {
    if (0 == tsdata->set(this))
    {
      tsd_cond1 = 1; // acquired read lock
      mutex->lock();
      mutex->unlock();
      void *result = NULL;
      if (0== tsdata->get(result))
      {
        if (result == OFstatic_cast(void *, this)) tsd_cond3 = 1;
      }
    }
  }
};

class TSDataT2: public OFThread
{
public:
  TSDataT2(): OFThread() {}
  ~TSDataT2() {}

  virtual void run()
  {
    if (0 == tsdata->set(this))
    {
      tsd_cond2 = 1; // acquired read lock
      mutex2->lock();
      mutex2->unlock();
      void *result = NULL;
      if (0== tsdata->get(result))
      {
        if (result == OFstatic_cast(void *, this)) tsd_cond4 = 1;
      }
    }
  }
};


static void tsdata_test()
{
  OFString errmsg;

  mutex = new OFMutex();
  if ((!mutex)||(! mutex->initialized())) BAILOUT("creation of mutex failed");
  mutex2 = new OFMutex();
  if ((!mutex2)||(! mutex2->initialized())) BAILOUT("creation of mutex failed");
  tsdata = new OFThreadSpecificData();
  if ((!tsdata)||(! tsdata->initialized())) BAILOUT("creation of thread specific data failed");

  int condition = mutex->trylock();
  if (condition)
  {
    mutex->errorstr(errmsg, condition);
    errmsg = "mutex lock failed: " + errmsg;
    BAILOUT(errmsg);
  }
  condition = mutex2->trylock();
  if (condition)
  {
    mutex2->errorstr(errmsg, condition);
    errmsg = "mutex lock failed: " + errmsg;
    BAILOUT(errmsg);
  }

  OFMutex memory_barrier;
  if (! memory_barrier.initialized()) BAILOUT("creation of mutex failed");

  TSDataT1 t1;
  if (0 != t1.start()) BAILOUT("unable to create thread, thread specific data test failed");

  TSDataT2 t2;
  if (0 != t2.start()) BAILOUT("unable to create thread, thread specific data test failed");


  int i=0;
  while ((i++<10) && ((!tsd_cond1)||(!tsd_cond2)))
  {
    memory_barrier.lock(); // locking the mutex acts as a (inefficient, but portable) memory barrier
    memory_barrier.unlock();
    OFStandard::milliSleep(wait_timeout);
  }

  if ((!tsd_cond1)||(!tsd_cond2)) BAILOUT("thread specific data write test failed");

  condition = mutex->unlock();
  if (condition)
  {
    mutex->errorstr(errmsg, condition);
    errmsg = "mutex unlock failed: " + errmsg;
    BAILOUT(errmsg);
  }
  condition = mutex2->unlock();
  if (condition)
  {
    mutex2->errorstr(errmsg, condition);
    errmsg = "mutex unlock failed: " + errmsg;
    BAILOUT(errmsg);
  }

  i=0;
  while ((i++<10) && ((!tsd_cond3)||(!tsd_cond4)))
  {
    memory_barrier.lock(); // locking the mutex acts as a (inefficient, but portable) memory barrier
    memory_barrier.unlock();
    OFStandard::milliSleep(wait_timeout);
  }

  if ((!tsd_cond3)||(!tsd_cond4)) BAILOUT("thread specific data read test failed");

  if (0 != t1.join()) BAILOUT("unable to create thread, thread specific data test failed");
  if (0 != t2.join()) BAILOUT("unable to create thread, thread specific data test failed");

  delete mutex;
  delete mutex2;
  delete tsdata;
}


OFTEST(ofstd_thread)
{
  // This makes sure tests are executed in the expected order
  mutex_test();
  semaphore_test(); // may assume that mutexes work correctly
  rwlock_test();    // may assume that mutexes and semaphores work correctly
  rwlocker_test();  // may assume that mutexes, semaphores and read/write locks work correctly
  tsdata_test();
}