1 | /* |
---|
2 | * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. |
---|
3 | * On-Line Applications Research Corporation (OAR). |
---|
4 | * All rights assigned to U.S. Government, 1994. |
---|
5 | * |
---|
6 | * This material may be reproduced by or for the U.S. Government pursuant |
---|
7 | * to the copyright license under the clause at DFARS 252.227-7013. This |
---|
8 | * notice must appear in all copies of this file and its derivatives. |
---|
9 | * |
---|
10 | * $Id$ |
---|
11 | */ |
---|
12 | |
---|
13 | #define CONFIGURE_INIT |
---|
14 | #include "system.h" |
---|
15 | #include <errno.h> |
---|
16 | |
---|
17 | void *POSIX_Init( |
---|
18 | void *argument |
---|
19 | ) |
---|
20 | { |
---|
21 | int status; |
---|
22 | struct sched_param param; |
---|
23 | pthread_attr_t attr; |
---|
24 | |
---|
25 | puts( "\n\n*** POSIX TEST 11 ***" ); |
---|
26 | |
---|
27 | /* set the time of day, and print our buffer in multiple ways */ |
---|
28 | |
---|
29 | set_time( TM_FRIDAY, TM_MAY, 24, 96, 11, 5, 0 ); |
---|
30 | |
---|
31 | /* get id of this thread */ |
---|
32 | |
---|
33 | Init_id = pthread_self(); |
---|
34 | printf( "Init's ID is 0x%08x\n", Init_id ); |
---|
35 | |
---|
36 | /* exercise pthread_setschedparam */ |
---|
37 | |
---|
38 | param.sched_priority = 127; |
---|
39 | |
---|
40 | puts( "Init: Setting scheduling parameters to FIFO with priority 127" ); |
---|
41 | status = pthread_setschedparam( Init_id, SCHED_FIFO, ¶m ); |
---|
42 | assert( !status ); |
---|
43 | |
---|
44 | param.sched_priority = 125; |
---|
45 | |
---|
46 | puts( "Init: Setting scheduling parameters to RR with priority 125" ); |
---|
47 | status = pthread_setschedparam( Init_id, SCHED_RR, ¶m ); |
---|
48 | assert( !status ); |
---|
49 | |
---|
50 | param.sched_priority = 121; |
---|
51 | |
---|
52 | puts( "Init: Setting scheduling parameters to OTHER with priority 121" ); |
---|
53 | status = pthread_setschedparam( Init_id, SCHED_OTHER, ¶m ); |
---|
54 | assert( !status ); |
---|
55 | |
---|
56 | /* create a thread as SCHED_FIFO */ |
---|
57 | |
---|
58 | puts( "Init: create a thread of SCHED_FIFO with priority 120" ); |
---|
59 | status = pthread_attr_init( &attr ); |
---|
60 | assert( !status ); |
---|
61 | |
---|
62 | attr.schedpolicy = SCHED_FIFO; |
---|
63 | attr.schedparam.sched_priority = 120; |
---|
64 | |
---|
65 | status = pthread_create( &Task_id, &attr, Task_1, NULL ); |
---|
66 | assert( !status ); |
---|
67 | |
---|
68 | puts( "Init: join with the other thread" ); |
---|
69 | status = pthread_join( Task_id, NULL ); |
---|
70 | assert( !status ); |
---|
71 | |
---|
72 | /* create a thread as SCHED_RR */ |
---|
73 | |
---|
74 | puts( "Init: create a thread of SCHED_RR with priority 120" ); |
---|
75 | status = pthread_attr_init( &attr ); |
---|
76 | assert( !status ); |
---|
77 | |
---|
78 | attr.schedpolicy = SCHED_RR; |
---|
79 | attr.schedparam.sched_priority = 120; |
---|
80 | |
---|
81 | status = pthread_create( &Task_id, &attr, Task_1, NULL ); |
---|
82 | assert( !status ); |
---|
83 | |
---|
84 | puts( "Init: join with the other thread" ); |
---|
85 | status = pthread_join( Task_id, NULL ); |
---|
86 | assert( !status ); |
---|
87 | |
---|
88 | /* create a thread as SCHED_OTHER */ |
---|
89 | |
---|
90 | puts( "Init: create a thread of SCHED_OTHER with priority 120" ); |
---|
91 | status = pthread_attr_init( &attr ); |
---|
92 | assert( !status ); |
---|
93 | |
---|
94 | attr.schedpolicy = SCHED_OTHER; |
---|
95 | attr.schedparam.sched_priority = 120; |
---|
96 | |
---|
97 | status = pthread_create( &Task_id, &attr, Task_1, NULL ); |
---|
98 | assert( !status ); |
---|
99 | |
---|
100 | puts( "Init: join with the other thread" ); |
---|
101 | status = pthread_join( Task_id, NULL ); |
---|
102 | assert( !status ); |
---|
103 | |
---|
104 | puts( "*** END OF POSIX TEST 11 ***" ); |
---|
105 | exit( 0 ); |
---|
106 | |
---|
107 | return NULL; /* just so the compiler thinks we returned something */ |
---|
108 | } |
---|