source: rtems/c/src/tests/psxtests/psx05/init.c @ 41616f6

4.104.114.84.95
Last change on this file since 41616f6 was 41616f6, checked in by Joel Sherrill <joel.sherrill@…>, on 12/03/98 at 23:01:22

Changed to account for ownership only being tracked when a priority
blocking protocol is used.

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