Skip to content

Commit dfa325a

Browse files
committed
update wq
1 parent 9a42eb0 commit dfa325a

File tree

3 files changed

+15
-35
lines changed

3 files changed

+15
-35
lines changed

Diff for: components/drivers/ipc/workqueue.c

+12-23
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ static rt_err_t _workqueue_submit_work(struct rt_workqueue *queue,
9494
struct rt_work *work, rt_tick_t ticks)
9595
{
9696
rt_base_t level;
97-
rt_err_t err;
97+
rt_err_t err = RT_EOK;
9898

9999
level = rt_spin_lock_irqsave(&(queue->spinlock));
100100

@@ -113,13 +113,7 @@ static rt_err_t _workqueue_submit_work(struct rt_workqueue *queue,
113113
{
114114
/* resume work thread, and do a re-schedule if succeed */
115115
rt_thread_resume(queue->work_thread);
116-
rt_spin_unlock_irqrestore(&(queue->spinlock), level);
117116
}
118-
else
119-
{
120-
rt_spin_unlock_irqrestore(&(queue->spinlock), level);
121-
}
122-
return RT_EOK;
123117
}
124118
else if (ticks < RT_TICK_MAX / 2)
125119
{
@@ -139,12 +133,14 @@ static rt_err_t _workqueue_submit_work(struct rt_workqueue *queue,
139133
rt_list_insert_after(queue->delayed_list.prev, &(work->list));
140134

141135
err = rt_timer_start(&(work->timer));
142-
rt_spin_unlock_irqrestore(&(queue->spinlock), level);
143-
144-
return err;
145136
}
137+
else
138+
{
139+
err = - RT_ERROR;
140+
}
141+
146142
rt_spin_unlock_irqrestore(&(queue->spinlock), level);
147-
return -RT_ERROR;
143+
return err;
148144
}
149145

150146
static rt_err_t _workqueue_cancel_work(struct rt_workqueue *queue, struct rt_work *work)
@@ -160,14 +156,14 @@ static rt_err_t _workqueue_cancel_work(struct rt_workqueue *queue, struct rt_wor
160156
{
161157
if ((err = rt_timer_stop(&(work->timer))) != RT_EOK)
162158
{
163-
rt_spin_unlock_irqrestore(&(queue->spinlock), level);
164-
return err;
159+
goto exit;
165160
}
166161
rt_timer_detach(&(work->timer));
167162
work->flags &= ~RT_WORK_STATE_SUBMITTING;
168163
}
169164
err = queue->work_current != work ? RT_EOK : -RT_EBUSY;
170165
work->workqueue = RT_NULL;
166+
exit:
171167
rt_spin_unlock_irqrestore(&(queue->spinlock), level);
172168
return err;
173169
}
@@ -200,12 +196,9 @@ static void _delayed_work_timeout_handler(void *parameter)
200196
{
201197
/* resume work thread, and do a re-schedule if succeed */
202198
rt_thread_resume(queue->work_thread);
203-
rt_spin_unlock_irqrestore(&(queue->spinlock), level);
204-
}
205-
else
206-
{
207-
rt_spin_unlock_irqrestore(&(queue->spinlock), level);
208199
}
200+
201+
rt_spin_unlock_irqrestore(&(queue->spinlock), level);
209202
}
210203

211204
/**
@@ -358,13 +351,9 @@ rt_err_t rt_workqueue_urgent_work(struct rt_workqueue *queue, struct rt_work *wo
358351
{
359352
/* resume work thread, and do a re-schedule if succeed */
360353
rt_thread_resume(queue->work_thread);
361-
rt_spin_unlock_irqrestore(&(queue->spinlock), level);
362-
}
363-
else
364-
{
365-
rt_spin_unlock_irqrestore(&(queue->spinlock), level);
366354
}
367355

356+
rt_spin_unlock_irqrestore(&(queue->spinlock), level);
368357
return RT_EOK;
369358
}
370359

Diff for: include/rtdef.h

+3-4
Original file line numberDiff line numberDiff line change
@@ -579,14 +579,13 @@ struct rt_object_information
579579
*/
580580
#define RT_TIMER_FLAG_DEACTIVATED 0x0 /**< timer is deactive */
581581
#define RT_TIMER_FLAG_ACTIVATED 0x1 /**< timer is active */
582-
#define RT_TIMER_FLAG_PROCESSING 0x2 /**< timer's timeout fuction is processing */
583582
#define RT_TIMER_FLAG_ONE_SHOT 0x0 /**< one shot timer */
584-
#define RT_TIMER_FLAG_PERIODIC 0x4 /**< periodic timer */
583+
#define RT_TIMER_FLAG_PERIODIC 0x2 /**< periodic timer */
585584

586585
#define RT_TIMER_FLAG_HARD_TIMER 0x0 /**< hard timer,the timer's callback function will be called in tick isr. */
587-
#define RT_TIMER_FLAG_SOFT_TIMER 0x8 /**< soft timer,the timer's callback function will be called in timer thread. */
586+
#define RT_TIMER_FLAG_SOFT_TIMER 0x4 /**< soft timer,the timer's callback function will be called in timer thread. */
588587
#define RT_TIMER_FLAG_THREAD_TIMER \
589-
(0x10 | RT_TIMER_FLAG_HARD_TIMER) /**< thread timer that cooperates with scheduler directly */
588+
(0x8 | RT_TIMER_FLAG_HARD_TIMER) /**< thread timer that cooperates with scheduler directly */
590589

591590
#define RT_TIMER_CTRL_SET_TIME 0x0 /**< set timer control command */
592591
#define RT_TIMER_CTRL_GET_TIME 0x1 /**< get timer control command */

Diff for: src/timer.c

-8
Original file line numberDiff line numberDiff line change
@@ -413,11 +413,6 @@ static rt_err_t _timer_start(rt_list_t *timer_list, rt_timer_t timer)
413413
unsigned int tst_nr;
414414
static unsigned int random_nr;
415415

416-
if (timer->parent.flag & RT_TIMER_FLAG_PROCESSING)
417-
{
418-
return -RT_ERROR;
419-
}
420-
421416
/* remove timer from list */
422417
_timer_remove(timer);
423418
/* change status of timer */
@@ -526,7 +521,6 @@ static void _timer_check(rt_list_t *timer_list, struct rt_spinlock *lock)
526521
t->parent.flag &= ~RT_TIMER_FLAG_ACTIVATED;
527522
}
528523

529-
t->parent.flag |= RT_TIMER_FLAG_PROCESSING;
530524
/* add timer to temporary list */
531525
rt_list_insert_after(&list, &(t->row[RT_TIMER_SKIP_LIST_LEVEL - 1]));
532526

@@ -539,8 +533,6 @@ static void _timer_check(rt_list_t *timer_list, struct rt_spinlock *lock)
539533

540534
level = rt_spin_lock_irqsave(lock);
541535

542-
t->parent.flag &= ~RT_TIMER_FLAG_PROCESSING;
543-
544536
/* Check whether the timer object is detached or started again */
545537
if (rt_list_isempty(&list))
546538
{

0 commit comments

Comments
 (0)