source: rtems/testsuites/psxtests/psx11/init.c @ 2317457

4.104.115
Last change on this file since 2317457 was 2317457, checked in by Joel Sherrill <joel.sherrill@…>, on 12/08/09 at 17:52:53

2009-12-08 Joel Sherrill <joel.sherrill@…>

  • include/pmacros.h, psx01/task.c, psx02/init.c, psx02/task.c, psx03/init.c, psx03/task.c, psx04/init.c, psx04/task1.c, psx04/task2.c, psx04/task3.c, psx05/init.c, psx05/task.c, psx05/task2.c, psx05/task3.c, psx06/init.c, psx06/task.c, psx06/task2.c, psx07/init.c, psx08/init.c, psx08/task2.c, psx08/task3.c, psx09/init.c, psx10/init.c, psx10/task.c, psx10/task2.c, psx10/task3.c, psx11/init.c, psx11/task.c, psx12/init.c, psxalarm01/init.c, psxbarrier01/test.c, psxcancel01/init.c, psxchroot01/test.c, psxclock/init.c, psxfile01/test.c, psxfile01/test_cat.c, psxfile01/test_extend.c, psxfile01/test_write.c, psxitimer/init.c, psxkey01/task.c, psxkey02/init.c, psxkey03/init.c, psxmount/test.c, psxmsgq01/init.c, psxmsgq03/init.c, psxmsgq04/init.c, psxreaddir/test.c, psxrwlock01/test.c, psxsem01/init.c, psxsignal01/init.c, psxsignal01/task1.c, psxsignal02/init.c, psxsignal03/init.c, psxsignal05/init.c, psxspin01/test.c, psxspin02/test.c, psxstack01/init.c, psxstat/test.c, psxtime/test.c, psxualarm/init.c: Use rtems_test_assert() consistently instead of system assert(). rtems_test_assert() is designed to integrate into the RTEMS test suite infrastructure.
  • Property mode set to 100644
File size: 3.6 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#include <sched.h>
13
14#define CONFIGURE_INIT
15#include "system.h"
16#include <errno.h>
17
18void *POSIX_Init(
19  void *argument
20)
21{
22  int                  status;
23  struct sched_param   param;
24  pthread_attr_t       attr;
25  int                  priority_1;
26  int                  priority_2;
27  int                  priority_3;
28  int                  priority_4;
29
30  puts( "\n\n*** POSIX TEST 11 ***" );
31
32  /* set the time of day, and print our buffer in multiple ways */
33
34  set_time( TM_FRIDAY, TM_MAY, 24, 96, 11, 5, 0 );
35
36  /* get id of this thread */
37
38  Init_id = pthread_self();
39  printf( "Init's ID is 0x%08" PRIxpthread_t "\n", Init_id );
40
41  /* exercise pthread_setschedparam */
42
43  priority_1 = sched_get_priority_max( SCHED_FIFO );      /* was 127 */
44  priority_2 = sched_get_priority_max( SCHED_FIFO ) - 2;  /* was 125 */
45  priority_3 = sched_get_priority_max( SCHED_FIFO ) - 6;  /* was 121 */
46  priority_4 = sched_get_priority_max( SCHED_FIFO ) - 7;  /* was 120 */
47
48  param.sched_priority = priority_1;
49
50  printf(
51    "Init: Setting scheduling parameters to FIFO with priority %d\n",
52    priority_1
53  );
54  status = pthread_setschedparam( Init_id, SCHED_FIFO, &param );
55  rtems_test_assert(  !status );
56
57  param.sched_priority = priority_2;
58
59  printf(
60    "Init: Setting scheduling parameters to RR with priority %d\n",
61    priority_2
62  );
63  status = pthread_setschedparam( Init_id, SCHED_RR, &param );
64  rtems_test_assert(  !status );
65
66  param.sched_priority = priority_3;
67
68  printf(
69    "Init: Setting scheduling parameters to OTHER with priority %d\n",
70    priority_3
71  );
72  status = pthread_setschedparam( Init_id, SCHED_OTHER, &param );
73  rtems_test_assert(  !status );
74
75  /* create a thread as SCHED_FIFO */
76
77  printf(
78    "Init: create a thread of SCHED_FIFO with priority %d\n", priority_4 );
79  status = pthread_attr_init( &attr );
80  rtems_test_assert(  !status );
81
82  attr.schedpolicy = SCHED_FIFO;
83  attr.schedparam.sched_priority = priority_4;
84
85  status = pthread_create( &Task_id, &attr, Task_1, NULL );
86  rtems_test_assert(  !status );
87
88  puts( "Init: join with the other thread" );
89  status = pthread_join( Task_id, NULL );
90  rtems_test_assert(  !status );
91
92  /* create a thread as SCHED_RR */
93
94  printf( "Init: create a thread of SCHED_RR with priority %d\n", priority_4 );
95  status = pthread_attr_init( &attr );
96  rtems_test_assert(  !status );
97
98  status = pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED );
99  rtems_test_assert(  !status );
100  attr.schedpolicy = SCHED_RR;
101  attr.schedparam.sched_priority = priority_4;
102
103  status = pthread_create( &Task_id, &attr, Task_1, NULL );
104  rtems_test_assert(  !status );
105
106  puts( "Init: join with the other thread" );
107  status = pthread_join( Task_id, NULL );
108  rtems_test_assert(  !status );
109
110  /* create a thread as SCHED_OTHER */
111
112  printf(
113    "Init: create a thread of SCHED_OTHER with priority %d\n", priority_4 );
114  status = pthread_attr_init( &attr );
115  rtems_test_assert(  !status );
116
117  attr.schedpolicy = SCHED_OTHER;
118  attr.schedparam.sched_priority = priority_4;
119
120  status = pthread_create( &Task_id, &attr, Task_1, NULL );
121  rtems_test_assert(  !status );
122
123  puts( "Init: join with the other thread" );
124  status = pthread_join( Task_id, NULL );
125  rtems_test_assert(  !status );
126
127  puts( "*** END OF POSIX TEST 11 ***" );
128  rtems_test_exit( 0 );
129
130  return NULL; /* just so the compiler thinks we returned something */
131}
Note: See TracBrowser for help on using the repository browser.