You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "TaiJuWu (via GitHub)" <gi...@apache.org> on 2023/09/16 18:32:20 UTC

[GitHub] [nuttx] TaiJuWu commented on a diff in pull request #10605: Try to implement fair spinlock

TaiJuWu commented on code in PR #10605:
URL: https://github.com/apache/nuttx/pull/10605#discussion_r1327995142


##########
sched/semaphore/spinlock.c:
##########
@@ -384,4 +384,176 @@ void spin_clrbit(FAR volatile cpu_set_t *set, unsigned int cpu,
 }
 #endif
 
+/****************************************************************************
+ * Name: fair_spinlock_list_init
+ *
+ * Description:
+ *   Initialize the link linsk of fair spinlock.
+ *   If there is any spinlock node, the node will get lock.
+ *
+ * Input Parameters:
+ *   lock_list - A reference to the spinlock list.
+ *
+ * Returned Value:
+ *   None
+ *
+ * Assumptions:
+ *   None.
+ *
+ ****************************************************************************/
+
+void fair_spinlock_list_init(fair_spinlock_list_t *lock_list)
+{
+  lock_list->lock = SP_UNLOCKED;
+  list_initialize(&lock_list->list);
+}
+
+/****************************************************************************
+ * Name: fair_spinlock_init
+ *
+ * Description:
+ *   Initialize the fair spinlock. Tje lock state is set as SP_LOCK util
+ *   some give lock to holder.
+ *
+ * Input Parameters:
+ *   lock - A reference to the spinlock object to lock.
+ *
+ * Returned Value:
+ *   None
+ *
+ * Assumptions:
+ *   Not running at the interrupt level.
+ *
+ ****************************************************************************/
+
+void fair_spinlock_init(fair_spinlock_t *lock)
+{
+  lock->lock = SP_LOCKED;

Review Comment:
   Default there is a guy get this lock.
   I will explain more detail on the last response.
   Hope you can give some suggestions.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org