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/10 00:35:50 UTC

incubator-mynewt-core git commit: update comments, remove trailing whitespace.

Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop 2fa4773ee -> 295a53238


update comments, remove trailing whitespace.


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

Branch: refs/heads/develop
Commit: 295a53238d907aeeab0472e9737e3b253c73dfcd
Parents: 2fa4773
Author: Sterling Hughes <st...@apache.org>
Authored: Mon May 9 17:35:16 2016 -0700
Committer: Sterling Hughes <st...@apache.org>
Committed: Mon May 9 17:35:43 2016 -0700

----------------------------------------------------------------------
 libs/os/include/os/os_callout.h |  5 ++++-
 libs/os/src/os.c                | 41 ++++++++++++++++++++++++++++--------
 libs/os/src/os_callout.c        | 35 ++++++++++++++++++++++++------
 3 files changed, 65 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/295a5323/libs/os/include/os/os_callout.h
----------------------------------------------------------------------
diff --git a/libs/os/include/os/os_callout.h b/libs/os/include/os/os_callout.h
index bba8571..baa377a 100644
--- a/libs/os/include/os/os_callout.h
+++ b/libs/os/include/os/os_callout.h
@@ -6,7 +6,7 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *  http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
@@ -33,6 +33,9 @@ struct os_callout {
 typedef void (*os_callout_func_t)(void *);
 
 struct os_callout_func {
+    /* Must be the first element in the structure for casting
+     * purposes.
+     */
     struct os_callout cf_c;
     os_callout_func_t cf_func;
 };

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/295a5323/libs/os/src/os.c
----------------------------------------------------------------------
diff --git a/libs/os/src/os.c b/libs/os/src/os.c
index 963fc40..5ec71ec 100644
--- a/libs/os/src/os.c
+++ b/libs/os/src/os.c
@@ -6,7 +6,7 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *  http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
@@ -22,15 +22,15 @@
 
 #include "hal/hal_os_tick.h"
 
-#include <assert.h> 
+#include <assert.h>
 
-struct os_task g_idle_task; 
+struct os_task g_idle_task;
 os_stack_t g_idle_task_stack[OS_STACK_ALIGN(OS_IDLE_STACK_SIZE)];
 
 uint32_t g_os_idle_ctr;
 /* Default zero.  Set by the architecture specific code when os is started.
  */
-int g_os_started; 
+int g_os_started;
 
 #ifdef ARCH_sim
 #define MIN_IDLE_TICKS  1
@@ -39,6 +39,14 @@ int g_os_started;
 #endif
 #define MAX_IDLE_TICKS  (600 * OS_TICKS_PER_SEC)        /* 10 minutes */
 
+/**
+ * Idle operating system task, runs when no other tasks are running.
+ * The idle task operates in tickless mode, which means it looks for
+ * the next time an event in the system needs to run, and then tells
+ * the architecture specific functions to sleep until that time.
+ *
+ * @param arg unused
+ */
 void
 os_idle_task(void *arg)
 {
@@ -46,7 +54,6 @@ os_idle_task(void *arg)
     os_time_t now;
     os_time_t iticks, sticks, cticks;
 
-    /* For now, idle task simply increments a counter to show it is running. */
     while (1) {
         ++g_os_idle_ctr;
         OS_ENTER_CRITICAL(sr);
@@ -61,13 +68,21 @@ os_idle_task(void *arg)
         } else {
             /* NOTHING */
         }
+        /* Tell the architecture specific support to put the processor to sleep
+         * for 'n' ticks.
+         */
         os_tick_idle(iticks);
         OS_EXIT_CRITICAL(sr);
     }
 }
 
-int 
-os_started(void) 
+/**
+ * Has the operating system started.
+ *
+ * @return 1 if the operating system has started, 0 if it hasn't
+ */
+int
+os_started(void)
 {
     return (g_os_started);
 }
@@ -76,11 +91,15 @@ os_started(void)
 void
 os_init_idle_task(void)
 {
-    os_task_init(&g_idle_task, "idle", os_idle_task, NULL, 
-            OS_IDLE_PRIO, OS_WAIT_FOREVER, g_idle_task_stack, 
+    os_task_init(&g_idle_task, "idle", os_idle_task, NULL,
+            OS_IDLE_PRIO, OS_WAIT_FOREVER, g_idle_task_stack,
             OS_STACK_ALIGN(OS_IDLE_STACK_SIZE));
 }
 
+/**
+ * Initialize the operating system, calls into the architecture specific
+ * support to initialize the operating system.
+ */
 void
 os_init(void)
 {
@@ -90,6 +109,10 @@ os_init(void)
     assert(err == OS_OK);
 }
 
+/**
+ * Start the operating system, calls into the architecture specific support
+ * to start the operating system.
+ */
 void
 os_start(void)
 {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/295a5323/libs/os/src/os_callout.c
----------------------------------------------------------------------
diff --git a/libs/os/src/os_callout.c b/libs/os/src/os_callout.c
index 7db2422..02462c0 100644
--- a/libs/os/src/os_callout.c
+++ b/libs/os/src/os_callout.c
@@ -6,7 +6,7 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *  http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
@@ -35,11 +35,11 @@ _os_callout_init(struct os_callout *c, struct os_eventq *evq, void *ev_arg)
 }
 
 /**
- * Initialize a callout.  
+ * Initialize a callout.
  *
- * Callouts are used to schedule events in the future onto a task's event 
- * queue.  Callout timers are scheduled using the os_callout_reset() 
- * function.  When the timer expires, an event is posted to the event 
+ * Callouts are used to schedule events in the future onto a task's event
+ * queue.  Callout timers are scheduled using the os_callout_reset()
+ * function.  When the timer expires, an event is posted to the event
  * queue specified in os_callout_func_init().  The event argument given here
  * is posted in the ev_arg field of that event.
  *
@@ -48,7 +48,7 @@ _os_callout_init(struct os_callout *c, struct os_eventq *evq, void *ev_arg)
  * @param timo_func The function to call on this callout for the host task
  *                  used to provide multiple timer events to a task
  *                  (this can be NULL.)
- * @param ev_arg The argument to provide to the event when posting the 
+ * @param ev_arg The argument to provide to the event when posting the
  *               timer.
  */
 void
@@ -59,6 +59,11 @@ os_callout_func_init(struct os_callout_func *cf, struct os_eventq *evq,
     cf->cf_func = timo_func;
 }
 
+/**
+ * Stop the callout from firing off, any pending events will be cleared.
+ *
+ * @param c The callout to stop
+ */
 void
 os_callout_stop(struct os_callout *c)
 {
@@ -78,6 +83,14 @@ os_callout_stop(struct os_callout *c)
     OS_EXIT_CRITICAL(sr);
 }
 
+/**
+ * Reset the callout to fire off in 'ticks' ticks.
+ *
+ * @param c The callout to reset
+ * @param ticks The number of ticks to wait before posting an event
+ *
+ * @return 0 on success, non-zero on failure
+ */
 int
 os_callout_reset(struct os_callout *c, int32_t ticks)
 {
@@ -120,6 +133,12 @@ err:
     return (rc);
 }
 
+/**
+ * This function is called by the OS in the time tick.  It searches the list
+ * of callouts, and sees if any of them are ready to run.  If they are ready
+ * to run, it posts an event for each callout that's ready to run,
+ * to the event queue provided to os_callout_func_init().
+ */
 void
 os_callout_tick(void)
 {
@@ -153,6 +172,10 @@ os_callout_tick(void)
 /*
  * Returns the number of ticks to the first pending callout. If there are no
  * pending callouts then return OS_TIMEOUT_NEVER instead.
+ *
+ * @param now The time now
+ *
+ * @return Number of ticks to first pending callout
  */
 os_time_t
 os_callout_wakeup_ticks(os_time_t now)