Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

RTOS & multitasking

Status
Not open for further replies.

atferrari

Well-Known Member
Most Helpful Member
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.
 
Why would you need multi tasking on a uC. All the processes are known and so can be done in order. Multi tasking is only really needed when multiple applications need to run together.

Can anyone come up with a scenario where multi tasking is required.

The scenario you outline above can easily be accomplished with a 16 series PIC.

Mike.
 
Pommie said:
Why would you need multi tasking on a uC. All the processes are known and so can be done in order. Multi tasking is only really needed when multiple applications need to run together.

'Multi-tasking' is VERY rare anyway, certainly in anything domestic?, all you do is time share slices of time - Windows and Intel processors don't do this at all well though!. Probably the best home multi-tasking machine was the Commodore Amiga?, it's Motorola processor was far better for time slicing than the Intel offerings.

Can anyone come up with a scenario where multi tasking is required.

Pretty rare, you usually only need polling and interrupts.

The scenario you outline above can easily be accomplished with a 16 series PIC.

Or a low spec 12 series?, it's a VERY trivial task.
 
Hola Pommie & NIgel,

Trivial as it is (I know that :!: ) the concrete mention was made to have someone giving an example of actual tasks I could break those processes into.

I don't need to describe the whole nuclear plant software management to get that. Do I... :?:

Could you help?
 
google around, for some reason I though I saw a RTOS for the pic (ar atmel), though that is overkill for your project, but the pic can handle it, memory allowing.. But if you find a C RTOS for a micro of some type it should be easy to port it over.

Your code looks top down to me?

Also, there is nothing wrong with assembler if you know it.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top