@@ -50,8 +50,8 @@ void k_stack_init(struct k_stack *stack, u32_t *buffer,
50
50
u32_t num_entries )
51
51
{
52
52
_waitq_init (& stack -> wait_q );
53
- stack -> base = buffer ;
54
- stack -> next = buffer ;
53
+ stack -> lock = ( struct k_spinlock ) {} ;
54
+ stack -> next = stack -> base = buffer ;
55
55
stack -> top = stack -> base + num_entries ;
56
56
57
57
SYS_TRACING_OBJ_INIT (k_stack , stack );
@@ -99,11 +99,11 @@ void k_stack_cleanup(struct k_stack *stack)
99
99
void _impl_k_stack_push (struct k_stack * stack , u32_t data )
100
100
{
101
101
struct k_thread * first_pending_thread ;
102
- u32_t key ;
102
+ k_spinlock_key_t key ;
103
103
104
104
__ASSERT (stack -> next != stack -> top , "stack is full" );
105
105
106
- key = irq_lock ( );
106
+ key = k_spin_lock ( & stack -> lock );
107
107
108
108
first_pending_thread = _unpend_first_thread (& stack -> wait_q );
109
109
@@ -112,12 +112,12 @@ void _impl_k_stack_push(struct k_stack *stack, u32_t data)
112
112
113
113
_set_thread_return_value_with_data (first_pending_thread ,
114
114
0 , (void * )data );
115
- _reschedule_irqlock ( key );
115
+ _reschedule ( & stack -> lock , key );
116
116
return ;
117
117
} else {
118
118
* (stack -> next ) = data ;
119
119
stack -> next ++ ;
120
- irq_unlock ( key );
120
+ k_spin_unlock ( & stack -> lock , key );
121
121
}
122
122
123
123
}
@@ -138,24 +138,24 @@ Z_SYSCALL_HANDLER(k_stack_push, stack_p, data)
138
138
139
139
int _impl_k_stack_pop (struct k_stack * stack , u32_t * data , s32_t timeout )
140
140
{
141
- u32_t key ;
141
+ k_spinlock_key_t key ;
142
142
int result ;
143
143
144
- key = irq_lock ( );
144
+ key = k_spin_lock ( & stack -> lock );
145
145
146
146
if (likely (stack -> next > stack -> base )) {
147
147
stack -> next -- ;
148
148
* data = * (stack -> next );
149
- irq_unlock ( key );
149
+ k_spin_unlock ( & stack -> lock , key );
150
150
return 0 ;
151
151
}
152
152
153
153
if (timeout == K_NO_WAIT ) {
154
- irq_unlock ( key );
154
+ k_spin_unlock ( & stack -> lock , key );
155
155
return - EBUSY ;
156
156
}
157
157
158
- result = _pend_curr_irqlock ( key , & stack -> wait_q , timeout );
158
+ result = _pend_curr ( & stack -> lock , key , & stack -> wait_q , timeout );
159
159
if (result == - EAGAIN ) {
160
160
return - EAGAIN ;
161
161
}
0 commit comments