You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2019/01/14 23:04:09 UTC

[GitHub] kasjer commented on a change in pull request #1593: console newtmgr coexistance

kasjer commented on a change in pull request #1593: console newtmgr coexistance
URL: https://github.com/apache/mynewt-core/pull/1593#discussion_r247699641
 
 

 ##########
 File path: sys/console/minimal/src/console.c
 ##########
 @@ -70,16 +71,73 @@ console_echo(int on)
     echo = on;
 }
 
+int
+console_lock(int timeout)
+{
+    int rc = OS_OK;
+
+    /* Locking from isr while some task own mutex fails with OS_EBUSY */
+    if (os_arch_in_isr()) {
+        if (os_mutex_get_level(&console_write_lock)) {
+            rc = OS_EBUSY;
+        }
+        goto end;
+    }
+
+    rc = os_mutex_pend(&console_write_lock, timeout);
+    if (rc == OS_NOT_STARTED) {
+        /* No need to block before system start make it OK */
+        rc = OS_OK;
+    }
+
+    end:
+    return rc;
+}
+
+int
+console_unlock(void)
+{
+    int rc = OS_OK;
+
+    if (os_arch_in_isr()) {
+        goto end;
+    }
+
+    rc = os_mutex_release(&console_write_lock);
+    assert(rc == OS_OK || rc == OS_NOT_STARTED);
+    end:
 
 Review comment:
   done

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services