1 |
1254 |
phoenix |
/*=================================================================
|
2 |
|
|
//
|
3 |
|
|
// ksched1.c
|
4 |
|
|
//
|
5 |
|
|
// Kernel C API Sched test 1
|
6 |
|
|
//
|
7 |
|
|
//==========================================================================
|
8 |
|
|
//####ECOSGPLCOPYRIGHTBEGIN####
|
9 |
|
|
// -------------------------------------------
|
10 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
11 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
12 |
|
|
//
|
13 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
14 |
|
|
// the terms of the GNU General Public License as published by the Free
|
15 |
|
|
// Software Foundation; either version 2 or (at your option) any later version.
|
16 |
|
|
//
|
17 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
18 |
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
19 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
20 |
|
|
// for more details.
|
21 |
|
|
//
|
22 |
|
|
// You should have received a copy of the GNU General Public License along
|
23 |
|
|
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
24 |
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
25 |
|
|
//
|
26 |
|
|
// As a special exception, if other files instantiate templates or use macros
|
27 |
|
|
// or inline functions from this file, or you compile this file and link it
|
28 |
|
|
// with other works to produce a work based on this file, this file does not
|
29 |
|
|
// by itself cause the resulting work to be covered by the GNU General Public
|
30 |
|
|
// License. However the source code for this file must still be made available
|
31 |
|
|
// in accordance with section (3) of the GNU General Public License.
|
32 |
|
|
//
|
33 |
|
|
// This exception does not invalidate any other reasons why a work based on
|
34 |
|
|
// this file might be covered by the GNU General Public License.
|
35 |
|
|
//
|
36 |
|
|
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
|
37 |
|
|
// at http://sources.redhat.com/ecos/ecos-license/
|
38 |
|
|
// -------------------------------------------
|
39 |
|
|
//####ECOSGPLCOPYRIGHTEND####
|
40 |
|
|
//==========================================================================
|
41 |
|
|
//#####DESCRIPTIONBEGIN####
|
42 |
|
|
//
|
43 |
|
|
// Author(s): dsm
|
44 |
|
|
// Contributors: dsm
|
45 |
|
|
// Date: 1998-03-23
|
46 |
|
|
// Description: Simply checks the world starts
|
47 |
|
|
//####DESCRIPTIONEND####
|
48 |
|
|
*/
|
49 |
|
|
|
50 |
|
|
#include <cyg/hal/hal_arch.h> // CYGNUM_HAL_STACK_SIZE_TYPICAL
|
51 |
|
|
|
52 |
|
|
#include <cyg/kernel/kapi.h>
|
53 |
|
|
|
54 |
|
|
#include <cyg/infra/testcase.h>
|
55 |
|
|
|
56 |
|
|
#ifdef CYGFUN_KERNEL_API_C
|
57 |
|
|
|
58 |
|
|
#include "testaux.h"
|
59 |
|
|
|
60 |
|
|
#define NTHREADS 2
|
61 |
|
|
#define STACKSIZE CYGNUM_HAL_STACK_SIZE_TYPICAL
|
62 |
|
|
|
63 |
|
|
static cyg_handle_t thread[NTHREADS];
|
64 |
|
|
|
65 |
|
|
static cyg_thread thread_obj[NTHREADS];
|
66 |
|
|
static char stack[NTHREADS][STACKSIZE];
|
67 |
|
|
|
68 |
|
|
|
69 |
|
|
static void entry0( cyg_addrword_t data )
|
70 |
|
|
{
|
71 |
|
|
CHECK( 222 == (int)data );
|
72 |
|
|
CYG_TEST_PASS_FINISH( "Kernel C API Sched 1 OK");
|
73 |
|
|
}
|
74 |
|
|
|
75 |
|
|
void ksched1_main(void)
|
76 |
|
|
{
|
77 |
|
|
CYG_TEST_INIT();
|
78 |
|
|
|
79 |
|
|
cyg_thread_create( 4, entry0 , (cyg_addrword_t)222, "ksched1",
|
80 |
|
|
(void *)stack[0], STACKSIZE, &thread[0], &thread_obj[0]);
|
81 |
|
|
cyg_thread_resume(thread[0]);
|
82 |
|
|
|
83 |
|
|
cyg_scheduler_start();
|
84 |
|
|
|
85 |
|
|
CYG_TEST_FAIL_FINISH("Not reached");
|
86 |
|
|
}
|
87 |
|
|
|
88 |
|
|
externC void
|
89 |
|
|
cyg_start( void )
|
90 |
|
|
{
|
91 |
|
|
ksched1_main();
|
92 |
|
|
}
|
93 |
|
|
|
94 |
|
|
#else /* def CYGFUN_KERNEL_API_C */
|
95 |
|
|
externC void
|
96 |
|
|
cyg_start( void )
|
97 |
|
|
{
|
98 |
|
|
CYG_TEST_INIT();
|
99 |
|
|
CYG_TEST_NA("Kernel C API layer disabled");
|
100 |
|
|
}
|
101 |
|
|
#endif /* def CYGFUN_KERNEL_API_C */
|
102 |
|
|
|
103 |
|
|
/* EOF ksched1.c */
|