1 | /* Task_1 |
---|
2 | * |
---|
3 | * This routine serves as a test task. |
---|
4 | * |
---|
5 | * Input parameters: |
---|
6 | * argument - task argument |
---|
7 | * |
---|
8 | * Output parameters: NONE |
---|
9 | * |
---|
10 | * COPYRIGHT (c) 1989-1997. |
---|
11 | * On-Line Applications Research Corporation (OAR). |
---|
12 | * Copyright assigned to U.S. Government, 1994. |
---|
13 | * |
---|
14 | * The license and distribution terms for this file may in |
---|
15 | * the file LICENSE in this distribution or at |
---|
16 | * http://www.OARcorp.com/rtems/license.html. |
---|
17 | * |
---|
18 | * $Id$ |
---|
19 | */ |
---|
20 | |
---|
21 | #include "system.h" |
---|
22 | |
---|
23 | void *Task_1( |
---|
24 | void *argument |
---|
25 | ) |
---|
26 | { |
---|
27 | int status; |
---|
28 | |
---|
29 | /* wait for a condition variable signal from Init */ |
---|
30 | |
---|
31 | Task_id = pthread_self(); |
---|
32 | printf( "Task_1: ID is 0x%08x\n", Task_id ); |
---|
33 | |
---|
34 | status = pthread_mutex_init( &Mutex_id, NULL ); |
---|
35 | assert( !status ); |
---|
36 | |
---|
37 | status = pthread_mutex_lock( &Mutex_id ); |
---|
38 | assert( !status ); |
---|
39 | |
---|
40 | puts( "Task_1: pthread_cond_wait" ); |
---|
41 | status = pthread_cond_wait( &Cond1_id, &Mutex_id ); |
---|
42 | assert( !status ); |
---|
43 | |
---|
44 | puts( "Task_1: back from pthread_cond_wait release mutex" ); |
---|
45 | status = pthread_mutex_unlock( &Mutex_id ); |
---|
46 | assert( !status ); |
---|
47 | |
---|
48 | /* wait for a condition variable broadcast from Init */ |
---|
49 | |
---|
50 | status = pthread_mutex_lock( &Mutex_id ); |
---|
51 | assert( !status ); |
---|
52 | |
---|
53 | puts( "Task_1: pthread_cond_wait" ); |
---|
54 | status = pthread_cond_wait( &Cond1_id, &Mutex_id ); |
---|
55 | assert( !status ); |
---|
56 | |
---|
57 | puts( "Task_1: back from pthread_cond_wait release mutex" ); |
---|
58 | status = pthread_mutex_unlock( &Mutex_id ); |
---|
59 | assert( !status ); |
---|
60 | |
---|
61 | puts( "Task_1: task exit" ); |
---|
62 | pthread_exit( NULL ); |
---|
63 | |
---|
64 | return NULL; /* just so the compiler thinks we returned something */ |
---|
65 | } |
---|