source: rtems/testsuites/psxtests/psx12/init.c @ 9b4422a2

4.115
Last change on this file since 9b4422a2 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on May 3, 2012 at 3:09:24 PM

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 4.4 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
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#include <sched.h>
15
16#define CONFIGURE_INIT
17#include "system.h"
18#include <errno.h>
19#include "pritime.h"
20
21void print_schedparam(
22  char               *prefix,
23  struct sched_param *schedparam
24);
25
26void print_schedparam(
27  char               *prefix,
28  struct sched_param *schedparam
29)
30{
31  printf( "%ssched priority      = %d\n", prefix, schedparam->sched_priority );
32#if defined(_POSIX_SPORADIC_SERVER)
33  printf( "%ssched_ss_low_priority     = %d\n",
34     prefix, schedparam->sched_ss_low_priority );
35  printf( "%ssched_ss_repl_period = (%" PRIdtime_t ", %ld)\n", prefix,
36     schedparam->sched_ss_repl_period.tv_sec,
37     schedparam->sched_ss_repl_period.tv_nsec );
38  printf( "%ssched_ss_init_budget = (%" PRIdtime_t ", %ld)\n", prefix,
39     schedparam->sched_ss_init_budget.tv_sec,
40     schedparam->sched_ss_init_budget.tv_nsec );
41#else
42  printf( "%s_POSIX_SPORADIC_SERVER is not defined\n" );
43#endif
44}
45
46void *POSIX_Init(
47  void *argument
48)
49{
50  int                 status;
51  pthread_attr_t      attr;
52  struct sched_param  schedparam;
53
54  puts( "\n\n*** POSIX TEST 12 ***" );
55
56  /* set the time of day, and print our buffer in multiple ways */
57
58  set_time( TM_FRIDAY, TM_MAY, 24, 96, 11, 5, 0 );
59
60  /* get id of this thread */
61
62  Init_id = pthread_self();
63  printf( "Init's ID is 0x%08" PRIxpthread_t "\n", Init_id );
64
65  /* invalid scheduling policy error */
66
67  puts( "Init: pthread_attr_init - SUCCESSFUL" );
68  status = pthread_attr_init( &attr );
69  rtems_test_assert( !status );
70
71  status = pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED );
72  rtems_test_assert( !status );
73  attr.schedpolicy = -1;
74
75  puts( "Init: pthread_create - EINVAL (invalid scheduling policy)" );
76  status = pthread_create( &Task_id, &attr, Task_1, NULL );
77  rtems_test_assert( status == EINVAL );
78
79  /* replenish period < budget error */
80
81  puts( "Init: pthread_attr_init - SUCCESSFUL" );
82  status = pthread_attr_init( &attr );
83  rtems_test_assert( !status );
84
85  puts( "Init: set scheduling parameter attributes for sporadic server" );
86  status = pthread_attr_setschedpolicy( &attr, SCHED_SPORADIC );
87  rtems_test_assert( !status );
88
89  schedparam.sched_ss_repl_period.tv_sec = 1;
90  schedparam.sched_ss_repl_period.tv_nsec = 0;
91  schedparam.sched_ss_init_budget.tv_sec = 2;
92  schedparam.sched_ss_init_budget.tv_nsec = 0;
93
94  schedparam.sched_priority = 200;
95  schedparam.sched_ss_low_priority = 100;
96
97  status = pthread_attr_setschedparam( &attr, &schedparam );
98  rtems_test_assert( !status );
99
100  status = pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED );
101  rtems_test_assert( !status );
102
103  puts( "Init: pthread_create - EINVAL (replenish < budget)" );
104  status = pthread_create( &Task_id, &attr, Task_1, NULL );
105  rtems_test_assert( status == EINVAL );
106
107  /* invalid sched_ss_low_priority error */
108
109  schedparam.sched_ss_repl_period.tv_sec = 2;
110  schedparam.sched_ss_repl_period.tv_nsec = 0;
111  schedparam.sched_ss_init_budget.tv_sec = 1;
112  schedparam.sched_ss_init_budget.tv_nsec = 0;
113
114  schedparam.sched_priority = 200;
115  schedparam.sched_ss_low_priority = -1;
116
117  status = pthread_attr_setschedparam( &attr, &schedparam );
118  rtems_test_assert( !status );
119
120  puts( "Init: pthread_create - EINVAL (invalid sched_ss_low_priority)" );
121  status = pthread_create( &Task_id, &attr, Task_1, NULL );
122  rtems_test_assert( status == EINVAL );
123
124  /* create a thread as a sporadic server */
125
126  schedparam.sched_ss_repl_period.tv_sec = 2;
127  schedparam.sched_ss_repl_period.tv_nsec = 0;
128  schedparam.sched_ss_init_budget.tv_sec = 1;
129  schedparam.sched_ss_init_budget.tv_nsec = 0;
130
131  schedparam.sched_priority = sched_get_priority_max( SCHED_FIFO );
132  schedparam.sched_ss_low_priority = sched_get_priority_max( SCHED_FIFO ) - 6;
133
134  status = pthread_attr_setschedparam( &attr, &schedparam );
135  rtems_test_assert( !status );
136
137  puts( "Init: pthread_create - SUCCESSFUL" );
138  status = pthread_create( &Task_id, &attr, Task_1, NULL );
139  rtems_test_assert( !status );
140
141  status = pthread_join( Task_id, NULL );
142  rtems_test_assert( status );
143
144    /* switch to Task_1 */
145
146  puts( "*** END OF POSIX TEST 12 ***" );
147  rtems_test_exit( 0 );
148
149  return NULL; /* just so the compiler thinks we returned something */
150}
Note: See TracBrowser for help on using the repository browser.