OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [kernel/] [v2_0/] [tests/] [release.cxx] - Blame information for rev 773

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
//==========================================================================
2
//
3
//        release.cxx
4
//
5
//        Thread release test
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):     nickg
44
// Contributors:    nickg
45
// Date:          1998-04-24
46
// Description:   Tests the functionality of thread release().
47
//####DESCRIPTIONEND####
48
 
49
#include <pkgconf/kernel.h>
50
 
51
#include <cyg/kernel/thread.hxx>
52
#include <cyg/kernel/thread.inl>
53
#include <cyg/kernel/sched.hxx>
54
#include <cyg/kernel/mutex.hxx>
55
#include <cyg/kernel/sema.hxx>
56
 
57
#include <cyg/infra/testcase.h>
58
 
59
#include <cyg/kernel/sched.inl>
60
 
61
#define NTHREADS 2
62
 
63
#include "testaux.hxx"
64
 
65
static Cyg_Binary_Semaphore s0, s1;
66
 
67
static void entry0( CYG_ADDRWORD data )
68
{
69
    Cyg_Thread *self = Cyg_Thread::self();
70
 
71
    if (!s0.wait() )
72
    {
73
        if( self->get_wake_reason() != Cyg_Thread::BREAK )
74
            CYG_TEST_FAIL_FINISH("Wake reason not BREAK");
75
    }
76
    else
77
    {
78
            CYG_TEST_FAIL_FINISH("Thread not released");
79
    }
80
 
81
    s1.post();
82
 
83
    self->exit();
84
}
85
 
86
 
87
static void entry1( CYG_ADDRWORD data )
88
{
89
    Cyg_Thread *self = Cyg_Thread::self();
90
 
91
    // Give the other thread a chance to wait in SMP systems.
92
    for( int i = 0; i < 100; i++ )
93
        self->yield();
94
 
95
    thread[0]->release();
96
 
97
    s1.wait();
98
 
99
    CYG_TEST_PASS_FINISH("Release OK");
100
 
101
    Cyg_Thread::self()->exit();
102
}
103
 
104
void release_main(void)
105
{
106
    CYG_TEST_INIT();
107
 
108
    new_thread( entry0, 0);
109
    new_thread( entry1, 1);
110
 
111
    thread[0]->set_priority(5);
112
    thread[1]->set_priority(6);
113
 
114
    Cyg_Scheduler::start();
115
 
116
    CYG_TEST_FAIL_FINISH("Not reached");
117
 
118
}
119
 
120
externC void
121
cyg_start( void )
122
{
123
#ifdef CYGSEM_HAL_STOP_CONSTRUCTORS_ON_FLAG
124
    cyg_hal_invoke_constructors();
125
#endif
126
    release_main();
127
}
128
 
129
// EOF release.cxx

powered by: WebSVN 2.1.0

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