1 | /* |
---|
2 | * Semaphore Obtain in Critical Section |
---|
3 | * |
---|
4 | * COPYRIGHT (c) 1989-2011. |
---|
5 | * On-Line Applications Research Corporation (OAR). |
---|
6 | * |
---|
7 | * The license and distribution terms for this file may be |
---|
8 | * found in the file LICENSE in this distribution or at |
---|
9 | * http://www.rtems.org/license/LICENSE. |
---|
10 | */ |
---|
11 | |
---|
12 | #include <rtems/bspIo.h> |
---|
13 | |
---|
14 | #define CONFIGURE_MAXIMUM_SEMAPHORES 10 |
---|
15 | |
---|
16 | #define FATAL_ERROR_TEST_NAME "3" |
---|
17 | #define FATAL_ERROR_DESCRIPTION "Core Mutex obtain in critical section" |
---|
18 | #define FATAL_ERROR_EXPECTED_SOURCE INTERNAL_ERROR_CORE |
---|
19 | #define FATAL_ERROR_EXPECTED_ERROR \ |
---|
20 | INTERNAL_ERROR_BAD_THREAD_DISPATCH_DISABLE_LEVEL |
---|
21 | |
---|
22 | void force_error(void) |
---|
23 | { |
---|
24 | |
---|
25 | rtems_status_code status; |
---|
26 | rtems_id mutex; |
---|
27 | |
---|
28 | status = rtems_semaphore_create( |
---|
29 | rtems_build_name( 'S','0',' ',' '), |
---|
30 | 0, |
---|
31 | RTEMS_LOCAL| |
---|
32 | RTEMS_SIMPLE_BINARY_SEMAPHORE, |
---|
33 | 0, |
---|
34 | &mutex |
---|
35 | ); |
---|
36 | directive_failed( status, "rtems_semaphore_create of S0"); |
---|
37 | printk("Create semaphore S0\n"); |
---|
38 | |
---|
39 | printk("Obtain semaphore in dispatching critical section\n"); |
---|
40 | _Thread_Dispatch_disable(); |
---|
41 | status = rtems_semaphore_obtain( mutex, RTEMS_WAIT, RTEMS_NO_TIMEOUT ); |
---|
42 | /* !!! SHOULD NOT RETURN FROM THE ABOVE CALL */ |
---|
43 | |
---|
44 | rtems_test_assert( 0 ); |
---|
45 | /* we will not run this far */ |
---|
46 | } |
---|