blob: 7428666fc3c9d141dd05978ca744d296034fadaf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
/***************************************************************************
* Copyright (c) 2024 Microsoft Corporation
* Copyright (c) 2026-present Eclipse ThreadX contributors
*
* This program and the accompanying materials are made available under the
* terms of the MIT License which is available at
* https://opensource.org/licenses/MIT.
*
* SPDX-License-Identifier: MIT
**************************************************************************/
/**************************************************************************/
/**************************************************************************/
/** */
/** ThreadX Component */
/** */
/** Thread */
/** */
/**************************************************************************/
/**************************************************************************/
#define TX_SOURCE_CODE
#define TX_THREAD_SMP_SOURCE_CODE
/* Include necessary system files. */
#include "tx_api.h"
#include "tx_thread.h"
#include "tx_timer.h"
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _tx_thread_smp_unprotect SMP/Linux/GCC */
/* 6.1 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This function releases previously obtained protection. The supplied */
/* previous interrupt posture is restored. */
/* */
/* INPUT */
/* */
/* Previous interrupt posture */
/* */
/* OUTPUT */
/* */
/* None */
/* */
/* CALLS */
/* */
/* pthread_self */
/* */
/* CALLED BY */
/* */
/* ThreadX Source */
/* */
/**************************************************************************/
void _tx_thread_smp_unprotect(UINT new_interrupt_posture)
{
UINT core;
pthread_t current_thread_id;
/* Lock Linux mutex. */
_tx_linux_mutex_obtain(&_tx_linux_mutex);
/* Pickup the current thread ID. */
current_thread_id = pthread_self();
/* Pickup the current core. */
core = _tx_thread_smp_core_get();
/* Determine if this core owns the protection. */
if (_tx_thread_smp_protection.tx_thread_smp_protect_core == core)
{
/* Yes, this core owns the protection. */
/* Decrement the protection count. */
_tx_thread_smp_protection.tx_thread_smp_protect_count--;
/* Is the protection still in force? */
if (_tx_thread_smp_protection.tx_thread_smp_protect_count == 0)
{
/* Restore the global interrupt disable value. */
_tx_linux_global_int_disabled_flag = new_interrupt_posture;
/* Determine if the preemption disable flag is set. */
if (_tx_thread_preempt_disable == 0)
{
/* Release the protection. */
/* Indicate the protection is no longer in force. */
_tx_thread_smp_protection.tx_thread_smp_protect_in_force = TX_FALSE;
_tx_thread_smp_protection.tx_thread_smp_protect_thread = TX_NULL;
_tx_thread_smp_protection.tx_thread_smp_protect_core = 0xFFFFFFFF;
_tx_thread_smp_protection.tx_thread_smp_protect_linux_thread_id = 0;
/* Debug entry. */
_tx_linux_debug_entry_insert("UNPROTECT-keep", __FILE__, __LINE__);
}
else
{
/* Debug entry. */
_tx_linux_debug_entry_insert("UNPROTECT-released", __FILE__, __LINE__);
}
}
else
{
/* Debug entry. */
_tx_linux_debug_entry_insert("UNPROTECT-nested", __FILE__, __LINE__);
}
/* Only release the critical section. */
_tx_linux_mutex_release(&_tx_linux_mutex);
}
/* Release the critical section. */
_tx_linux_mutex_release(&_tx_linux_mutex);
}
|