source: rtems/testsuites/psxtests/psx05/init.c @ 42d57c7

4.104.115
Last change on this file since 42d57c7 was 42d57c7, checked in by Joel Sherrill <joel.sherrill@…>, on 07/28/09 at 13:44:58

2009-07-28 Santosh G Vattam <vattam.santosh@…>

  • psx05/init.c, psx05/psx05.scn: Add test for pthread_mutex_timedlock with timeout in the past.
  • Property mode set to 100644
File size: 19.3 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2009.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.com/license/LICENSE.
8 *
9 *  $Id$
10 */
11
12#define CONFIGURE_INIT
13#include "system.h"
14#include <errno.h>
15#include <rtems/posix/priority.h>
16
17#define MUTEX_BAD_ID 0xfffffffe
18
19void Print_mutexattr(
20  char                *msg,
21  pthread_mutexattr_t *attr
22);
23
24void calculate_abstimeout(
25  struct timespec *times,
26  uint32_t         seconds,
27  uint32_t         nanoseconds
28);
29
30void Print_mutexattr(
31  char                *msg,
32  pthread_mutexattr_t *attr
33)
34{
35  int status;
36  int protocol;
37  int prioceiling;
38  int pshared;
39
40  /* protocol */
41
42  status = pthread_mutexattr_getprotocol( attr, &protocol );
43  assert( !status );
44
45  printf( "%smutex protocol is (%d) -- ", msg, protocol );
46  switch ( protocol ) {
47    case PTHREAD_PRIO_NONE:
48      puts( "PTHREAD_PRIO_NONE" );
49      break;
50    case PTHREAD_PRIO_INHERIT:
51      puts( "PTHREAD_PRIO_INHERIT" );
52      break;
53    case PTHREAD_PRIO_PROTECT:
54      puts( "PTHREAD_PRIO_PROTECT" );
55      break;
56    default:
57      puts( "UNKNOWN" );
58      assert( 0 );
59      break;
60  }
61
62  /* priority ceiling */
63
64  status = pthread_mutexattr_getprioceiling( attr, &prioceiling );
65  assert( !status );
66  printf( "%smutex priority ceiling is %d\n", msg, prioceiling );
67
68  /* process shared */
69
70  status = pthread_mutexattr_getpshared( attr, &pshared );
71  assert( !status );
72  printf( "%smutex process shared is (%d) -- ", msg, pshared );
73  switch ( pshared ) {
74    case PTHREAD_PROCESS_PRIVATE:
75      puts( "PTHREAD_PROCESS_PRIVATE" );
76      break;
77    case PTHREAD_PROCESS_SHARED:
78      puts( "PTHREAD_PROCESS_SHARED" );
79      break;
80    default:
81      puts( "UNKNOWN" );
82      assert( 0 );
83      break;
84  }
85}
86
87void calculate_abstimeout(
88  struct timespec *times,
89  uint32_t         seconds,
90  uint32_t         nanoseconds
91)
92{
93  struct timeval       tv1;
94  struct timezone      tz1;
95
96  gettimeofday( &tv1, &tz1 );
97
98  times->tv_sec  = seconds     + tv1.tv_sec;
99  times->tv_nsec = nanoseconds + (tv1.tv_usec * 1000);
100
101  while ( times->tv_nsec >= TOD_NANOSECONDS_PER_SECOND ) {
102    times->tv_sec++;
103    times->tv_nsec -= TOD_NANOSECONDS_PER_SECOND;
104  }
105
106}
107
108void *POSIX_Init(
109  void *argument
110)
111{
112  int                  status;
113  pthread_mutexattr_t  attr;
114  pthread_mutexattr_t  destroyed_attr;
115  struct timespec      times;
116  struct sched_param   param;
117  int                  pshared;
118  int                  policy;
119  int                  protocol;
120  int                  ceiling;
121  int                  old_ceiling;
122  int                  priority;
123
124  assert( MUTEX_BAD_ID != PTHREAD_MUTEX_INITIALIZER );
125  Mutex_bad_id = MUTEX_BAD_ID;
126
127  puts( "\n\n*** POSIX TEST 5 ***" );
128
129  /* set the time of day, and print our buffer in multiple ways */
130
131  set_time( TM_FRIDAY, TM_MAY, 24, 96, 11, 5, 0 );
132
133  /* get id of this thread */
134
135  Init_id = pthread_self();
136  printf( "Init's ID is 0x%08x\n", Init_id );
137
138  /* tes pthread_mutex_attr_init */
139
140  puts( "Init: pthread_mutexattr_init - EINVAL (NULL attr)" );
141  status = pthread_mutexattr_init( NULL );
142  assert( status == EINVAL );
143
144  puts( "Init: pthread_mutexattr_init - SUCCESSFUL" );
145  status = pthread_mutexattr_init( &attr );
146  assert( !status );
147
148  Print_mutexattr( "Init: ", &attr );
149
150  /* create an "uninitialized" attribute structure */
151
152  status = pthread_mutexattr_init( &destroyed_attr );
153  assert( !status );
154
155  puts( "Init: pthread_mutexattr_destroy - SUCCESSFUL" );
156  status = pthread_mutexattr_destroy( &destroyed_attr );
157  assert( !status );
158
159  puts( "Init: pthread_mutexattr_destroy - EINVAL (NULL attr)" );
160  status = pthread_mutexattr_destroy( NULL );
161  assert( status == EINVAL );
162
163  puts( "Init: pthread_mutexattr_destroy - EINVAL (not initialized)" );
164  status = pthread_mutexattr_destroy( &destroyed_attr );
165  assert( status == EINVAL );
166
167  /* error cases for set and get pshared attribute */
168
169  empty_line();
170
171  puts( "Init: pthread_mutexattr_getpshared - EINVAL (NULL attr)" );
172  status = pthread_mutexattr_getpshared( NULL, &pshared );
173  assert( status == EINVAL );
174
175  puts( "Init: pthread_mutexattr_getpshared - EINVAL (NULL pshared)" );
176  status = pthread_mutexattr_getpshared( &attr, NULL );
177  assert( status == EINVAL );
178
179  puts( "Init: pthread_mutexattr_getpshared - EINVAL (not initialized)" );
180  status = pthread_mutexattr_getpshared( &destroyed_attr, &pshared );
181  assert( status == EINVAL );
182
183  pshared = PTHREAD_PROCESS_PRIVATE;
184  puts( "Init: pthread_mutexattr_setpshared - EINVAL (NULL attr)" );
185  status = pthread_mutexattr_setpshared( NULL, pshared );
186  assert( status == EINVAL );
187
188  pshared = PTHREAD_PROCESS_PRIVATE;
189  puts( "Init: pthread_mutexattr_setpshared - EINVAL (not initialized)" );
190  status = pthread_mutexattr_setpshared( &destroyed_attr, pshared );
191  assert( status == EINVAL );
192
193  /* error cases for set and get protocol attribute */
194
195  empty_line();
196
197  puts( "Init: pthread_mutexattr_getprotocol - EINVAL (NULL attr)" );
198  status = pthread_mutexattr_getprotocol( NULL, &protocol );
199  assert( status == EINVAL );
200
201  puts( "Init: pthread_mutexattr_getprotocol - EINVAL (NULL protocol)" );
202  status = pthread_mutexattr_getprotocol( &attr, NULL );
203  assert( status == EINVAL );
204
205  puts( "Init: pthread_mutexattr_getprotocol - EINVAL (not initialized)" );
206  status = pthread_mutexattr_getprotocol( &destroyed_attr, &protocol );
207  assert( status == EINVAL );
208
209  puts( "Init: pthread_mutexattr_setprotocol - EINVAL (NULL attr)" );
210  status = pthread_mutexattr_setprotocol( NULL, PTHREAD_PRIO_NONE );
211  assert( status == EINVAL );
212
213  puts( "Init: pthread_mutexattr_setprotocol - EINVAL (invalid protocol)" );
214  status = pthread_mutexattr_setprotocol( &attr, -1 );
215  assert( status == EINVAL );
216
217  puts( "Init: pthread_mutexattr_setprotocol - EINVAL (not initialized)" );
218  status = pthread_mutexattr_setprotocol( &destroyed_attr, -1 );
219  assert( status == EINVAL );
220
221  /* error cases for set and get prioceiling attribute */
222
223  empty_line();
224
225  puts( "Init: pthread_mutexattr_getprioceiling - EINVAL (NULL attr)" );
226  status = pthread_mutexattr_getprioceiling( NULL, &ceiling );
227  assert( status == EINVAL );
228
229  puts( "Init: pthread_mutexattr_getprioceiling - EINVAL (NULL prioceiling)" );
230  status = pthread_mutexattr_getprioceiling( &attr, NULL );
231  assert( status == EINVAL );
232
233  puts( "Init: pthread_mutexattr_getprioceiling - EINVAL (not initialized)" );
234  status = pthread_mutexattr_getprioceiling( &destroyed_attr, &ceiling );
235  assert( status == EINVAL );
236
237  puts( "Init: pthread_mutexattr_setprioceiling - EINVAL (NULL attr)" );
238  status = pthread_mutexattr_setprioceiling( NULL, 128 );
239  assert( status == EINVAL );
240
241  puts( "Init: pthread_mutexattr_setprioceiling - EINVAL (invalid priority)" );
242  status = pthread_mutexattr_setprioceiling( &attr, 512 );
243  if ( status != EINVAL )
244    printf( "status = %d\n", status );
245  assert( status == EINVAL );
246
247  puts( "Init: pthread_mutexattr_setprioceiling - EINVAL (not initialized)" );
248  status = pthread_mutexattr_setprioceiling( &destroyed_attr, -1 );
249  assert( status == EINVAL );
250
251  /* create a thread */
252
253  status = pthread_create( &Task_id, NULL, Task_1, NULL );
254  assert( !status );
255
256  /* now try some basic mutex operations */
257
258  empty_line();
259
260  puts( "Init: pthread_mutex_init - EINVAL (NULL mutex_id)" );
261  status = pthread_mutex_init( NULL, &attr );
262  assert( status == EINVAL );
263
264  puts( "Init: pthread_mutex_init - EINVAL (not initialized attr)" );
265  status = pthread_mutex_init( &Mutex_id, &destroyed_attr );
266  assert( status == EINVAL );
267
268  /* must get around error checks in attribute set routines */
269  attr.protocol = -1;
270
271  puts( "Init: pthread_mutex_init - EINVAL (bad protocol)" );
272  status = pthread_mutex_init( &Mutex_id, &attr );
273  assert( status == EINVAL );
274
275  /* must get around error checks in attribute set routines */
276  attr.protocol = PTHREAD_PRIO_INHERIT;
277  attr.prio_ceiling = -1;
278
279  puts( "Init: pthread_mutex_init - EINVAL (bad priority ceiling)" );
280  status = pthread_mutex_init( &Mutex_id, &attr );
281  assert( status == EINVAL );
282
283  /* must get around various error checks before checking bad scope */
284  puts( "Init: Resetting mutex attributes" );
285  status = pthread_mutexattr_init( &attr );
286  assert( !status );
287
288  puts( "Init: pthread_mutex_init - ENOSYS (process wide scope)" );
289  attr.process_shared = PTHREAD_PROCESS_SHARED;
290  status = pthread_mutex_init( &Mutex_id, &attr );
291  assert( status == ENOSYS );
292
293  puts( "Init: pthread_mutex_init - EINVAL (invalid scope)" );
294  attr.process_shared = -1;
295  status = pthread_mutex_init( &Mutex_id, &attr );
296  assert( status == EINVAL );
297
298  /* now set up for a success pthread_mutex_init */
299
300  puts( "Init: Resetting mutex attributes" );
301  status = pthread_mutexattr_init( &attr );
302  assert( !status );
303
304  puts( "Init: Changing mutex attributes" );
305  status = pthread_mutexattr_setprotocol( &attr, PTHREAD_PRIO_INHERIT );
306  assert( !status );
307
308  status = pthread_mutexattr_setprioceiling(
309    &attr,
310    (sched_get_priority_max(SCHED_FIFO) / 2) + 1
311  );
312  assert( !status );
313
314  status = pthread_mutexattr_setpshared( &attr, PTHREAD_PROCESS_SHARED );
315  assert( !status );
316
317  Print_mutexattr( "Init: ", &attr );
318
319  puts( "Init: Resetting mutex attributes" );
320  status = pthread_mutexattr_init( &attr );
321  assert( !status );
322
323  /*
324   *  Set the protocol to priority ceiling so the owner check happens
325   *  and the EPERM test (later) will work.
326   */
327
328  status = pthread_mutexattr_setprotocol( &attr, PTHREAD_PRIO_INHERIT );
329  assert( !status );
330
331  puts( "Init: pthread_mutex_init - SUCCESSFUL" );
332  status = pthread_mutex_init( &Mutex_id, &attr );
333  if ( status )
334    printf( "status = %d\n", status );
335  assert( !status );
336
337  /*
338   *  This is not required to be an error and when it is, there are
339   *  behavioral conflicts with other implementations.
340   */
341  puts( "Init: pthread_mutex_init - EBUSY (reinitialize an existing mutex) - skipped" );
342
343#if 0
344  status = pthread_mutex_init( &Mutex_id, &attr );
345  if ( !status )
346    printf( "status = %d\n", status );
347  assert( status == EBUSY );
348#endif
349
350  puts( "Init: pthread_mutex_trylock - EINVAL (illegal ID)" );
351  status = pthread_mutex_trylock( &Mutex_bad_id );
352  if ( status != EINVAL )
353    printf( "status = %d\n", status );
354  assert( status == EINVAL );
355
356  puts( "Init: pthread_mutex_trylock - SUCCESSFUL" );
357  status = pthread_mutex_trylock( &Mutex_id );
358  if ( status )
359    printf( "status = %d\n", status );
360  assert( !status );
361
362  puts( "Init: pthread_mutex_trylock - EDEADLK (already locked)" );
363  status = pthread_mutex_trylock( &Mutex_id );
364  if ( status != EDEADLK )
365    printf( "status = %d\n", status );
366  assert( status == EDEADLK );
367
368  puts( "Init: pthread_mutex_lock - EINVAL (NULL id)" );
369  status = pthread_mutex_lock( NULL );
370  if ( status != EINVAL )
371    printf( "status = %d\n", status );
372  assert( status == EINVAL );
373
374  puts( "Init: pthread_mutex_unlock - EINVAL (NULL id)" );
375  status = pthread_mutex_unlock( NULL );
376  if ( status != EINVAL )
377    printf( "status = %d\n", status );
378  assert( status == EINVAL );
379
380  puts( "Init: pthread_mutex_lock - EDEADLK (already locked)" );
381  status = pthread_mutex_lock( &Mutex_id );
382  if ( status != EDEADLK )
383    printf( "status = %d\n", status );
384  assert( status == EDEADLK );
385
386  puts( "Init: Sleep 1 second" );
387
388  sleep( 1 );
389
390     /* switch to task 1 */
391
392  puts( "Init: pthread_mutex_unlock - EINVAL (invalid id)" );
393  status = pthread_mutex_unlock( &Mutex_bad_id );
394  if ( status != EINVAL )
395    printf( "status = %d\n", status );
396  assert( status == EINVAL );
397
398  puts( "Init: pthread_mutex_unlock - SUCCESSFUL" );
399  status = pthread_mutex_unlock( &Mutex_id );
400  if ( status )
401    printf( "status = %d\n", status );
402  assert( !status );
403
404  puts( "Init: pthread_mutex_unlock - EPERM (not owner)" );
405  status = pthread_mutex_unlock( &Mutex_id );
406  if ( status != EPERM )
407    printf( "status = %d\n", status );
408  assert( status == EPERM );
409
410  puts( "Init: pthread_mutex_timedlock - time out in 1/2 second" );
411  calculate_abstimeout( &times, 0, (TOD_NANOSECONDS_PER_SECOND / 2) );
412
413  status = pthread_mutex_timedlock( &Mutex_id, &times );
414  if ( status != ETIMEDOUT )
415    printf( "status = %d\n", status );
416  assert( status == ETIMEDOUT );
417
418  puts( "Init: pthread_mutex_timedlock - time out in the past" );
419  calculate_abstimeout( &times, -1, (TOD_NANOSECONDS_PER_SECOND / 2) );
420
421  status = pthread_mutex_timedlock( &Mutex_id, &times );
422  if ( status != EBUSY )
423    printf( "status = %d\n", status );
424  assert( status == EBUSY );
425
426     /* switch to idle */
427
428  puts( "Init: pthread_mutex_timedlock - EAGAIN (timeout)" );
429
430  /* destroy a mutex */
431
432  empty_line();
433
434  puts( "Init: pthread_mutex_init - SUCCESSFUL" );
435  status = pthread_mutex_init( &Mutex2_id, &attr );
436  if ( status )
437    printf( "status = %d\n", status );
438  assert( !status );
439
440  puts( "Init: pthread_mutex_init - EAGAIN (too many)" );
441  status = pthread_mutex_init( &Mutex3_id, &attr );
442  assert( status == EAGAIN );
443
444  puts( "Init: pthread_mutexattr_destroy - SUCCESSFUL" );
445  status = pthread_mutexattr_destroy( &attr );
446  assert( !status );
447
448  puts( "Init: pthread_mutex_destroy - SUCCESSFUL" );
449  status = pthread_mutex_destroy( &Mutex2_id );
450  assert( !status );
451
452  puts( "Init: pthread_mutex_destroy - EINVAL (invalid id)" );
453  status = pthread_mutex_destroy( &Mutex_bad_id );
454  assert( status == EINVAL );
455
456  /* destroy a busy mutex */
457
458  empty_line();
459
460  puts( "Init: pthread_mutexattr_init - SUCCESSFUL" );
461  status = pthread_mutexattr_init( &attr );
462  assert( !status );
463
464  puts( "Init: pthread_mutex_init - SUCCESSFUL" );
465  status = pthread_mutex_init( &Mutex2_id, &attr );
466  assert( !status );
467
468  puts( "Init: pthread_mutex_trylock - SUCCESSFUL" );
469  status = pthread_mutex_trylock( &Mutex2_id );
470  if ( status )
471    printf( "status = %d\n", status );
472  assert( !status );
473
474  puts( "Init: pthread_mutex_destroy - EBUSY (already locked)" );
475  status = pthread_mutex_destroy( &Mutex2_id );
476  if ( status != EBUSY )
477    printf( "status = %d\n", status );
478  assert( status == EBUSY );
479
480  puts( "Init: pthread_mutex_unlock - SUCCESSFUL" );
481  status = pthread_mutex_unlock( &Mutex2_id );
482  assert( !status );
483
484  puts( "Init: pthread_mutex_destroy - SUCCESSFUL" );
485  status = pthread_mutex_destroy( &Mutex2_id );
486  assert( !status );
487
488  /* priority inherit mutex */
489
490  empty_line();
491
492  puts( "Init: pthread_mutexattr_init - SUCCESSFUL" );
493  status = pthread_mutexattr_init( &attr );
494  assert( !status );
495
496  puts(
497    "Init: pthread_mutexattr_setprotocol - SUCCESSFUL (PTHREAD_PRIO_INHERIT)"
498  );
499  status = pthread_mutexattr_setprotocol( &attr, PTHREAD_PRIO_INHERIT );
500  assert( !status );
501
502  puts( "Init: pthread_mutex_init - SUCCESSFUL" );
503  status = pthread_mutex_init( &Mutex2_id, &attr );
504  assert( !status );
505
506  puts( "Init: pthread_mutex_trylock - SUCCESSFUL" );
507  status = pthread_mutex_trylock( &Mutex2_id );
508  assert( !status );
509
510  /* create a thread at a lower priority */
511
512  status = pthread_create( &Task2_id, NULL, Task_2, NULL );
513  assert( !status );
514
515  /* set priority of Task2 to highest priority */
516
517  param.sched_priority = sched_get_priority_max( SCHED_FIFO );
518
519  puts( "Init: pthread_setschedparam - Setting Task2 priority to highest" );
520  status = pthread_setschedparam( Task2_id, SCHED_FIFO, &param );
521  assert( !status );
522
523  /* switching to Task2 */
524
525  status = pthread_getschedparam( pthread_self(), &policy, &param );
526  assert( !status );
527  printf( "Init: pthread_getschedparam - priority = %d\n", param.sched_priority);
528
529  puts( "Init: pthread_mutex_unlock - SUCCESSFUL" );
530  status = pthread_mutex_unlock( &Mutex2_id );
531  assert( !status );
532
533  puts( "Init: pthread_mutexattr_destroy - SUCCESSFUL" );
534  status = pthread_mutexattr_destroy( &attr );
535  assert( !status );
536
537  puts( "Init: pthread_mutex_destroy - SUCCESSFUL" );
538  status = pthread_mutex_destroy( &Mutex2_id );
539  assert( !status );
540
541  /* priority ceiling mutex */
542
543  empty_line();
544
545  puts( "Init: pthread_mutexattr_init - SUCCESSFUL" );
546  status = pthread_mutexattr_init( &attr );
547  assert( !status );
548
549  puts(
550    "Init: pthread_mutexattr_setprotocol - SUCCESSFUL (PTHREAD_PRIO_PROTECT)"
551  );
552  status = pthread_mutexattr_setprotocol( &attr, PTHREAD_PRIO_PROTECT );
553  assert( !status );
554
555  puts( "Init: pthread_mutex_init - SUCCESSFUL" );
556  status = pthread_mutex_init( &Mutex2_id, &attr );
557  assert( !status );
558
559  puts( "Init: pthread_mutex_getprioceiling - EINVAL (invalid id)" );
560  status = pthread_mutex_getprioceiling( &Mutex_bad_id, &ceiling );
561  assert( status == EINVAL );
562
563  puts( "Init: pthread_mutex_getprioceiling - EINVAL (NULL ceiling)" );
564  status = pthread_mutex_getprioceiling( &Mutex2_id, NULL );
565  assert( status == EINVAL );
566
567  status = pthread_mutex_getprioceiling( &Mutex2_id, &ceiling );
568  assert( !status );
569  printf( "Init: pthread_mutex_getprioceiling - %d\n", ceiling );
570
571  puts( "Init: pthread_mutex_setprioceiling - EINVAL (invalid id)" );
572  status = pthread_mutex_setprioceiling( &Mutex_bad_id, 200, &old_ceiling );
573  assert( status == EINVAL );
574
575  puts( "Init: pthread_mutex_setprioceiling - EINVAL (illegal priority)" );
576  status = pthread_mutex_setprioceiling( &Mutex2_id, 512, &old_ceiling );
577  assert( status == EINVAL );
578
579  puts( "Init: pthread_mutex_setprioceiling - EINVAL (NULL ceiling)" );
580  status = pthread_mutex_setprioceiling( &Mutex2_id, 128, NULL );
581  assert( status == EINVAL );
582
583  /* normal cases of set priority ceiling */
584
585  priority = sched_get_priority_max( SCHED_FIFO );
586  priority = (priority == 254) ? 200 : 13;
587 
588  printf( "Init: pthread_mutex_setprioceiling - new ceiling = %d\n", priority );
589  status = pthread_mutex_setprioceiling( &Mutex2_id, priority, &old_ceiling );
590  assert( !status );
591  printf(
592    "Init: pthread_mutex_setprioceiling - old ceiling = %d\n",old_ceiling
593  );
594
595  status = pthread_getschedparam( pthread_self(), &policy, &param );
596  assert( !status );
597  printf(
598    "Init: pthread_getschedparam - priority = %d\n", param.sched_priority
599  );
600
601  puts( "Init: pthread_mutex_trylock - SUCCESSFUL" );
602  status = pthread_mutex_trylock( &Mutex2_id );
603  assert( !status );
604
605  status = pthread_getschedparam( pthread_self(), &policy, &param );
606  assert( !status );
607  printf(
608    "Init: pthread_getschedparam - priority = %d\n", param.sched_priority
609  );
610
611  /* create a thread at a higher priority */
612
613  status = pthread_create( &Task3_id, NULL, Task_3, NULL );
614  assert( !status );
615
616  /* set priority of Task3 to highest priority */
617
618  param.sched_priority = --priority;
619
620  status = pthread_setschedparam( Task3_id, SCHED_FIFO, &param );
621  assert( !status );
622  puts( "Init: pthread_setschedparam - set Task3 priority to highest" );
623
624  /* DOES NOT SWITCH to Task3 */
625
626  puts( "Init: Sleep 1 second" );
627  assert( !status );
628  sleep( 1 );
629
630  /* switch to task 3 */
631
632  puts( "Init: pthread_mutex_unlock - SUCCESSFUL" );
633  status = pthread_mutex_unlock( &Mutex2_id );
634  assert( !status );
635
636  status = pthread_mutex_getprioceiling( &Mutex2_id, &ceiling );
637  assert( !status );
638  printf( "Init: pthread_mutex_getprioceiling- ceiling = %d\n", ceiling );
639
640  /* set priority of Init to highest priority */
641
642  param.sched_priority = sched_get_priority_max(SCHED_FIFO);
643
644  status = pthread_setschedparam( Init_id, SCHED_FIFO, &param );
645  assert( !status );
646  puts( "Init: pthread_setschedparam - set Init priority to highest" );
647
648  puts( "Init: pthread_mutex_lock - EINVAL (priority ceiling violation)" );
649  status = pthread_mutex_lock( &Mutex2_id );
650  if ( status != EINVAL )
651    printf( "status = %d\n", status );
652  assert( status == EINVAL );
653
654  puts( "*** END OF POSIX TEST 5 ***" );
655  rtems_test_exit( 0 );
656
657  return NULL; /* just so the compiler thinks we returned something */
658}
Note: See TracBrowser for help on using the repository browser.