I've been reading about RTOS and multitasking with 18F PIC micros or eventually DSPICs in mind. While I managed to understand somehow the basics I have lot of doubts.
A scenario: there is a micro continuously polling a keypad and three inputs normally high. Once one of them is found low, and after a certain delay the alarm is started: a flashing LED plus an auxiliary contact closed.
Asynchronously to the above the micro should check a serial connection, to receive a request for data and send it if certain conditions are met.
I guess a reasonable sequence could be:
Check the input.
If input is low, start debouncing.
Check input again.
If input is low, start delay.
If input still low, start the alarm.
Repeat the check for the other two channels.
Check the kepad in case the user decides to stop the flashing and open the contact.
Check the RS232 input to see if valid commands are received.
In case a valid command is received, send the information requested.
Mantain the LEDs flashing as long they are not turned off by the user.
My questions:
a- What would be the ACTUAL "tasks" to implement the above in a multitasking fashion.
b- Is it any "rule of thumb" to know how to break everything in proper "subtasks"? I feel that most of the lines above should be broken into smaller pieces. I would like to learn how to recognize them. Could you mention them in detail?
c- What is more reasonable for this case, preemptive or cooperative multitasking? Why?
d- Some books talk about "procedures" and mention the "tasks" as part of them. What is a procedure in this context?
e- Preemptive means that all tasks are given the same period to run? Or could be that different tasks get different lengths of time to run? Not doing this means that the longest one imposes the minimum for the time slice used, right?
f- What is an "hostile task"?
g- I have the feeling that trying to write my own kernel even if VERY elementary would be pretty useless but I found this subject extremely appealing. I know assembly but no C. Any advise :?:
Sorry for the long posting.
Replies will be appreciated. Really.
A scenario: there is a micro continuously polling a keypad and three inputs normally high. Once one of them is found low, and after a certain delay the alarm is started: a flashing LED plus an auxiliary contact closed.
Asynchronously to the above the micro should check a serial connection, to receive a request for data and send it if certain conditions are met.
I guess a reasonable sequence could be:
Check the input.
If input is low, start debouncing.
Check input again.
If input is low, start delay.
If input still low, start the alarm.
Repeat the check for the other two channels.
Check the kepad in case the user decides to stop the flashing and open the contact.
Check the RS232 input to see if valid commands are received.
In case a valid command is received, send the information requested.
Mantain the LEDs flashing as long they are not turned off by the user.
My questions:
a- What would be the ACTUAL "tasks" to implement the above in a multitasking fashion.
b- Is it any "rule of thumb" to know how to break everything in proper "subtasks"? I feel that most of the lines above should be broken into smaller pieces. I would like to learn how to recognize them. Could you mention them in detail?
c- What is more reasonable for this case, preemptive or cooperative multitasking? Why?
d- Some books talk about "procedures" and mention the "tasks" as part of them. What is a procedure in this context?
e- Preemptive means that all tasks are given the same period to run? Or could be that different tasks get different lengths of time to run? Not doing this means that the longest one imposes the minimum for the time slice used, right?
f- What is an "hostile task"?
g- I have the feeling that trying to write my own kernel even if VERY elementary would be pretty useless but I found this subject extremely appealing. I know assembly but no C. Any advise :?:
Sorry for the long posting.
Replies will be appreciated. Really.