@RB:
The idea of having the blocking thread stat decrement the seq var is good.
Code:
THREAD_START(AD0) // adc related process
adc_start_conversion(0);
THREAD_BREAK
[B]if (!adc_finished(0)) seq[AD0]--;[/B]
THREAD_BREAK
peocess_adc_value():
THREAD_END(AD0)
I lean towards that externally controlled model because to me the best
multitasking system is to have multiple fast loops that can run at the
same time. But I'm beginning to see you lean more towards an "object
oriented" model where threads can just halt and wait for a button press
etc. (Please correct me if I'm wrong there!)
I was under the impression that we were talking about cooperative
multi tasking. By "Externally controlled" I assume you mean that there
is some code outside the tasks that control execution. This can be the
case in both cooperative and preemptive systems. Can we agree that this
not task code is called a kernel?
Structured programing and OOP are philosophies, we can code
in their styles using any procedural language.
Structured programming was developed in response to spaghetti
code. OOP is an effort to make large systems more manageable
and has its detractors.
So if you are saying that I lean in the direction of good
coding practices you are correct. But I did not suggest
that we use objects.
At the most fundamental level the difference between what weW
are doing is in the placement of the state guard statement.
The line of code that determines if any given state will execute.
Your method embeds a guard statement for each state within the
thread. NAOS uses a single guard statement per thread in the kernel
(main loop). The state within the thread is selected via a
switch/case, a n way branch.
NAOS is a thread per task system. It allows one to set priority and
blocking on a per task basis. The use of this
in conjunction with ISR routines that unblock when resources become
available is a powerful mechanism.
As I said earlier a well designed cooperative system can out preform
a preemptive one.