You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2016/12/15 19:03:51 UTC

incubator-mynewt-core git commit: os; add owner task to eventq structure. Assert if os_eventq_get() is not done by owner.

Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop f2ed5c979 -> 58805cb7f


os; add owner task to eventq structure. Assert if os_eventq_get()
is not done by owner.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/58805cb7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/58805cb7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/58805cb7

Branch: refs/heads/develop
Commit: 58805cb7f10af51e7563a60e283c1b613be27157
Parents: f2ed5c9
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Thu Dec 15 11:02:47 2016 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Thu Dec 15 11:02:47 2016 -0800

----------------------------------------------------------------------
 kernel/os/include/os/os_eventq.h |  3 ++-
 kernel/os/src/os_eventq.c        | 13 ++++++++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/58805cb7/kernel/os/include/os/os_eventq.h
----------------------------------------------------------------------
diff --git a/kernel/os/include/os/os_eventq.h b/kernel/os/include/os/os_eventq.h
index 87b93ea..cfe0d34 100644
--- a/kernel/os/include/os/os_eventq.h
+++ b/kernel/os/include/os/os_eventq.h
@@ -41,7 +41,8 @@ struct os_event {
 #define OS_EVENT_QUEUED(__ev) ((__ev)->ev_queued)
 
 struct os_eventq {
-    struct os_task *evq_task;
+    struct os_task *evq_owner;  /* owner task */
+    struct os_task *evq_task;   /* sleeper; must be either NULL, or the owner */
     STAILQ_HEAD(, os_event) evq_list;
 };
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/58805cb7/kernel/os/src/os_eventq.c
----------------------------------------------------------------------
diff --git a/kernel/os/src/os_eventq.c b/kernel/os/src/os_eventq.c
index 1e76c7c..d443dfd 100644
--- a/kernel/os/src/os_eventq.c
+++ b/kernel/os/src/os_eventq.c
@@ -111,10 +111,21 @@ os_eventq_get(struct os_eventq *evq)
     os_sr_t sr;
     struct os_task *t;
 
+    t = os_sched_get_current_task();
+    if (evq->evq_owner != t) {
+        if (evq->evq_owner == NULL) {
+            evq->evq_owner = t;
+        } else {
+            /*
+             * A task is trying to read from event queue which is handled
+             * by another.
+             */
+            assert(0);
+        }
+    }
     OS_ENTER_CRITICAL(sr);
 pull_one:
     ev = STAILQ_FIRST(&evq->evq_list);
-    t = os_sched_get_current_task();
     if (ev) {
         STAILQ_REMOVE(&evq->evq_list, ev, os_event, ev_next);
         ev->ev_queued = 0;