source: rtems/testsuites/psxtests/psx11/init.c @ 3d36b370

4.104.115
Last change on this file since 3d36b370 was 3d36b370, checked in by Joel Sherrill <joel.sherrill@…>, on 07/20/09 at 01:05:59

2009-07-19 Joel Sherrill <joel.sherrill@…>

  • psx11/init.c: Use explicit scheduler.
  • Property mode set to 100644
File size: 3.4 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2008.
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
16void *POSIX_Init(
17  void *argument
18)
19{
20  int                  status;
21  struct sched_param   param;
22  pthread_attr_t       attr;
23  int                  priority_1;
24  int                  priority_2;
25  int                  priority_3;
26  int                  priority_4;
27
28  puts( "\n\n*** POSIX TEST 11 ***" );
29
30  /* set the time of day, and print our buffer in multiple ways */
31
32  set_time( TM_FRIDAY, TM_MAY, 24, 96, 11, 5, 0 );
33
34  /* get id of this thread */
35
36  Init_id = pthread_self();
37  printf( "Init's ID is 0x%08x\n", Init_id );
38
39  /* exercise pthread_setschedparam */
40
41  priority_1 = sched_get_priority_max( SCHED_FIFO );      /* was 127 */
42  priority_2 = sched_get_priority_max( SCHED_FIFO ) - 2;  /* was 125 */
43  priority_3 = sched_get_priority_max( SCHED_FIFO ) - 6;  /* was 121 */
44  priority_4 = sched_get_priority_max( SCHED_FIFO ) - 7;  /* was 120 */
45
46  param.sched_priority = priority_1;
47
48  printf(
49    "Init: Setting scheduling parameters to FIFO with priority %d\n",
50    priority_1
51  );
52  status = pthread_setschedparam( Init_id, SCHED_FIFO, &param );
53  assert( !status );
54
55  param.sched_priority = priority_2;
56
57  printf(
58    "Init: Setting scheduling parameters to RR with priority %d\n",
59    priority_2
60  );
61  status = pthread_setschedparam( Init_id, SCHED_RR, &param );
62  assert( !status );
63
64  param.sched_priority = priority_3;
65
66  printf(
67    "Init: Setting scheduling parameters to OTHER with priority %d\n",
68    priority_3
69  );
70  status = pthread_setschedparam( Init_id, SCHED_OTHER, &param );
71  assert( !status );
72
73  /* create a thread as SCHED_FIFO */
74
75  printf(
76    "Init: create a thread of SCHED_FIFO with priority %d\n", priority_4 );
77  status = pthread_attr_init( &attr );
78  assert( !status );
79
80  attr.schedpolicy = SCHED_FIFO;
81  attr.schedparam.sched_priority = priority_4;
82
83  status = pthread_create( &Task_id, &attr, Task_1, NULL );
84  assert( !status );
85
86  puts( "Init: join with the other thread" );
87  status = pthread_join( Task_id, NULL );
88  assert( !status );
89
90  /* create a thread as SCHED_RR */
91
92  printf( "Init: create a thread of SCHED_RR with priority %d\n", priority_4 );
93  status = pthread_attr_init( &attr );
94  assert( !status );
95
96  status = pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED );
97  assert( !status );
98  attr.schedpolicy = SCHED_RR;
99  attr.schedparam.sched_priority = priority_4;
100
101  status = pthread_create( &Task_id, &attr, Task_1, NULL );
102  assert( !status );
103
104  puts( "Init: join with the other thread" );
105  status = pthread_join( Task_id, NULL );
106  assert( !status );
107
108  /* create a thread as SCHED_OTHER */
109
110  printf(
111    "Init: create a thread of SCHED_OTHER with priority %d\n", priority_4 );
112  status = pthread_attr_init( &attr );
113  assert( !status );
114
115  attr.schedpolicy = SCHED_OTHER;
116  attr.schedparam.sched_priority = priority_4;
117
118  status = pthread_create( &Task_id, &attr, Task_1, NULL );
119  assert( !status );
120
121  puts( "Init: join with the other thread" );
122  status = pthread_join( Task_id, NULL );
123  assert( !status );
124
125  puts( "*** END OF POSIX TEST 11 ***" );
126  rtems_test_exit( 0 );
127
128  return NULL; /* just so the compiler thinks we returned something */
129}
Note: See TracBrowser for help on using the repository browser.