File tree Expand file tree Collapse file tree 3 files changed +15
-49
lines changed Expand file tree Collapse file tree 3 files changed +15
-49
lines changed Original file line number Diff line number Diff line change @@ -119,37 +119,30 @@ int sem_post(FAR sem_t *sem)
119
119
120
120
int nxsem_post (FAR sem_t * sem )
121
121
{
122
- bool mutex ;
123
122
bool fastpath = true;
123
+ bool mutex ;
124
124
125
125
DEBUGASSERT (sem != NULL );
126
126
127
- /* We don't do atomic fast path in case of LIBC_ARCH_ATOMIC because that
128
- * uses spinlocks, which can't be called from userspace. Also in the kernel
129
- * taking the slow path directly is faster than locking first in here
130
- */
131
-
132
- #ifndef CONFIG_LIBC_ARCH_ATOMIC
133
-
134
127
mutex = NXSEM_IS_MUTEX (sem );
135
128
136
129
/* Disable fast path if priority protection is enabled on the semaphore */
137
130
138
- # ifdef CONFIG_PRIORITY_PROTECT
131
+ #ifdef CONFIG_PRIORITY_PROTECT
139
132
if ((sem -> flags & SEM_PRIO_MASK ) == SEM_PRIO_PROTECT )
140
133
{
141
134
fastpath = false;
142
135
}
143
- # endif
136
+ #endif
144
137
145
138
/* Disable fast path on a counting semaphore with priority inheritance */
146
139
147
- # ifdef CONFIG_PRIORITY_INHERITANCE
140
+ #ifdef CONFIG_PRIORITY_INHERITANCE
148
141
if (!mutex && (sem -> flags & SEM_PRIO_MASK ) != SEM_PRIO_NONE )
149
142
{
150
143
fastpath = false;
151
144
}
152
- # endif
145
+ #endif
153
146
154
147
while (fastpath )
155
148
{
@@ -181,10 +174,6 @@ int nxsem_post(FAR sem_t *sem)
181
174
return OK ;
182
175
}
183
176
}
184
- #else
185
- UNUSED (mutex );
186
- UNUSED (fastpath );
187
- #endif
188
177
189
178
return nxsem_post_slow (sem );
190
179
}
Original file line number Diff line number Diff line change @@ -107,8 +107,8 @@ int sem_trywait(FAR sem_t *sem)
107
107
108
108
int nxsem_trywait (FAR sem_t * sem )
109
109
{
110
- bool mutex ;
111
110
bool fastpath = true;
111
+ bool mutex ;
112
112
113
113
DEBUGASSERT (sem != NULL );
114
114
@@ -119,32 +119,25 @@ int nxsem_trywait(FAR sem_t *sem)
119
119
up_interrupt_context ());
120
120
#endif
121
121
122
- /* We don't do atomic fast path in case of LIBC_ARCH_ATOMIC because that
123
- * uses spinlocks, which can't be called from userspace. Also in the kernel
124
- * taking the slow path directly is faster than locking first in here
125
- */
126
-
127
- #ifndef CONFIG_LIBC_ARCH_ATOMIC
128
-
129
122
mutex = NXSEM_IS_MUTEX (sem );
130
123
131
124
/* Disable fast path if priority protection is enabled on the semaphore */
132
125
133
- # ifdef CONFIG_PRIORITY_PROTECT
126
+ #ifdef CONFIG_PRIORITY_PROTECT
134
127
if ((sem -> flags & SEM_PRIO_MASK ) == SEM_PRIO_PROTECT )
135
128
{
136
129
fastpath = false;
137
130
}
138
- # endif
131
+ #endif
139
132
140
133
/* Disable fast path on a counting semaphore with priority inheritance */
141
134
142
- # ifdef CONFIG_PRIORITY_INHERITANCE
135
+ #ifdef CONFIG_PRIORITY_INHERITANCE
143
136
if (!mutex && (sem -> flags & SEM_PRIO_MASK ) != SEM_PRIO_NONE )
144
137
{
145
138
fastpath = false;
146
139
}
147
- # endif
140
+ #endif
148
141
149
142
while (fastpath )
150
143
{
@@ -177,10 +170,5 @@ int nxsem_trywait(FAR sem_t *sem)
177
170
}
178
171
}
179
172
180
- #else
181
- UNUSED (mutex );
182
- UNUSED (fastpath );
183
- #endif
184
-
185
173
return nxsem_trywait_slow (sem );
186
174
}
Original file line number Diff line number Diff line change @@ -135,8 +135,8 @@ int sem_wait(FAR sem_t *sem)
135
135
136
136
int nxsem_wait (FAR sem_t * sem )
137
137
{
138
- bool mutex ;
139
138
bool fastpath = true;
139
+ bool mutex ;
140
140
141
141
DEBUGASSERT (sem != NULL );
142
142
@@ -147,32 +147,25 @@ int nxsem_wait(FAR sem_t *sem)
147
147
up_interrupt_context ());
148
148
#endif
149
149
150
- /* We don't do atomic fast path in case of LIBC_ARCH_ATOMIC because that
151
- * uses spinlocks, which can't be called from userspace. Also in the kernel
152
- * taking the slow path directly is faster than locking first in here
153
- */
154
-
155
- #ifndef CONFIG_LIBC_ARCH_ATOMIC
156
-
157
150
mutex = NXSEM_IS_MUTEX (sem );
158
151
159
152
/* Disable fast path if priority protection is enabled on the semaphore */
160
153
161
- # ifdef CONFIG_PRIORITY_PROTECT
154
+ #ifdef CONFIG_PRIORITY_PROTECT
162
155
if ((sem -> flags & SEM_PRIO_MASK ) == SEM_PRIO_PROTECT )
163
156
{
164
157
fastpath = false;
165
158
}
166
- # endif
159
+ #endif
167
160
168
161
/* Disable fast path on a counting semaphore with priority inheritance */
169
162
170
- # ifdef CONFIG_PRIORITY_INHERITANCE
163
+ #ifdef CONFIG_PRIORITY_INHERITANCE
171
164
if (!mutex && (sem -> flags & SEM_PRIO_MASK ) != SEM_PRIO_NONE )
172
165
{
173
166
fastpath = false;
174
167
}
175
- # endif
168
+ #endif
176
169
177
170
while (fastpath )
178
171
{
@@ -204,10 +197,6 @@ int nxsem_wait(FAR sem_t *sem)
204
197
return OK ;
205
198
}
206
199
}
207
- #else
208
- UNUSED (mutex );
209
- UNUSED (fastpath );
210
- #endif
211
200
212
201
return nxsem_wait_slow (sem );
213
202
}
You can’t perform that action at this time.
0 commit comments