2020-09-02 11:39:27 +02:00
|
|
|
From 219e01c2b9fb779e3682a24d361a8a9b672b551a Mon Sep 17 00:00:00 2001
|
2020-06-25 22:35:50 +02:00
|
|
|
From: Francisco Molina <femolina@uc.cl>
|
|
|
|
Date: Sun, 29 Mar 2020 12:11:53 +0200
|
2020-09-02 11:39:27 +02:00
|
|
|
Subject: [PATCH 4/9] kernel/openos/scheduler: use thread flags, restore
|
2020-06-25 22:35:50 +02:00
|
|
|
irq_state
|
|
|
|
|
|
|
|
Use thread_flags_wait_any to pause the scheduler. Set flag in
|
|
|
|
scheduler_push_task to trigger new task handling.
|
|
|
|
|
|
|
|
squash! kernel/openos/scheduler: use thread flags
|
|
|
|
---
|
|
|
|
kernel/openos/scheduler.c | 13 ++++++++++++-
|
|
|
|
kernel/scheduler.h | 2 +-
|
|
|
|
2 files changed, 13 insertions(+), 2 deletions(-)
|
|
|
|
|
|
|
|
diff --git a/kernel/openos/scheduler.c b/kernel/openos/scheduler.c
|
2020-09-02 11:39:27 +02:00
|
|
|
index f52f35d4..41be092f 100644
|
2020-06-25 22:35:50 +02:00
|
|
|
--- a/kernel/openos/scheduler.c
|
|
|
|
+++ b/kernel/openos/scheduler.c
|
|
|
|
@@ -10,6 +10,11 @@
|
|
|
|
#include "debugpins.h"
|
|
|
|
#include "leds.h"
|
|
|
|
|
|
|
|
+#include "openwsn.h"
|
|
|
|
+#include "thread.h"
|
|
|
|
+
|
|
|
|
+#define OPENWSN_SCHEDULER_FLAG (1u << 8)
|
|
|
|
+
|
|
|
|
//=========================== variables =======================================
|
|
|
|
|
|
|
|
scheduler_vars_t scheduler_vars;
|
2020-09-02 11:39:27 +02:00
|
|
|
@@ -36,8 +41,11 @@ void scheduler_init(void) {
|
2020-06-25 22:35:50 +02:00
|
|
|
SCHEDULER_ENABLE_INTERRUPT();
|
|
|
|
}
|
|
|
|
|
|
|
|
-void scheduler_start(void) {
|
|
|
|
+void scheduler_start(unsigned state) {
|
|
|
|
taskList_item_t* pThisTask;
|
|
|
|
+
|
|
|
|
+ irq_restore(state);
|
|
|
|
+
|
|
|
|
while (1) {
|
|
|
|
while(scheduler_vars.task_list!=NULL) {
|
|
|
|
// there is still at least one task in the linked-list of tasks
|
2020-09-02 11:39:27 +02:00
|
|
|
@@ -66,6 +74,7 @@ void scheduler_start(void) {
|
2020-06-25 22:35:50 +02:00
|
|
|
}
|
|
|
|
debugpins_task_clr();
|
|
|
|
board_sleep();
|
|
|
|
+ thread_flags_wait_any(OPENWSN_SCHEDULER_FLAG);
|
|
|
|
debugpins_task_set(); // IAR should halt here if nothing to do
|
|
|
|
}
|
|
|
|
}
|
2020-09-02 11:39:27 +02:00
|
|
|
@@ -114,6 +123,8 @@ void scheduler_push_task(task_cbt cb, task_prio_t prio) {
|
|
|
|
#endif
|
2020-06-25 22:35:50 +02:00
|
|
|
|
|
|
|
ENABLE_INTERRUPTS();
|
|
|
|
+ thread_t *thread = (thread_t*) thread_get(openwsn_get_pid());
|
|
|
|
+ thread_flags_set(thread, OPENWSN_SCHEDULER_FLAG);
|
|
|
|
}
|
|
|
|
|
2020-09-02 11:39:27 +02:00
|
|
|
|
2020-06-25 22:35:50 +02:00
|
|
|
diff --git a/kernel/scheduler.h b/kernel/scheduler.h
|
2020-09-02 11:39:27 +02:00
|
|
|
index dd035a22..51b6d9cb 100644
|
2020-06-25 22:35:50 +02:00
|
|
|
--- a/kernel/scheduler.h
|
|
|
|
+++ b/kernel/scheduler.h
|
2020-09-02 11:39:27 +02:00
|
|
|
@@ -47,7 +47,7 @@ typedef void (*task_cbt)(void);
|
2020-06-25 22:35:50 +02:00
|
|
|
//=========================== prototypes ======================================
|
|
|
|
|
|
|
|
void scheduler_init(void);
|
|
|
|
-void scheduler_start(void);
|
|
|
|
+void scheduler_start(unsigned state);
|
|
|
|
void scheduler_push_task(task_cbt task_cb, task_prio_t prio);
|
|
|
|
|
2020-09-02 11:39:27 +02:00
|
|
|
#if SCHEDULER_DEBUG_ENABLE
|
2020-06-25 22:35:50 +02:00
|
|
|
--
|
2020-09-02 11:39:27 +02:00
|
|
|
2.28.0
|
2020-06-25 22:35:50 +02:00
|
|
|
|