You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by st...@apache.org on 2016/05/05 15:18:25 UTC

[1/2] incubator-mynewt-core git commit: add eventq_poll(), which will poll multiple event queues, with a timeout.

Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop 8051041b8 -> e080c3c4c


add eventq_poll(), which will poll multiple event queues, with a timeout.


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/5c87fec5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/5c87fec5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/5c87fec5

Branch: refs/heads/develop
Commit: 5c87fec5954400eba4f3b102fc3f027662f13b2c
Parents: 8ddc20e
Author: Sterling Hughes <st...@apache.org>
Authored: Thu May 5 08:18:01 2016 -0700
Committer: Sterling Hughes <st...@apache.org>
Committed: Thu May 5 08:18:01 2016 -0700

----------------------------------------------------------------------
 libs/os/include/os/os_eventq.h |  1 +
 libs/os/src/os_eventq.c        | 82 +++++++++++++++++++++++++++++++++++--
 2 files changed, 80 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5c87fec5/libs/os/include/os/os_eventq.h
----------------------------------------------------------------------
diff --git a/libs/os/include/os/os_eventq.h b/libs/os/include/os/os_eventq.h
index 2111373..b261145 100644
--- a/libs/os/include/os/os_eventq.h
+++ b/libs/os/include/os/os_eventq.h
@@ -43,6 +43,7 @@ struct os_eventq {
 void os_eventq_init(struct os_eventq *);
 void os_eventq_put(struct os_eventq *, struct os_event *);
 struct os_event *os_eventq_get(struct os_eventq *);
+struct os_event *os_eventq_poll(struct os_eventq **, int, os_time_t);
 void os_eventq_remove(struct os_eventq *, struct os_event *);
 
 #endif /* _OS_EVENTQ_H */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5c87fec5/libs/os/src/os_eventq.c
----------------------------------------------------------------------
diff --git a/libs/os/src/os_eventq.c b/libs/os/src/os_eventq.c
index 87085ca..9645a0d 100644
--- a/libs/os/src/os_eventq.c
+++ b/libs/os/src/os_eventq.c
@@ -47,12 +47,20 @@ os_eventq_put(struct os_eventq *evq, struct os_event *ev)
     ev->ev_queued = 1;
     STAILQ_INSERT_TAIL(&evq->evq_list, ev, ev_next);
 
-    /* If task waiting on event, wake it up. */
     resched = 0;
     if (evq->evq_task) {
-        os_sched_wakeup(evq->evq_task);
+        /* If task waiting on event, wake it up.
+         * Check if task is sleeping, because another event 
+         * queue may have woken this task up beforehand.
+         */
+        if (evq->evq_task->t_state == OS_TASK_SLEEP) {
+            os_sched_wakeup(evq->evq_task);
+            resched = 1;
+        }
+        /* Either way, NULL out the task, because the task will
+         * be awake upon exit of this function.
+         */
         evq->evq_task = NULL;
-        resched = 1;
     }
 
     OS_EXIT_CRITICAL(sr);
@@ -90,6 +98,74 @@ pull_one:
     return (ev);
 }
 
+/**
+ * Poll the list of event queues specified by the evq parameter 
+ * (size nevqs), and return the "first" event available on any of 
+ * the queues.  Event queues are searched in the order that they 
+ * are passed in the array.
+ *
+ * @param evq Array of event queues
+ * @param nevqs Number of event queues in evq
+ * @param timo Timeout, forever if OS_WAIT_FOREVER is passed to poll.
+ *
+ * @return An event, or NULL if no events available
+ */
+struct os_event *
+os_eventq_poll(struct os_eventq **evq, int nevqs, os_time_t timo)
+{
+    struct os_event *ev;
+    struct os_task *cur_t;
+    int i, j;
+    os_sr_t sr;
+
+    OS_ENTER_CRITICAL(sr);
+    cur_t = os_sched_get_current_task();
+
+    for (i = 0; i < nevqs; i++) {
+        ev = STAILQ_FIRST(&evq[i]->evq_list);
+        if (ev) {
+            STAILQ_REMOVE(&evq[i]->evq_list, ev, os_event, ev_next);
+            ev->ev_queued = 0;
+            /* Reset the items that already have an evq task set
+             */
+            for (j = 0; j < i; j++) {
+                evq[i]->evq_task = NULL;
+            }
+
+            OS_EXIT_CRITICAL(sr);
+            goto has_event;
+        }
+        evq[i]->evq_task = cur_t;
+    }
+
+    os_sched_sleep(cur_t, timo);
+    OS_EXIT_CRITICAL(sr);
+
+    os_sched(NULL);
+
+    OS_ENTER_CRITICAL(sr);
+    for (i = 0; i < nevqs; i++) {
+        /* Go through the entire loop to clear the evq_task variable, 
+         * given this task is no longer sleeping on the event queues.
+         * Return the first event found, so only grab the event if 
+         * we haven't found one.
+         */
+        if (!ev) {
+            ev = STAILQ_FIRST(&evq[i]->evq_list);
+            if (ev) {
+                STAILQ_REMOVE(&evq[i]->evq_list, ev, os_event, ev_next);
+                ev->ev_queued = 0;
+            }
+        }
+        evq[i]->evq_task = NULL;
+    }
+    OS_EXIT_CRITICAL(sr);
+
+has_event:
+    return (ev);
+}
+
+
 void
 os_eventq_remove(struct os_eventq *evq, struct os_event *ev)
 {


[2/2] incubator-mynewt-core git commit: Merge branch 'develop' of https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core into develop

Posted by st...@apache.org.
Merge branch 'develop' of https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core into develop


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/e080c3c4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/e080c3c4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/e080c3c4

Branch: refs/heads/develop
Commit: e080c3c4c6e1b7102550d597dcdb042f0043577b
Parents: 5c87fec 8051041
Author: Sterling Hughes <st...@apache.org>
Authored: Thu May 5 08:18:15 2016 -0700
Committer: Sterling Hughes <st...@apache.org>
Committed: Thu May 5 08:18:15 2016 -0700

----------------------------------------------------------------------
 apps/bleprph/src/main.c                         |   2 +-
 apps/bletest/src/main.c                         |  23 +-
 apps/bletiny/src/bletiny_priv.h                 |   4 +-
 apps/bletiny/src/cmd.c                          | 100 ++++
 apps/bletiny/src/main.c                         |  14 +-
 apps/bletiny/src/parse.c                        |  18 +-
 .../controller/include/controller/ble_ll_conn.h |   2 +-
 .../controller/include/controller/ble_phy.h     |   3 +
 net/nimble/controller/src/ble_ll.c              |   5 +-
 net/nimble/controller/src/ble_ll_adv.c          |  81 ++--
 net/nimble/controller/src/ble_ll_conn.c         |  33 +-
 net/nimble/drivers/nrf51/src/ble_phy.c          |  21 +-
 net/nimble/drivers/nrf52/src/ble_phy.c          |  20 +-
 net/nimble/host/include/host/ble_att.h          |   1 +
 net/nimble/host/include/host/ble_gap.h          |  21 +-
 net/nimble/host/include/host/ble_gatt.h         |   3 +
 net/nimble/host/include/host/ble_hs.h           |  11 +-
 net/nimble/host/include/host/ble_hs_adv.h       |   2 +-
 net/nimble/host/include/host/ble_l2cap.h        |  19 +-
 net/nimble/host/src/ble_att_svr.c               |  89 +++-
 net/nimble/host/src/ble_gap.c                   |  34 ++
 net/nimble/host/src/ble_gap_priv.h              |   6 +-
 net/nimble/host/src/ble_gatts.c                 |  11 +-
 net/nimble/host/src/ble_hs_cfg.c                |   4 +-
 net/nimble/host/src/ble_ibeacon.c               |   4 +-
 net/nimble/host/src/ble_l2cap_sm.c              | 474 ++++++++++++++-----
 net/nimble/host/src/ble_l2cap_sm_cmd.c          |   6 +-
 net/nimble/host/src/test/ble_l2cap_sm_test.c    |  30 +-
 net/nimble/include/nimble/ble.h                 |   6 +
 net/nimble/src/util.c                           |  84 ++++
 30 files changed, 871 insertions(+), 260 deletions(-)
----------------------------------------------------------------------