#endif
/**
+ * Controller lock defines.
+ *
+ * controller_lock_*_d:
+ * - mutex_max_retry: The maximum amount of times to retry the mutex lock before giving up.
+ */
+#ifndef _di_controller_lock_d_
+ #define controller_lock_mutex_max_retry_d 1000000
+#endif // _di_controller_lock_d_
+
+/**
* A structure for sharing mutexes globally between different threads.
*
* The alert lock is intended for a generic waiting on alerts operations.
controller_entry_t *entry = 0;
controller_process_t *process = 0;
- f_status_t status = F_none;
f_array_length_t i = 0;
f_array_length_t j = 0;
pid_t pid = 0;
} // for
}
- // Use the alert lock to toggle enabled (using it as if it is a write like and a signal lock).
- status = f_thread_mutex_lock(&global->thread->lock.alert);
+ f_status_t status = F_none;
- if (F_status_is_error(status)) {
- global->thread->enabled = controller_thread_enabled_not_e;
- }
- else {
+ for (f_array_length_t i = 0; i < controller_lock_mutex_max_retry_d; ++i) {
+
+ status = f_thread_mutex_lock(&global->thread->lock.alert);
+
+ if (F_status_is_error_not(status) || F_status_set_fine(status) == F_parameter || F_status_set_fine(status) == F_deadlock) break;
+ } // for
+
+ if (F_status_is_error_not(status) && F_status_set_fine(status) != F_parameter && F_status_set_fine(status) != F_deadlock) {
if (by == controller_thread_cancel_execute_e) {
global->thread->enabled = controller_thread_enabled_execute_e;
}