OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [tests/] [psxtests/] [psx11/] [init.c] - Blame information for rev 173

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
2
 *  COPYRIGHT (c) 1989-1999.
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.OARcorp.com/rtems/license.html.
8
 *
9
 *  $Id: init.c,v 1.2 2001-09-27 12:02:24 chris Exp $
10
 */
11
 
12
#define CONFIGURE_INIT
13
#include "system.h"
14
#include <errno.h>
15
 
16
void *POSIX_Init(
17
  void *argument
18
)
19
{
20
  int                  status;
21
  struct sched_param   param;
22
  pthread_attr_t       attr;
23
 
24
  puts( "\n\n*** POSIX TEST 11 ***" );
25
 
26
  /* set the time of day, and print our buffer in multiple ways */
27
 
28
  set_time( TM_FRIDAY, TM_MAY, 24, 96, 11, 5, 0 );
29
 
30
  /* get id of this thread */
31
 
32
  Init_id = pthread_self();
33
  printf( "Init's ID is 0x%08x\n", Init_id );
34
 
35
  /* exercise pthread_setschedparam */
36
 
37
  param.sched_priority = 127;
38
 
39
  puts( "Init: Setting scheduling parameters to FIFO with priority 127" );
40
  status = pthread_setschedparam( Init_id, SCHED_FIFO, &param );
41
  assert( !status );
42
 
43
  param.sched_priority = 125;
44
 
45
  puts( "Init: Setting scheduling parameters to RR with priority 125" );
46
  status = pthread_setschedparam( Init_id, SCHED_RR, &param );
47
  assert( !status );
48
 
49
  param.sched_priority = 121;
50
 
51
  puts( "Init: Setting scheduling parameters to OTHER with priority 121" );
52
  status = pthread_setschedparam( Init_id, SCHED_OTHER, &param );
53
  assert( !status );
54
 
55
  /* create a thread as SCHED_FIFO */
56
 
57
  puts( "Init: create a thread of SCHED_FIFO with priority 120" );
58
  status = pthread_attr_init( &attr );
59
  assert( !status );
60
 
61
  attr.schedpolicy = SCHED_FIFO;
62
  attr.schedparam.sched_priority = 120;
63
 
64
  status = pthread_create( &Task_id, &attr, Task_1, NULL );
65
  assert( !status );
66
 
67
  puts( "Init: join with the other thread" );
68
  status = pthread_join( Task_id, NULL );
69
  assert( !status );
70
 
71
  /* create a thread as SCHED_RR */
72
 
73
  puts( "Init: create a thread of SCHED_RR with priority 120" );
74
  status = pthread_attr_init( &attr );
75
  assert( !status );
76
 
77
  attr.schedpolicy = SCHED_RR;
78
  attr.schedparam.sched_priority = 120;
79
 
80
  status = pthread_create( &Task_id, &attr, Task_1, NULL );
81
  assert( !status );
82
 
83
  puts( "Init: join with the other thread" );
84
  status = pthread_join( Task_id, NULL );
85
  assert( !status );
86
 
87
  /* create a thread as SCHED_OTHER */
88
 
89
  puts( "Init: create a thread of SCHED_OTHER with priority 120" );
90
  status = pthread_attr_init( &attr );
91
  assert( !status );
92
 
93
  attr.schedpolicy = SCHED_OTHER;
94
  attr.schedparam.sched_priority = 120;
95
 
96
  status = pthread_create( &Task_id, &attr, Task_1, NULL );
97
  assert( !status );
98
 
99
  puts( "Init: join with the other thread" );
100
  status = pthread_join( Task_id, NULL );
101
  assert( !status );
102
 
103
  puts( "*** END OF POSIX TEST 11 ***" );
104
  exit( 0 );
105
 
106
  return NULL; /* just so the compiler thinks we returned something */
107
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.