]> Kevux Git Server - controller/commit
Update: Major improvements in locking logic.
authorKevin Day <Kevin@kevux.org>
Sun, 10 Aug 2025 01:32:18 +0000 (20:32 -0500)
committerKevin Day <Kevin@kevux.org>
Sun, 10 Aug 2025 01:32:18 +0000 (20:32 -0500)
commitefdd3047649966affa46ac0195be18d457e089d3
tree8ca847ad12928a0ea15ff7ee0721d236d0ece483
parent95015165aa68c4712ee1db9bbade957d0839887b
Update: Major improvements in locking logic.

Major Improvements:
- Add custom thread status checking functions (also replacing `controller_thread_is_enabled()` with `controller_thread_enable_is()`).
- The thread enable property is now `enable` rather than `enabled`.
- Add new `controller_thread_enable_none_e` to allow for handling default behavior.
- Add new `enable` read/write lock to better handle the reading and writing of the enable property.
- Change the signalling logic to directly call `f_thread_condition_signal_all()` and to not read lock the conditions on signal send.
- Change the lock status checks to more explicitly check for `F_okay` so that unknown conditions without error bit set are ignored.

Being explicit on handling the `F_okay` helps ensures that the lock is guaranteed to be set.

I think I need to additional review and re-structuring of the thread logic beyond this commit.
There will likely be additional commits in the future to further improve the locking logic.

I believe that there are some cases where unlock might be called on a not-locked lock.
The additional work will likely include addressing this.
I suspect this is happening in cases where the same function is called in two different contexts.
One context is directly from a thread and another is in the middle of processing something.
The lock might not be set in the case of the directly calling from the thread.
32 files changed:
data/build/settings
data/build/stand_alone/settings.controller
data/build/stand_alone/settings.init
sources/c/program/controller/init/signal.c
sources/c/program/controller/main/common/enumeration/thread.h
sources/c/program/controller/main/common/type/lock.c
sources/c/program/controller/main/common/type/lock.h
sources/c/program/controller/main/common/type/thread.h
sources/c/program/controller/main/controller.h
sources/c/program/controller/main/entry.c
sources/c/program/controller/main/entry/preprocess.c
sources/c/program/controller/main/entry/process.c
sources/c/program/controller/main/instance.c
sources/c/program/controller/main/instance.h
sources/c/program/controller/main/instance/prepare.c
sources/c/program/controller/main/lock.c
sources/c/program/controller/main/lock.h
sources/c/program/controller/main/process.c
sources/c/program/controller/main/rule/execute.c
sources/c/program/controller/main/rule/instance.c
sources/c/program/controller/main/rule/wait.c
sources/c/program/controller/main/thread/cleanup.c
sources/c/program/controller/main/thread/control.c
sources/c/program/controller/main/thread/enable.c [new file with mode: 0644]
sources/c/program/controller/main/thread/enable.h [new file with mode: 0644]
sources/c/program/controller/main/thread/entry.c
sources/c/program/controller/main/thread/instance.c
sources/c/program/controller/main/thread/instance.h
sources/c/program/controller/main/thread/is.c
sources/c/program/controller/main/thread/is.h
sources/c/program/controller/main/thread/rule.c
sources/c/program/controller/main/thread/signal.c