source: rtems/testsuites/psxtests/psx05/task.c @ ce78b894

4.104.114.84.95
Last change on this file since ce78b894 was ce78b894, checked in by Joel Sherrill <joel.sherrill@…>, on 07/04/96 at 17:38:55

added test case for timeout using pthread_mutex_timedlock

  • Property mode set to 100644
File size: 1.4 KB
Line 
1/*  Task_1_through_3
2 *
3 *  This routine serves as a test task.  It verifies the basic task
4 *  switching capabilities of the executive.
5 *
6 *  Input parameters:
7 *    argument - task argument
8 *
9 *  Output parameters:  NONE
10 *
11 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
12 *  On-Line Applications Research Corporation (OAR).
13 *  All rights assigned to U.S. Government, 1994.
14 *
15 *  This material may be reproduced by or for the U.S. Government pursuant
16 *  to the copyright license under the clause at DFARS 252.227-7013.  This
17 *  notice must appear in all copies of this file and its derivatives.
18 *
19 *  $Id$
20 */
21
22#include "system.h"
23#include <errno.h>
24
25void *Task_1_through_3(
26  void *argument
27)
28{
29  int status;
30
31  printf( "Task: pthread_mutex_trylock already locked\n" );
32  status = pthread_mutex_trylock( &Mutex_id );
33  if ( status != EBUSY )
34    printf( "status = %d\n", status );
35  assert( status == EBUSY );
36
37  printf( "Task: pthread_mutex_lock unavailable\n" );
38  status = pthread_mutex_lock( &Mutex_id );
39  if ( status )
40    printf( "status = %d\n", status );
41  assert( !status );
42
43     /* switch to init */
44
45  printf( "Task: mutex acquired\n" );
46
47  printf( "Task: sleep for 2 seconds\n" );
48  sleep( 2 );
49
50     /* switch to init */
51
52  printf( "Task: exit\n" );
53  pthread_exit( NULL );
54
55     /* switch to Init */
56
57  return NULL; /* just so the compiler thinks we returned something */
58}
Note: See TracBrowser for help on using the repository browser.