1 | /* |
---|
2 | * SuperCore Barrier Handler |
---|
3 | * |
---|
4 | * DESCRIPTION: |
---|
5 | * |
---|
6 | * This package is part of the implementation of the SuperCore Barrier Handler. |
---|
7 | * |
---|
8 | * COPYRIGHT (c) 1989-2006. |
---|
9 | * On-Line Applications Research Corporation (OAR). |
---|
10 | * |
---|
11 | * The license and distribution terms for this file may be |
---|
12 | * found in the file LICENSE in this distribution or at |
---|
13 | * http://www.rtems.com/license/LICENSE. |
---|
14 | */ |
---|
15 | |
---|
16 | #if HAVE_CONFIG_H |
---|
17 | #include "config.h" |
---|
18 | #endif |
---|
19 | |
---|
20 | #include <rtems/system.h> |
---|
21 | #include <rtems/score/isr.h> |
---|
22 | #include <rtems/score/corebarrier.h> |
---|
23 | #include <rtems/score/states.h> |
---|
24 | #include <rtems/score/thread.h> |
---|
25 | #include <rtems/score/threadq.h> |
---|
26 | |
---|
27 | /* |
---|
28 | * _CORE_barrier_Release |
---|
29 | * |
---|
30 | * Input parameters: |
---|
31 | * the_barrier - the barrier to be flushed |
---|
32 | * id - id of the object for a remote unblock |
---|
33 | * api_barrier_mp_support - api dependent MP support actions |
---|
34 | * |
---|
35 | * Output parameters: |
---|
36 | * CORE_BARRIER_STATUS_SUCCESSFUL - if successful |
---|
37 | * core error code - if unsuccessful |
---|
38 | * |
---|
39 | * Output parameters: |
---|
40 | * returns number of threads unblocked |
---|
41 | */ |
---|
42 | |
---|
43 | uint32_t _CORE_barrier_Release( |
---|
44 | CORE_barrier_Control *the_barrier, |
---|
45 | #if defined(RTEMS_MULTIPROCESSING) |
---|
46 | Objects_Id id, |
---|
47 | CORE_barrier_API_mp_support_callout api_barrier_mp_support |
---|
48 | #else |
---|
49 | Objects_Id id __attribute__((unused)), |
---|
50 | CORE_barrier_API_mp_support_callout api_barrier_mp_support __attribute__((unused)) |
---|
51 | #endif |
---|
52 | ) |
---|
53 | { |
---|
54 | Thread_Control *the_thread; |
---|
55 | uint32_t count; |
---|
56 | |
---|
57 | count = 0; |
---|
58 | while ( (the_thread = _Thread_queue_Dequeue(&the_barrier->Wait_queue)) ) { |
---|
59 | #if defined(RTEMS_MULTIPROCESSING) |
---|
60 | if ( !_Objects_Is_local_id( the_thread->Object.id ) ) |
---|
61 | (*api_barrier_mp_support) ( the_thread, id ); |
---|
62 | #endif |
---|
63 | count++; |
---|
64 | } |
---|
65 | the_barrier->number_of_waiting_threads = 0; |
---|
66 | return count; |
---|
67 | } |
---|